Redos logo

Redos

Community
ByamB4
redos

Detect Regular Expression Denial of Service (ReDoS) where crafted input causes catastrophic backtracking in regex patterns applied to user-controlled strings.

Overview

PublisherByamB4
Repositoryfind-cve-agent
Skill nameredos
Stars
60
Forks
13
Bundled files
3
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by ByamB4 on GitHub. Read the source before you install it.

Installation

Install the Redos AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/ByamB4/find-cve-agent/tree/main/skills/redos
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ByamB4/find-cve-agent.git /tmp/find-cve-agent
mkdir -p .claude/skills
cp -r /tmp/find-cve-agent/skills/redos .claude/skills/redos
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Redos in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Redos on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Redos is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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 quantifiers

Overlapping Alternation

(a|a)+$         # Identical alternatives
(a|ab)+$        # Prefix overlap
(a|b|ab)+$      # Partial overlap
(\w|\d)+$       # \d is subset of \w -- overlap

Quantified Groups with Optional Elements

(a+b?)+$        # Optional between repeated groups
(\s*,\s*)+$     # Common in CSV/list parsing
([^"]*"[^"]*")*[^"]*$  # Quote matching

Dangerous 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

PatternEvil StringGrowth
(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:

  1. Nested quantifiers: (X+)+, (X*)*, (X+)*, (X*)+
  2. Overlapping alternation: (a|a)+, (a|ab)+
  3. Quantified group with internal repetition: (\s*,\s*)+
  4. Unbounded repetition with anchor failure: Pattern ends with $ and input doesn't match
  5. User-controlled regex: new RegExp(userInput) -- always exploitable

Step 3: Mandatory Timing Measurement

js
// 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 RateRatio PatternInput for 1s HangSeverity
O(2^N) exponential~2x per char25-30 charsHIGH 7.5
O(N^3+) polynomialgrows with input10K-100K charsMEDIUM 5.3-6.5
O(N^2) quadraticgrows slowly100K+ charsLOW-MEDIUM
O(N) linearconstant rationeverNOT ReDoS

Step 5: Verify User Input Reaches Regex

The regex MUST be applied to user-controlled input. Check the full call chain:

  1. Where does input enter? (HTTP param, form field, file content)
  2. Is input truncated before regex? (length limit < 100 chars = likely safe)
  3. Is there a regex timeout? (some libraries implement circuit breakers)
  4. 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.
  • re module uses backtracking. No built-in timeout.
  • re2 package (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.timeout defaults to nil (no timeout) unless explicitly set.

PHP

  • Uses PCRE (backtracking). Vulnerable to ReDoS.
  • pcre.backtrack_limit defaults 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

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Redos AI skill do?

Detect Regular Expression Denial of Service (ReDoS) where crafted input causes catastrophic backtracking in regex patterns applied to user-controlled strings.

Why use Redos on TypingMind?

Because you install it once and use it with any model. Redos is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Redos in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ByamB4/find-cve-agent/tree/main/skills/redos. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Redos?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Redos?

As many as you like. As long as a model supports skills, you can use Redos with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Redos AI skill free?

Yes. It is published on GitHub by ByamB4 under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇