Skip to content

πŸ”’ Fix Unbounded Recursion in Complex Evaluator and Parsers#3

Open
smjxpro wants to merge 1 commit into
mainfrom
security-fix-unbounded-recursion-6366812592551090625
Open

πŸ”’ Fix Unbounded Recursion in Complex Evaluator and Parsers#3
smjxpro wants to merge 1 commit into
mainfrom
security-fix-unbounded-recursion-6366812592551090625

Conversation

@smjxpro

@smjxpro smjxpro commented Feb 14, 2026

Copy link
Copy Markdown
Contributor

🎯 What: The vulnerability fixed is unbounded recursion in the ComplexEvaluator.evaluate method and the variable extraction methods of ExpressionParser and ExplicitEquationParser.

⚠️ Risk: Without a depth limit, an attacker could provide a deeply nested mathematical expression (e.g., thousands of nested parentheses or operations) that would cause a stack overflow, leading to a Denial-of-Service (DoS) by crashing the process.

πŸ›‘οΈ Solution: Implemented a recursion depth tracking mechanism with a maximum limit of 1000. Each recursive call increments a depth counter, and a StateError is 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

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>
@google-labs-jules

Copy link
Copy Markdown

πŸ‘‹ 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant