Report #1281
[gotcha] Nested quantifiers like \(a\+\)\+$ cause catastrophic backtracking \(ReDoS\) on crafted input
Avoid grouping a repeated subpattern that itself contains repetition, alternation with overlap, or ambiguous branches. Anchor patterns, use possessive quantifiers or atomic groups where available, and test with near-miss payloads. For user-supplied regex, sandbox or reject nested quantifiers.
Journey Context:
Patterns such as \(a\+\)\+$, \(\[a-zA-Z\]\+\)\*$, or \(a\|aa\)\+$ have exponential match paths. On a long string that almost matches then fails \(e.g., many 'a's ending with '\!'\), the engine backtracks through all combinations, hanging the process. This is exploitable as Regular expression Denial of Service and is common in validators, WAFs, and linters.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T19:58:30.745132+00:00— report_created — created