ReDoS Checker: Static Scan for Catastrophic Backtracking

Looks at the structure of a regex and flags shapes that are known to backtrack badly, with a suggestion for a test string and a fix.

Use the tool

Why this tool exists

Some regexes take exponential time on input that almost matches. A web server running one of them can be frozen by a single request, which is called ReDoS. The risky shapes are well known: a repeated group that ends in a repeat, alternatives that start with the same character inside a loop, and two repeats side by side that match the same characters.

This tool parses the pattern and checks for those shapes using sampled character sets. It is a heuristic. It can miss risky patterns, especially with backreferences or lookarounds, and it can flag safe ones, so every finding is a review item. Confirm with a timing test on your own engine.

How to use it

  1. Paste one or more regexes, one per line.
  2. Read each finding and the part of the pattern it points to.
  3. Try the suggested test string in the regex benchmark tool to confirm.
  4. Rewrite the pattern so the parts cannot match the same text.

Frequently asked questions

Does "no known risky shape" mean the regex is safe?

No. It only means none of the shapes this tool knows about were found. Treat it as a first filter.

Which engines are affected?

Backtracking engines such as JavaScript, Python, Java, PHP and .NET. Engines with linear-time matching, such as RE2, are not.

How do I fix a flagged pattern?

Make alternatives exclusive, remove the inner repeat, place a delimiter between repeats, limit lengths, or use a linear-time engine.

Does it run the regex?

No. It only analyses the pattern, so it cannot hang. The benchmark tool can time a pattern against real input.