DevTools Logo

ReDoS Vulnerability Checker

ReDoS Vulnerability Checker

Find catastrophic-backtracking risk in a regex, see exact spans, and measure growth in a killable worker.

Runs in your browser
Try an example

Regex pattern

Pattern with highlighted risk spans

Spans appear here once the pattern is analysed.

Click a highlighted span to focus its finding below. Every finding also appears as text in the report.

Risk report

Paste a regex to scan for catastrophic backtracking

Structural risks, exact spans and a guarded timing sweep — all in this browser tab.

Details

Paste a JavaScript regular expression and optional flags. A zero-dependency parser computes character sets over the pattern AST and flags nested quantifiers, adjacent overlapping quantifiers, shared-prefix alternations, repeated dot-stars, optional ambiguity and risky backreferences. Each finding carries an exact source span, an explanation and a fix; simple nested quantifiers get a suggested rewrite with an equivalence caveat. A separate guarded leg synthesises an adversarial input from the computed character sets and runs an increasing length sweep inside a Web Worker with a 300 ms per-run budget. A killed run, quadratic curve or superlinear curve is reported alongside the static evidence, and the whole report can be copied as JSON. Patterns stay in this tab; verdicts are advisory because only a DFA-based engine can prove safety.

More examples

Nested quantifier in a validator

^([a-zA-Z]+)*$

The nested quantifier detector highlights ([a-zA-Z]+)*, grades it HIGH and suggests the flattened [a-zA-Z]* rewrite.

Overlapping alternation under repetition

^(a|a)*$

Both branches can start with the same character, so a failing suffix makes the engine retry both branches on every repetition.

Safe, tightly bounded pattern

^[0-9]{4}$

No ambiguous shape is found; a linear timing sweep provides clean evidence for the generated probe only.

    Examples

    Nested quantifier

    Input
    ^([a-zA-Z]+)*$
    Output
    HIGH · nested-quantifier [1, 13) · rewrite ^[a-zA-Z]*$

    The outer star can split a run of letters between inner repetitions in many ways; flattening the quantifiers removes the ambiguity.

    Shared alternation prefix

    Input
    ^(a|a)*$
    Output
    MEDIUM · alternation-prefix [2, 5) · fix: use [a] or merge branches

    Both branches start with 'a', so a failing suffix forces the engine to revisit both choices on every repetition.

    Clean pattern with linear evidence

    Input
    ^[a-z]+$
    Output
    LOW · zero findings · sweep slope ≈ 1

    The generated probe is repeated letters plus a non-matching terminator; the measured curve stays near linear for that probe.

    About this tool

    ReDoS Vulnerability Checker analyses the regex itself, not a sample match. A dependency-free parser builds an AST with exact source offsets, propagates character sets through literals, classes, escapes, groups and alternations, and flags the shapes that make backtracking engines do exponential or high-degree polynomial work. Every finding points at its span in the pattern and carries a concrete fix.

    Static evidence can be paired with a guarded dynamic sweep. The tool synthesises an adversarial input from the computed character sets, then times increasing input lengths inside a Web Worker with a 300 ms budget per run. A run that breaches the budget kills the worker and stops the sweep; the classification fits a log-log curve instead of assuming the sweep lengths double, so a linear pattern is not mistaken for an exponential one. Everything runs locally and reports are advisory, not proof of formal safety.

    What this tool does not do

    • Static detectors cover common JavaScript backtracking shapes, not every possible engine pathology; exotic syntax is reported as a coverage note.
    • Unicode property escapes use approximate range tables and are flagged as such; verify exact membership for unusual properties.
    • Lookarounds and backreferences are approximated conservatively; their internal backtracking is not modelled exactly.
    • Timings depend on the browser engine, device load and the generated probe; they are comparative evidence, not a benchmark.
    • Batch mode is static only, and patterns are capped at 10 kB each with 100 lines per batch.

    How to use this tool

    1. Paste a pattern

      Enter a JavaScript regular expression, optionally with flags, or load one of the gallery examples.

    2. Read the highlighted spans

      Risk spans are colour-coded over the pattern; click one to focus the matching finding and its rewrite hint.

    3. Run the timing sweep

      Optionally enable Auto sweep for HIGH findings or press Run timing sweep. Each length runs in a killable worker.

    4. Export or batch

      Copy the JSON report for CI logs, or switch to Batch to scan up to 100 patterns statically at once.

    Use cases

    Review a validator

    Check a user-supplied or copied regex before it reaches a request path that accepts long strings.

    Audit a pattern library

    Paste many patterns in Batch mode to rank them by severity before deep-diving into the risky ones.

    Document a fix

    Copy the JSON report and the suggested rewrite into a code-review comment or CI artefact.

    Detector rules

    RuleWhat it flags
    nested-quantifierAn outer repetition (including bounded ranges) around an inner quantifier with overlapping characters — HIGH.
    adjacent-quantifiersTwo consecutive repetitions over overlapping sets such as a*a* — MEDIUM, usually quadratic.
    alternation-prefixAlternation branches with a common first character inside a repetition — MEDIUM.
    dot-star-suffixTwo unbounded .* quantifiers followed by the same token — MEDIUM, polynomial.
    optional-ambiguity / backref-ambiguityOptional or backreferenced parts inside a repeated group — MEDIUM.

    Findings that share an exact span are deduplicated with the highest severity; LOW means a construct needs manual review, not that it is safe.

    Common mistakes

    Mistake:Treating a LOW verdict as a formal safety proof.

    Fix:The verdict only covers the detected shapes and one probe on this engine. Use a DFA-based engine such as RE2 for untrusted patterns.

    Mistake:Reading a budget kill as exponential growth.

    Fix:A kill means the run stalled on this device; slow hardware or a high constant can kill a linear regex. The report labels it as a stall.

    Mistake:Applying a rewrite without testing semantics.

    Fix:The mechanical rewrite only covers simple single-token bodies; capturing groups, backreferences and anchors can change meaning.

    Frequently asked questions

    What is catastrophic backtracking?

    JavaScript's RegExp engine explores alternatives when a match fails. If several ways to consume the same text exist — for example the outer and inner stars in (a+)+ — the number of retries can grow exponentially with input length. A single failed validation of a few thousand characters can then block the thread for a very long time.

    How reliable is static detection?

    The detectors flag well-known risky shapes with exact spans: nested or adjacent quantifiers, alternations with shared prefixes, repeated dot-stars and ambiguous optional or backreferenced groups. They are intentionally conservative, so a flag is a prompt to inspect, not a proof of exploitability. The optional timing sweep is the tiebreaker for patterns that can actually be exercised.

    Why does my safe-looking regex get flagged?

    Anchors and validators do not remove ambiguity: ^([a-zA-Z]+)*$ still fails on a long letter run followed by '!' and can retry many partitions. Lookarounds, backreferences and unfamiliar Unicode properties also produce conservative notes because character sets cannot model them exactly.

    What fixes a vulnerable pattern?

    Merge nested quantifiers into one, replace overlapping alternations with a character class or a factored prefix, bound repetitions tightly, and cap the length of untrusted input. Where possible, evaluate untrusted patterns in a linear-time engine such as RE2. JavaScript does not portably support possessive quantifiers or atomic groups, so use lookahead-based rewrites instead.

    Does this prove a regex is safe?

    No. A LOW verdict means no known risky shape was found and, if you ran it, the generated probe produced a near-linear curve on this browser engine. Formal safety requires DFA-based analysis, and other inputs or engines can behave differently. The JSON report records the evidence so you can review the limits of the verdict.

    References & standards