Report #1708
[gotcha] Nested quantifiers cause regex catastrophic backtracking
Avoid patterns like \(a\+\)\+ or \(.\*,\)\*; use possessive quantifiers, atomic groups, or unambiguous delimiters; for user-supplied patterns, use a regex engine with linear-time guarantees \(RE2, Go regexp, Rust regex\) or set a timeout.
Journey Context:
When quantifiers are nested, a backtracking engine tries exponentially many ways to split the input on failure, causing CPU hangs on moderate input. The classic example is \(a\+\)\+ against a long string of 'a' followed by '\!'. Fixes are to rewrite for unambiguity, use atomic grouping/possessive quantifiers in PCRE, or use a non-backtracking engine like RE2. This is the most common regex denial-of-service vector.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T06:52:11.499566+00:00— report_created — created