Fix ReDoS vulnerability in ParameterMetadataExtractor regex#111
Open
Vipin-Sharma wants to merge 1 commit intomasterfrom
Open
Fix ReDoS vulnerability in ParameterMetadataExtractor regex#111Vipin-Sharma wants to merge 1 commit intomasterfrom
Vipin-Sharma wants to merge 1 commit intomasterfrom
Conversation
Fixed regex pattern that was vulnerable to catastrophic backtracking: - Changed from: (\w+\.\w+|\w+)\s*=\s*\? - Changed to: (\w++(?:\.\w++)?+)\s*+=\s*+\? Key improvements: - Used possessive quantifiers (\w++ instead of \w+) to prevent backtracking - Used possessive optional (?:...)++ to prevent nested backtracking - This eliminates polynomial runtime vulnerability while maintaining functionality All 28 tests pass successfully. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed Regular Expression Denial of Service (ReDoS) vulnerability in
ParameterMetadataExtractorby using possessive quantifiers throughout the regex pattern.Changes
(\w+\.\w+|\w+)\s*=\s*\?(\w++(?:\.\w++)?+)\s*+=\s*+\?Why This Works
The fix uses possessive quantifiers (
++) which prevent backtracking completely:\w++- matches word characters without backtracking(?:\.\w++)?+- possessive optional group with possessive inner match\s*+- possessive whitespace matchingThis eliminates the polynomial runtime vulnerability while maintaining identical functionality.
Technical Explanation
Possessive quantifiers commit to their matches immediately and never backtrack, making catastrophic backtracking impossible. This is the recommended approach for preventing ReDoS in complex patterns.
Test plan
🤖 Generated with Claude Code