Module lessons (2/4)
ReDoS: Quantifier Bombs & Safe Patterns
Detect nested quantifier ReDoS traps statically and rewrite vulnerable slug validators into deterministic linear patterns.
What you'll learn in this lesson
- Explain why JavaScript's backtracking NFA regex engine stalls exponentially (ReDoS) on nested quantifiers like
([a-z]+)+. - Enforce bounded input lengths before running any regex validator as your primary denial-of-service circuit breaker.
- Detect nested quantifier risks statically and rewrite ambiguous slug/identifier patterns into linear deterministic regexes.
Overview
Because JavaScript's built-in RegExp uses a backtracking NFA engine, patterns containing ambiguous nested quantifiers (^([a-z0-9-]+)+$) or overlapping alternations examine exponentially many backtracking branches when a near-matching string fails on its final character. Even 32 bad characters can peg a single-threaded Node.js event loop at 100%…
Compare vulnerable patterns against fast, unambiguous alternatives:
Sections covered in this lesson
- 11. Catastrophic NFA Backtracking vs Deterministic Delimiters
- 22. Interactive Explorer: ReDoS Backtracking Curves
- 33. Progressive Labs: Warm-Up → Attack → Defend → Harden
- 44. Checkpoints & Code Review
Unlock "ReDoS: Quantifier Bombs & Safe Patterns" and the full Application & Web Security curriculum
Detect nested quantifier ReDoS traps statically and rewrite vulnerable slug validators into deterministic linear patterns.
Unlock all 6 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Application & Web Security plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.