redos
하는 일
이 스킬은 특별히 만든 문자열에서 정규 표현식이 매우 오래 걸리는 서비스 거부 공격인 ReDoS를 설명합니다. 자신의 코드의 속도와 안전성을 점검하는 개발자와 테스터를 위한 스킬입니다.
사용하는 경우
- ✓개발자가 조작된 입력에 대해 심하게 느려질 수 있는 정규 표현식을 찾아 달라고 요청할 때.
- ✓에이전트가 프로젝트에서 어떤 정규 표현식 엔진이 영향을 받는지 확인할 때.
- ✓보고서에 속도 저하를 증명하는 시간 측정 결과를 보여 줘야 하는 경우.
스킬 링크
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/redos/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“우리 허가된 코드에서 길고 조작된 입력을 받으면 서버를 멈출 수 있는 정규 표현식이 있는지 확인해 주시겠어요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 정규 표현식 호출을 찾고, 중첩 반복이 있는 것을 고르고, 사용자 입력이 그곳까지 가는지 추적한 뒤, 테스트 복사본에서 응답 시간을 측정합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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:
stringtainted,patternstatic → ReDoS possible if pattern is vulnerablepatterntainted → also check for Regex Injection (attacker adds their own quantifiers → instant ReDoS)- 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
자주 묻는 질문
ReDoS란 무엇인가요?
정규 표현식이 특정 입력에서 훨씬 오래 걸려 서버를 묶어 둘 수 있는 속도 저하입니다.
모든 정규 표현식 엔진이 영향을 받나요?
아닙니다. 스킬은 RE2나 Go의 regexp 같은 엔진은 백트래킹을 하지 않아 이런 방식으로 영향을 받지 않는다고 설명합니다.
이것은 어떻게 확인하나요?
정상 입력과 비교해 응답 시간이 뚜렷하게 늘어나는 것을 보여 주는 시간 테스트를 요구합니다.
상세 정보
작성자의 원본 설명
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'.
인기도
- GitHub 스타
- 6.5k
- 순위
- #13968
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
detector-overview
6.5k에이전트가 스캐너가 표시한 코드를 읽고, 표시된 곳 중 어디가 실제 보안 버그이고 어디가 오탐인지 판단하도록 돕습니다.
exploiter-overview
6.5k에이전트가 확인된 여러 보안 약점을 하나의 테스트 체인으로 묶고, 그 체인이 어디까지 닿을 수 있는지 확인하도록 돕습니다.
llm-redteam-overview
6.5k에이전트가 프롬프트 인젝션부터 모델 악용까지 15개 전술 그룹 중 테스트에 맞는 AI 레드팀 가이드를 찾도록 돕습니다.
aatmf-t01-prompt-injection
6.5k숨겨진 지시가 AI 시스템을 덮어쓰려 하는 프롬프트 인젝션을 설명해, 보안 테스터가 이를 점검할 수 있게 합니다.