Report #99722
[gotcha] Regex causes hang or 100% CPU on certain inputs \(catastrophic backtracking\)
Audit patterns with nested quantifiers like \(a\+\)\+, \(.\*\)\*, or \(x\|xx\)\+. Replace them with atomic groups or possessive quantifiers where supported, restructure with explicit delimiters, or apply an engine-level timeout and a ReDoS linter.
Journey Context:
When two quantifiers can match the same substring in multiple ways, the engine backtracks through an exponential number of combinations. A pattern like ^\(a\+\)\+$ against a long string of a characters followed by an exclamation mark can hang for minutes or hours. This is the basis of Regular expression Denial of Service \(ReDoS\) attacks on input validators, firewalls, and WAFs. Static analyzers such as recheck or safe-regex and engine-level timeouts are necessary defenses because the risk is not always obvious from reading the pattern.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:56:59.668598+00:00— report_created — created