redos
यह क्या करती है
यह स्किल ReDoS समझाती है, एक सेवा-बाधा जिसमें कोई रेगुलर एक्सप्रेशन विशेष रूप से बनाए गए स्ट्रिंग पर बहुत लंबा समय लेता है। यह उन डेवलपर्स और परीक्षकों के लिए है जो अपने कोड की गति और सुरक्षा जाँचते हैं।
कब इस्तेमाल करें
- ✓जब डेवलपर पूछता है कि कौन-से रेगुलर एक्सप्रेशन गढ़े हुए इनपुट पर बहुत धीमे हो सकते हैं।
- ✓जब एजेंट जाँचता है कि प्रोजेक्ट के कौन-से रेगुलर एक्सप्रेशन इंजन प्रभावित हो सकते हैं, क्योंकि कुछ इंजन प्रभावित नहीं होते।
- ✓जब रिपोर्ट में समय का ऐसा परिणाम दिखाना हो जो धीमेपन को साबित करे।
Skill का लिंक
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/analyst/redos/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“क्या आप हमारे अधिकृत कोड में ऐसे रेगुलर एक्सप्रेशन जाँच सकते हैं जो लंबे गढ़े हुए इनपुट मिलने पर सर्वर को जाम कर सकते हैं?”
हर हफ़्ते 5 नई skills, 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
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
detector-overview
6.5kयह आपके एजेंट को स्कैनर से चिह्नित कोड पढ़ने और तय करने में मदद करती है कि कौन सी जगहें असली सुरक्षा बग हैं और कौन सी गलत चेतावनी।
exploiter-overview
6.5kयह आपके एजेंट को कई पक्की सुरक्षा कमज़ोरियों को एक परीक्षण श्रृंखला में जोड़ने और जाँचने में मदद करती है कि वह श्रृंखला कितनी दूर तक पहुँच सकती है।
llm-redteam-overview
6.5kयह आपके एजेंट को परीक्षण के लिए सही AI रेड-टीम गाइड खोजने में मदद करती है, प्रॉम्प्ट इंजेक्शन से लेकर मॉडल के दुरुपयोग तक 15 रणनीति समूहों में।
aatmf-t01-prompt-injection
6.5kसमझाती है कि प्रॉम्प्ट इंजेक्शन क्या है, जिसमें छिपे निर्देश AI सिस्टम के नियम बदलने की कोशिश करते हैं, ताकि सुरक्षा परीक्षक उसकी जाँच कर सकें।
मिलती-जुलती skills
reverse-engineer-anything
422kयह आपके एजेंट को REA टूल से शिप हुई ऐप्स और पैकेज को अंदर से समझने, वर्ज़न की तुलना करने या दोबारा बनाने में मदद करती है।
1password
394kयह आपके एजेंट को 1Password CLI सेट करने, साइन इन करने और सीक्रेट्स की वैल्यू चैट में छापे बिना उन्हें पढ़ने या इस्तेमाल करने में मदद करती है।
healthcheck
394kयह आपके एजेंट को उस कंप्यूटर या सर्वर का सुरक्षा ऑडिट करने देती है जिस पर OpenClaw चलता है, जिसमें SSH, firewall, अपडेट और बैकअप शामिल हैं, और फिर सुरक्षित सुधार सुझाती है।