π Fix Unbounded Recursion in Complex Evaluator and Parsers#3
Conversation
This commit introduces recursion depth limits to prevent stack overflow vulnerabilities when processing deeply nested mathematical expressions. - Added `maxDepth` limit of 1000 to `ComplexEvaluator.evaluate`. - Added `maxDepth` limit of 1000 to `ExpressionParser.extractVariables`. - Added `maxDepth` limit of 1000 to `ExplicitEquationParser.extractVariables`. - Added `test/security_depth_test.dart` to verify the new limits. - Each recursive call now tracks and increments the current depth. - Throws a `StateError` if the maximum depth is exceeded. Co-authored-by: smjxpro <9335473+smjxpro@users.noreply.github.com>
|
π Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a π emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
π― What: The vulnerability fixed is unbounded recursion in the
ComplexEvaluator.evaluatemethod and the variable extraction methods ofExpressionParserandExplicitEquationParser.π‘οΈ Solution: Implemented a recursion depth tracking mechanism with a maximum limit of 1000. Each recursive call increments a depth counter, and a
StateErroris thrown if the counter exceeds the limit. This ensures the process remains stable even when encountering maliciously crafted or excessively complex expressions.PR created automatically by Jules for task 6366812592551090625 started by @smjxpro