Skip to content
Skillpedia
Security6.5k Β· #13968

redos

What it does

This skill explains ReDoS, a denial of service where a regex takes a very long time on a specially built string. It is for developers and testers who check the speed and safety of their own code.

When to use it

  • βœ“When a developer asks the agent to find regular expressions that could slow down badly on a crafted input.
  • βœ“When the agent checks which regex engines in the project can be affected, since some engines are not affected.
  • βœ“When a report must show a timing result that proves the slowdown.

Skill link

https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/redos/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/redos/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

Example of what to ask your AI

β€œCan you check our authorized code for regular expressions that could freeze the server when given a long crafted input?”

5 new skills a week. 1 minute to read.

How it works

The agent searches for regex calls, finds the ones with nested repeats, traces user input to them, and measures the response time on a test copy.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

ReDoS Hunting Playbook

Regular Expression Denial of Service exploits O(2^n) or O(n^2) matching time in backtracking engines. One crafted string can peg a CPU thread for seconds or minutes against an otherwise tiny pattern.

1. Identify Backtracking Engines in Scope

Not all regex engines backtrack:

Engine Language/Runtime Backtracks? Vulnerable?
PCRE / PCRE2 C, PHP, Apache, nginx Yes YES
re module Python (pre-3.11 re, regex) Yes YES
java.util.regex Java Yes YES
RegExp JavaScript / V8 Yes YES
System.Text.RegularExpressions .NET Yes (w/ timeout option) YES
regexp package Go DFA-based (RE2) NO
Oniguruma Ruby Yes YES
RE2 C++, re2 Python binding DFA-based NO

If the target uses RE2 or Go's regexp, skip this playbook β€” no backtracking, no ReDoS.

2. Source Patterns β€” Where Tainted Input Reaches Regex

# Python
grep -rn 're\.match\|re\.search\|re\.fullmatch\|re\.compile\|regex\.match' /workspace/src \
  | grep -v '#' | grep -v 'test_' | grep -v '_test\.py'

# Node.js / TypeScript
grep -rn 'new RegExp\|\.match(\|\.search(\|\.test(' /workspace/src \
  --include='*.js' --include='*.ts' | grep -v 'node_modules'

# Java
grep -rn 'Pattern\.compile\|\.matches(\|\.find(\|String\.matches' /workspace/src \
  --include='*.java'

# PHP
grep -rn 'preg_match\|preg_replace\|preg_split' /workspace/src --include='*.php'

# Ruby
grep -rn 'match\|=~\|Regexp\.new\|\.scan(' /workspace/src --include='*.rb' \
  | grep -v '#'

# Semgrep for tainted-input-to-regex-sink
semgrep --config p/regex /workspace/src --sarif -o /workspace/sem-redos.sarif 2>/dev/null

For each hit, determine whether the regex pattern is:

  • Static (hardcoded string literal) β†’ scan the pattern itself
  • Dynamic (constructed from user input) β†’ separate vuln class (regex injection); flag it and continue

3. Catastrophic Pattern Recognition

A regex is potentially catastrophic if it can match the same character through multiple paths. The two canonical forms:

Form 1: Nested quantifiers

(a+)+, (a*)*, ([a-z]+)+, (a|a)+

The inner group can match one character in multiple ways β†’ exponential backtracking on a string like aaaa...b.

Form 2: Overlapping alternation

(a|aa)+, (a|ab)+c, (x+|y+)+z

Two branches can match the same prefix β†’ exponential when neither eventually matches the suffix.

Quick pattern scanner

# Find potentially catastrophic regexes (grep heuristic)
grep -rn "$(printf \
  '(\([^)]*[+*][^)]*\)[+*])\|(\([^)]*|\[^)]*\)[+*])\|(\([^)]*[+*]\)\{[2-9]\})')" \
  /workspace/src 2>/dev/null | grep -v 'node_modules\|\.min\.js'

# Better: use vuln-regex-detector (if available)
python3 -c "
import subprocess, json, os, sys
# Try to find all regex literals in Python files
import ast, glob
for path in glob.glob('/workspace/src/**/*.py', recursive=True):
    try:
        tree = ast.parse(open(path).read())
        for node in ast.walk(tree):
            if isinstance(node, ast.Call):
                fn = getattr(node.func, 'attr', '') or getattr(node.func, 'id', '')
                if fn in ('compile','match','search','fullmatch'):
                    for arg in node.args:
                        if isinstance(arg, ast.Constant) and isinstance(arg.value, str):
                            print(path, node.lineno, repr(arg.value))
    except Exception:
        pass
" 2>/dev/null | head -50

Patterns warranting deeper analysis (flag these):

  • Any group with a quantifier inside a quantifier: (X+)+, (X*)+, (X+)*
  • Alternation where branches share a prefix: (ab|a)+, (abc|ab)+
  • Long character classes under a star inside a group under a star: ([a-z ]+)+

4. Taint Heuristics β€” Is This Reachable?

For each flagged regex, trace whether attacker-controlled data reaches the pattern, the string argument, or both:

  1. string tainted, pattern static β†’ ReDoS possible if pattern is vulnerable
  2. pattern tainted β†’ also check for Regex Injection (attacker adds their own quantifiers β†’ instant ReDoS)
  3. Both tainted β†’ highest risk

For web endpoints, check:

  • URL path / query param β†’ regex for routing or validation
  • HTTP body field β†’ input validation regex
  • Header (User-Agent, Content-Type) β†’ server-side validation

5. Timing PoC Construction

A valid PoC must demonstrate measurable time difference between a benign and a malicious input

FAQ

What is ReDoS?

It is a slowdown caused by a regular expression that takes far longer on certain inputs, which can tie up a server.

Are all regex engines affected?

No. The skill says engines such as RE2 and Go's regexp do not backtrack, so they are not affected in this way.

How is it confirmed?

The skill asks for a timing test that shows a clear rise in response time compared with a normal input.

Details

Original description by the author

Hunt ReDoS (CWE-1333, Catastrophic Backtracking) β€” identify regexes with nested quantifiers or overlapping alternation that cause super-linear matching time, trace tainted input paths to regex sinks, demonstrate timing PoC, and validate with response-time delta. Covers PCRE/RE2/V8/Python re engine differences. Triggers on: 'ReDoS', 'regex denial', 'catastrophic backtracking', 'redos', 'regex complexity', 'nested quantifiers', 'regex amplification', 'CWE-1333'.

repo: BitterSecurity/Decepticon

Popularity

GitHub stars
6.5k
Ranking position
#13968
License
Apache-2.0
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills