The vulnerability allows malicious Jiffle scripts to cause a Denial of Service by entering an infinite loop. Jiffle scripts are parsed and compiled into Java code, specifically into classes that extend AbstractJiffleRuntime (e.g., AbstractDirectRuntime, AbstractIndirectRuntime). The core logic, including loops, is executed within the evaluate methods of these generated classes.
The vulnerability existed because the methods responsible for generating the Java code for Jiffle loop constructs (e.g., While.write, Until.write, LoopInRange.write) in the it.geosolutions.jaiext.jiffle.parser.node package did not include any mechanism to limit the number of iterations. Consequently, when a Jiffle script with an unbounded loop was processed, the evaluate method of the corresponding runtime instance would execute this loop indefinitely.
The patch addresses this by:
- Introducing an iteration counting mechanism in
it.geosolutions.jaiext.jiffle.runtime.AbstractJiffleRuntime (fields _iterations, _maxIterations, and method checkLoopIterations()).
- Modifying the
write methods in the parser.node classes to inject calls to checkLoopIterations() at the beginning of each generated loop block.
- Initializing the iteration counter (
_iterations = 0;) at the start of the generated evaluate methods (evident from changes in it.geosolutions.jaiext.jiffle.parser.node.Script.write and the patched reference/*.java files).
Therefore, the evaluate methods of the Jiffle runtime are the primary functions where the infinite loop would manifest during exploitation. The write methods in the parser are culpable for generating the vulnerable loop code. Both are critical to understanding the vulnerability.