Check regular expressions for ReDoS (catastrophic backtracking)
sieve_check_redosUse when a regular expression will run on user input or untrusted data (form validation, request routing, log parsing, WAF or search rules) and must not hang the server, or when reviewing a codebase's regexes for ReDoS (signals: "is this regex safe", "ReDoS", "catastrophic backtracking", "regex hangs", "CPU spike on validation", "security review of regexes", "(a+)+"). Analyzes 1 to 20 patterns with recheck (automaton analysis with a fuzzing fallback) for backtracking engines with JavaScript syntax, and returns per pattern: safe (proven linear, or no attack found when backreferences or lookarounds force fuzzing), or vulnerable with the complexity (exponential, or polynomial with its degree), a concrete attack string (repr like 'a'.repeat(31) + '\x00', plus the string itself when short), the hot part of the pattern and a fix hint. Example: {"patterns":["^(a+)+$","/^([a-z]+\s)*$/","^[\w.+-]+@[\w-]+\.[\w.-]+$"]}. Python re, PCRE, Java, .NET and Ruby backtrack the same way on these constructs; RE2, Go regexp and Rust regex are linear-time and not affected. To also run the pattern on test strings, use sieve_test_regex.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"patterns": "<patterns>"
},
"name": "sieve_check_redos"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| flags | No | Flags for every pattern given as a raw source (literals keep their own). JavaScript flags d g i m s u v y. | |
| patterns | Yes | Regex sources ("^(a+)+$") or JavaScript literals ("/^(a+)+$/i"). |