redos
Skill2 starsChanged 2 months agoMITView on GitHub
Detect Regular Expression Denial of Service (ReDoS) where crafted input causes catastrophic backtracking in regex patterns applied to user-controlled strings.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- thejefflarson/soundchecktheir own version, first seen Jul 31, 2026
- KaanBicaklar/mona-sast-skillstheir own version, first seen Jul 9, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- thejefflarson/soundcheck★ 20same name
- KaanBicaklar/mona-sast-skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository255 other files it gives its agents.
- ad-acl-abuseSkill
- ad-adcs-access-and-relaySkill
- ad-adcs-persistenceSkill
- ad-adcs-template-abuseSkill
- ad-ad-discoverySkill
- ad-ad-persistenceSkill
- ad-auth-coercion-relaySkill
- ad-credential-dumpingSkill
- ad-gpo-abuseSkill
- ad-kerberos-delegationSkill
- ad-kerberos-roastingSkill
- ad-kerberos-ticket-forgingSkill
- ad-pass-the-hashSkill
- ad-sccm-exploitationSkill
- ad-trust-attacksSkill
- hunt-ntlm-infoSkill
- offensive-active-directorySkill
- hunt-llm-aiSkill
- hunt-rag-vectorSkill
- offensive-ai-securitySkill
- cloud-iam-deepSkill
- hunt-cloud-misconfigSkill
- hunt-k8sSkill
- m365-entra-attackSkill
- network-container-escapesSkill
- offensive-cloudSkill
- offensive-container-escapeSkill
- offensive-k8s-attacksSkill
- okta-attackSkill
- vmware-vcenter-attackSkill
- credential-password-sprayingSkill
- hunt-brute-forceSkill
- hunt-forgot-passwordSkill
- post-exploit-credential-recoverySkill
- meme-coin-auditSkill
- offensive-crypto-attacksSkill
- web3-auditSkill
- ctfSkill
- advisory-miningSkill
- auth-bypassSkill
- code-injection-codegenSkill
- command-injectionSkill
- cross-pollinationSkill
- cve-hunting-methodologySkill
- decompression-bombSkill
- entity-expansionSkill
- fp-checkSkill
- method-clobberingSkill
- path-traversalSkill
- prototype-pollutionSkill
- recursion-dosSkill
- sandbox-escapeSkill
- target-reconSkill
- web2-vuln-classesSkill
- evasion-av-edr-evasionSkill
- offensive-anti-forensicsSkill
- offensive-edr-evasionSkill
- offensive-keylogger-archSkill
- offensive-mitigationsSkill
- offensive-waf-bypassSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
MUST measure actual backtracking growth rate: Do not report based on pattern structure alone.
- Distinctive: line 100
Look for these red flags:
- Very specific: line 175
Check ini_get('pcre.backtrack_limit') -- if lowered, may limit impact.
- Very specific: line 179
No built-in timeout in Pattern.compile().
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
ReDoS Detection
When to Use
Audit input validation libraries, URL/email/date parsers, sanitization utilities, template engines, and any package that applies regular expressions to user-controlled strings.
Critical Rule
MUST measure actual backtracking growth rate. Do not report based on pattern structure alone. The validator.js lesson: assumed ReDoS from pattern complexity but could not confirm exponential growth. Always TIME IT.
Vulnerable Regex Patterns
Nested Quantifiers (Most Common)
(a+)+$ # Nested plus -- classic ReDoS
(a*)*$ # Nested star
(a+)*$ # Star of plus
(a*)+$ # Plus of star
(a{1,}){1,}$ # Nested bounded quantifiersOverlapping Alternation
(a|a)+$ # Identical alternatives
(a|ab)+$ # Prefix overlap
(a|b|ab)+$ # Partial overlap
(\w|\d)+$ # \d is subset of \w -- overlapQuantified Groups with Optional Elements
(a+b?)+$ # Optional between repeated groups
(\s*,\s*)+$ # Common in CSV/list parsing
([^"]*"[^"]*")*[^"]*$ # Quote matchingDangerous Real-World Patterns
^([a-zA-Z0-9])(([\-.]|[_]+)?([a-zA-Z0-9]+))*$ # Email local part
^((https?|ftp):\/\/)?([\w.-]+)\.([a-z.]{2,6}).*$ # URL validation
^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$ # IP (safe but often combined)Evil String Construction
| Pattern | Evil String | Growth |
(a+)+$ | "a" * N + "!" | O(2^N) |
(a+b?)+$ | "a" * N + "!" | O(2^N) |
(a|aa)+$ | "a" * N + "!" | O(2^N) |
([a-zA-Z]+)*$ | "a" * N + "1" | O(2^N) |
(\s+$) | " " * N + "x" | O(N^2) quadratic |
(.*a){10}$ | "a" * N + "!" | O(N^10) polynomial |
Key insight: The evil string is N copies of a character the pattern CAN match, followed by one character it CANNOT. This forces the engine to try every possible split of the N characters across the quantifiers.
Process
Step 1: Find Regex Usage
# JavaScript/TypeScript
grep -rn "new RegExp\|RegExp(" . --include="*.js" --include="*.ts"
grep -rn "\.match(\|\.test(\|\.replace(\|\.search(\|\.split(" . --include="*.js" --include="*.ts"
grep -rn "/[^/]*[+*][^/]*[+*][^/]*/" . --include="*.js" --include="*.ts"
# Python
grep -rn "re\.compile\|re\.match\|re\.search\|re\.findall\|re\.sub" . --include="*.py"
grep -rn "re\.DOTALL\|re\.MULTILINE\|re\.VERBOSE" . --include="*.py"
# Ruby
grep -rn "Regexp\.new\|=~\|\.match\|\.scan\|\.gsub" . --include="*.rb"
# PHP
grep -rn "preg_match\|preg_replace\|preg_split" . --include="*.php"
# Java
grep -rn "Pattern\.compile\|\.matches(\|\.replaceAll(" . --include="*.java"Step 2: Identify Potentially Vulnerable Patterns
Look for these red flags:
- Nested quantifiers:
(X+)+,(X*)*,(X+)*,(X*)+ - Overlapping alternation:
(a|a)+,(a|ab)+ - Quantified group with internal repetition:
(\s*,\s*)+ - Unbounded repetition with anchor failure: Pattern ends with
$and input doesn't match - User-controlled regex:
new RegExp(userInput)-- always exploitable
Step 3: Mandatory Timing Measurement
// Node.js timing test -- REQUIRED before reporting
const regex = /VULNERABLE_PATTERN/;
console.log('Length | Time (ms) | Ratio');
let prevTime = 0;
for (let len = 15; len <= 35; len++) {
const evil = 'a'.repeat(len) + '!';
const start = performance.now();
regex.test(evil);
const elapsed = performance.now() - start;
const ratio = prevTime > 0 ? (elapsed / prevTime).toFixed(1) : '-';
console.log(`${String(len).padStart(6)} | ${elapsed.toFixed(2).padStart(9)} | ${ratio}`);
prevTime = elapsed;
}Interpretation:
- Ratio ~2.0 per character = exponential (O(2^N)) = CONFIRMED ReDoS
- Ratio ~1.0 but time grows = likely polynomial = needs larger input test
- Ratio ~1.0 and time flat = linear = NOT ReDoS
Step 4: Classify Severity
| Growth Rate | Ratio Pattern | Input for 1s Hang | Severity |
| O(2^N) exponential | ~2x per char | 25-30 chars | HIGH 7.5 |
| O(N^3+) polynomial | grows with input | 10K-100K chars | MEDIUM 5.3-6.5 |
| O(N^2) quadratic | grows slowly | 100K+ chars | LOW-MEDIUM |
| O(N) linear | constant ratio | never | NOT ReDoS |
Step 5: Verify User Input Reaches Regex
The regex MUST be applied to user-controlled input. Check the full call chain:
- Where does input enter? (HTTP param, form field, file content)
- Is input truncated before regex? (length limit < 100 chars = likely safe)
- Is there a regex timeout? (some libraries implement circuit breakers)
- Is the regex applied in a worker/child process? (reduces impact to DoS of worker only)
Language-Specific Notes
JavaScript (V8 Engine)
- No built-in regex timeout. Catastrophic backtracking freezes the entire event loop.
- Single-threaded: one ReDoS hangs ALL request processing.
String.prototype.matchAll()is lazy but still backtracks.- V8 does NOT use RE2 for regex. All JS regex uses backtracking.
Python
- GIL blocks all threads. ReDoS in one thread freezes the entire process.
remodule uses backtracking. No built-in timeout.re2package (Google RE2 bindings) is safe but rarely used.- Python 3.11+ has some regex optimizations but is still vulnerable.
Go
- Uses RE2 engine. Guarantees linear-time matching. NOT vulnerable to ReDoS.
- Exception: CGo bindings to PCRE (rare) ARE vulnerable.
- Skip Go targets unless they use PCRE bindings.
Ruby
- Uses Oniguruma engine (backtracking). Vulnerable to ReDoS.
- Ruby 3.2+ added
Regexp.timeout=global setting -- check if configured. Regexp.timeoutdefaults to nil (no timeout) unless explicitly set.
PHP
- Uses PCRE (backtracking). Vulnerable to ReDoS.
pcre.backtrack_limitdefaults to 1,000,000 -- provides some protection.- Check
ini_get('pcre.backtrack_limit')-- if lowered, may limit impact.
Java
- Uses backtracking engine. Vulnerable to ReDoS.
- No built-in timeout in
Pattern.compile(). - Can be mitigated with
Thread.interrupt()but rarely done.
CVSS Guidance
- Exponential backtracking, user input, event loop blocking: HIGH 7.5
- Exponential backtracking, authenticated only: MEDIUM 6.5
- Quadratic on user input requiring large payload (>10KB): MEDIUM 5.3
- Regex on bounded input (< 100 chars): usually not exploitable
- Regex with timeout/circuit breaker configured: reduced severity
- User-controlled regex pattern (
new RegExp(input)): HIGH 7.5 (always exploitable)
References
- Sinks -- Regex-heavy libraries and known vulnerable patterns
- False Positive Indicators
- PoC Skeleton
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

