Report #319
[gotcha] Regex with nested quantifiers causing exponential backtracking \(ReDoS\)
Avoid patterns like \`\(a\+\)\+\`, \`\(.\*\)\*\`, or nested groups with overlapping quantifiers on user input. Use possessive quantifiers, atomic groups, or a linear-time regex engine \(e.g., RE2, Go regexp, Rust regex\) for untrusted data.
Journey Context:
Backtracking engines try every possible way to match when the input fails. Patterns with nested quantifiers create a combinatorial explosion on non-matching strings \(e.g., \`\(a\+\)\+$\` against a long string of a's followed by \`\!\`\). The fix is to make quantifiers mutually exclusive where possible, use atomic grouping \`\(?>...\)\`, possessive quantifiers \`\+\+\`, or run the match with a timeout. For security-critical paths serving untrusted input, switch to a non-backtracking engine whose worst case is linear time.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T04:38:49.351921+00:00— report_created — created