ajtazer/heckit / skills/cve-hunting/redos
redos
VerifiedDetect Regular Expression Denial of Service (ReDoS) where crafted input causes catastrophic backtracking in regex patterns applied to user-controlled strings.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.0 KB |
| references/false-positive-indicators.md | markdown | 3.0 KB |
| references/poc-skeleton.md | markdown | 5.6 KB |
| references/sinks.md | markdown | 3.5 KB |
references/false-positive-indicators.md
View on GitHub# False Positive Indicators -- ReDoS
### 1. Uses RE2 or Linear-Time Engine
Go `regexp` (stdlib), Rust `regex` crate, Google RE2, or `re2` Python bindings all guarantee linear-time matching. Cannot have catastrophic backtracking. Verify actual engine used -- some Go projects import PCRE via CGo.
### 2. Measured Growth Rate is Linear
**This is the most important check.** A regex can LOOK dangerous (nested quantifiers, overlapping classes) but behave linearly in practice due to:
- Engine optimizations (some V8 patterns are optimized)
- Anchoring that prevents backtracking paths
- Character class mutual exclusion (looks overlapping but isn't)
Always measure: if time does NOT grow exponentially with input length, it is NOT ReDoS regardless of pattern structure.
### 3. Input Length is Bounded
If user input is truncated to < 100 characters before reaching the regex, exponential backtracking cannot produce meaningful delay. Check for:
- `maxLength` attribute on form fields (client-side only -- insufficient)
- Server-side `.slice(0, N)` or `.substring(0, N)` before regex
- Database column length constraints (only if validated before regex)
- Framework-level body size limits (usually too large to prevent ReDoS)
### 4. Regex Has Timeout or Circuit Breaker
- Ruby 3.2+: `Regexp.timeout = 1.0` (global) or `Regexp.new(pattern, timeout: 1.0)`
- PHP: `pcre.backtrack_limit` (default 1,000,000 -- partial protection)
- Java: `Thread.interrupt()` pattern (rare but exists)
- Custom: some libraries wrap regex in `setTimeout`/worker with kill
### 5. Atomic Groups or Possessive Quantifiers
Patterns using `(?>...)` (atomic group) or `a++` / `a*+` (possessive quantifiers) explicitly prevent backtracking in those subexpressions. These constructs are only available in PCRE-compatible engines (not JavaScript).
### 6. Regex Applied to Internal Data Only
The regex is only applied to trusted strings generated by the application itself, not user input. Trace the data flow -- if input originates from a database row that was previously validated, or from a hardcoded constant, it's not user-controlled.
### 7. Polynomial (Not Exponential) on Small Input
Quadratic `O(N^2)` or cubic `O(N^3)` growth is only exploitable with large input (>10KB). If the endpoint has a reasonable body size limit or the field is naturally short (e.g., username, email), polynomial ReDoS may not be practically exploitable. Still reportable as MEDIUM if input can be large.
### 8. Runs in Worker Thread or Child Process
If the regex runs in a Web Worker, worker thread, or child process, a hang only affects that worker, not the main event loop. Impact is reduced (DoS of one worker vs. full server hang). Still reportable but lower severity.
### 9. Pattern is Anchored with Mutual Exclusion
A pattern like `^[a-z]+[0-9]+$` has two groups with NON-overlapping character classes. Even though both are quantified, the engine cannot split input between them ambiguously -- each character belongs to exactly one group. This prevents backtracking explosion.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |