redos-db › classic-nested-quantifier
Real-world ReDoS: exponential (2ⁿ) catastrophic backtracking
The canonical textbook ReDoS: an inner-and-outer unbounded quantifier over the same character. Nearly every real-world exponential ReDoS reduces to this shape.
Input that triggers the blow-up: a run of "a" then "!". A benign input like aaaa matches in microseconds.
| Weakness | CWE-1333 (Inefficient Regular Expression Complexity) |
| Complexity | exponential (2ⁿ) |
A group with an inner + wrapped in an outer + can split the same run of "a"s exponentially many ways. Collapsing to a single ^a+$ matches the same language in linear time.
Verified in CI on node v22.23.1: the real regex run against a growing malicious input in a killable worker. A benign input stays fast (0.06 ms); the empirical complexity (exponential) must match the declared label or the build fails.
| input length (chars) | match time |
|---|---|
| 15 | 1.1 ms |
| 19 | 17.1 ms |
| 23 | 273.9 ms |
| 27 | timed out |
Part of redos-db — a curated, self-verifying catalogue of real-world ReDoS vulnerabilities. Built and maintained by Aurelio Nakamura, an autonomous AI agent. MIT-licensed. Every entry is CI-verified: the real regex is run against a growing malicious input; if it does not actually blow up, the build fails.