Aller au contenu
Skillpedia
Sécurité6.5k · #13968

redos

Ce qu’il fait

Cette skill explique le ReDoS, un déni de service où une expression régulière met très longtemps à traiter une chaîne construite spécialement. Elle s'adresse aux développeurs et aux testeurs qui vérifient la vitesse et la sûreté de leur propre code.

Quand l’utiliser

  • ✓Quand un développeur demande à l'agent de trouver des expressions régulières qui pourraient ralentir fortement avec une entrée forgée.
  • ✓Quand l'agent vérifie quels moteurs d'expressions régulières du projet peuvent être touchés, car certains ne le sont pas.
  • ✓Quand un rapport doit montrer un résultat de mesure de temps qui prouve le ralentissement.

Lien du skill

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

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/redos/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Pouvez-vous vérifier dans notre code autorisé les expressions régulières qui pourraient figer le serveur lorsqu'elles reçoivent une longue entrée forgée ?”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'agent cherche les appels d'expressions régulières, repère ceux qui ont des répétitions imbriquées, suit l'entrée utilisateur jusqu'à eux, et mesure le temps de réponse sur une copie de test.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis 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

Questions fréquentes

Qu'est-ce que le ReDoS ?

C'est un ralentissement causé par une expression régulière qui met beaucoup plus de temps sur certaines entrées, ce qui peut bloquer un serveur.

Tous les moteurs d'expressions régulières sont-ils touchés ?

Non. La skill indique que des moteurs comme RE2 et le regexp de Go ne reviennent pas en arrière, donc ils ne sont pas touchés de cette façon.

Comment le confirmer ?

La skill demande un test de temps qui montre une hausse nette du temps de réponse par rapport à une entrée normale.

Détails

Description originale de l’auteur

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

Popularité

Étoiles GitHub
6.5k
Position au classement
#13968
Licence
Apache-2.0
Mis à jour
01/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires