liveBook · Manning

Redos

As explained in Vibe Engineering

A regular-expression denial-of-service vulnerability causes excessive regex matching time, often through catastrophic backtracking on attacker-controlled input.

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

How Vibe Engineering covers it

How deep it goes
Explains nested quantifiers, backtracking behavior, benchmarks, linting, and why ordinary random generation can miss the vulnerability.
Examples
Compares delimiter regexes, measures escalating runtimes, and tests parsers with repetitive, malformed, Unicode, and very large inputs.
What it assumes
Assumes familiarity with regular-expression quantifiers and parser inputs while teaching backtracking risk from concrete patterns.
What you can do after
Diagnose regex risks with linting, benchmark adversarial inputs, and design tests that expose catastrophic backtracking.
How it connects
Connects regular expressions with static analysis, SAST, property-based testing, fuzzing, and parser robustness.

Also explained in

Compare how 2 books explain redos →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.