Skip to content

Hardening: Implement nesting depth limits and systematic overflow pro…#623

Open
uwezkhan wants to merge 1 commit intogoogle:mainfrom
uwezkhan:overflow-checks
Open

Hardening: Implement nesting depth limits and systematic overflow pro…#623
uwezkhan wants to merge 1 commit intogoogle:mainfrom
uwezkhan:overflow-checks

Conversation

@uwezkhan
Copy link
Copy Markdown

This PR adds a few safety improvements to RE2 to better handle untrusted regex input.

Introduces a nesting depth limit (default 1000) to avoid extremely deep expressions that could cause memory or processing issues.
Adds a clear error (kRegexpNestedTooDeep) so users know when a regex is too deeply nested.
Fixes potential integer overflow in string handling and strengthens PODArray to prevent invalid memory allocations.
Confirms that key parts like destruction and simplification are already safe from stack overflows.

Overall, these changes make RE2 more robust against edge cases and malicious inputs.

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