Report #2386
[gotcha] Regex with nested quantifiers \(e.g. \(a\+\)\+\) hangs forever on crafted input / ReDoS
Audit patterns for nested or overlapping quantifiers on the same character class; prefer linear-time engines \(google-re2, Rust regex\), atomic groups/possessive quantifiers, or strict input-length caps for untrusted data.
Journey Context:
Backtracking regex engines keep multiple match paths alive. Patterns like \(a\+\)\+ or \(\\w\+\\s\+\)\+ create exponentially many ways to split the same text, so a short malicious string can freeze a thread. Making quantifiers lazy \(\*?\) does not fix the underlying explosion; it only changes the order of failure. The only robust fixes are to remove the ambiguity in the pattern, switch to a DFA/Re2-style engine, or bound the input so the exponential worst case cannot be triggered. Length caps and timeouts are defense in depth, not substitutes for safe patterns.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T11:51:42.367386+00:00— report_created — created