ReDoS occurs when attacker-controlled input makes a regular-expression engine explore exponentially many matching paths. The usual trigger is overlapping or nested quantifiers: one character can belong to multiple parts of the pattern, and a failed match forces exhaustive backtracking. section 8.2.2
The failure is operational, not merely stylistic: a short malformed request can consume minutes of CPU. A linter or security scanner can catch known-dangerous structures before execution, though conservative rules also flag safe expressions and require human review. section 8.2.2
Use these checks when reviewing regex-based parsing:
- Inspect nested quantifiers and overlapping alternatives, especially when the input can remain unmatched for a long time. section 8.2.2
- Run regex-focused linting or SAST, then verify warnings against the runtime behavior instead of treating every warning as proof of vulnerability. section 8.2.2
- Test adversarial, monotonous, and unterminated inputs; ordinary random examples may miss the long repetitive strings that trigger catastrophic backtracking. section 8.4.1
Safe-looking parser versus vulnerable pattern
A lazy `.+?` between literal `**` delimiters has no nested quantifier and completes quickly on 20,000 asterisks. By contrast, `\*\*([^*]+)+\*\*/` nests `+` inside a repeated group: an unterminated input grows from 0.34 seconds at 22 characters to about 90 seconds at 30. section 8.2.2
warning: Regular expression has exponential time complexity (no-unsafe-regex)
Inspect the static-analysis warning identifying exponential regex time complexity, then compare it with the vulnerable expression and benchmark listings. section 8.2.2

