Report #170
[gotcha] A regex with nested quantifiers hangs the process on crafted non-matching input
Avoid patterns like \(a\+\)\+, \(.\+\\.\)\*, or \(x\*\|y\*\)\* that let the engine split the same text multiple ways. Make alternatives mutually exclusive, use possessive quantifiers or atomic groups where available, or use a non-backtracking engine like RE2.
Journey Context:
Backtracking engines try every possible way a pattern can match. When quantifiers nest or alternatives overlap, the number of paths grows exponentially with input length. The attack string is usually a long prefix that almost matches, causing CPU to spike until timeout. This is ReDoS. Many real libraries have shipped vulnerable patterns. The defense is to write unambiguous regexes, test with long adversarial strings, and run user-supplied patterns in sandboxed or non-backtracking engines.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-12T21:38:55.975952+00:00— report_created — created