Regex denial of service (ReDoS): one crafted input that freezes your app

Last updated November 11, 2026
Steps
- Search your code for regexes used on user input: new RegExp(, .test(, .match(, .replace( and validation libraries' custom patterns, on both the server and in API routes.
- Look for the risky shape OWASP calls an "evil regex": a group with repetition that contains repetition or overlapping alternatives, such as (a+)+, ([a-zA-Z]+)* or (a|aa)+.
- Never build a regex from user input. If users need to search, escape their text or use plain string methods like includes() instead.
- Limit input length before any regex runs. An email field doesn't need 10,000 characters.
- Rewrite risky patterns without nested quantifiers, or use a well-tested validation library instead of a hand-made pattern.
- Where possible, use a regex engine without backtracking (for example RE2-based libraries) for untrusted input, or set backtracking or time limits in your runtime.
- Add rate limiting so one client can't send these inputs over and over, and keep dependencies updated, since ReDoS bugs are often fixed in library releases.
Why it matters
MITRE tracks this as CWE-1333 (Inefficient Regular Expression Complexity): a regular expression whose worst-case complexity is inefficient and possibly exponential. MITRE lists the impact as denial of service through CPU consumption, with high likelihood, because attackers can craft inputs that cause excessive backtracking. Its mitigations are to use regexes that don't backtrack (for example by removing nested quantifiers), set backtracking limits, avoid running regexes on untrusted input, and limit input length. OWASP's ReDoS page explains that most regex engines try every possible path when a match fails, gives examples like ^(a+)+$ where each extra character doubles the work, and warns that if a regex itself is built from user input, an attacker can inject an evil pattern.
Sources
MITRE CWE-1333: Inefficient Regular Expression Complexity — https://cwe.mitre.org/data/definitions/1333.html
OWASP: Regular expression Denial of Service - ReDoS — https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
Checked at the source on November 2, 2026.
Related patterns
- No rate limiting on login, signup or AI endpoints
- Running AI or user output with eval, exec or new Function (code injection)
- Outdated packages with known vulnerabilities
- XML parsers that resolve external entities (XXE)
- NoSQL operator injection: login and search filters built from raw JSON
- GraphQL APIs with introspection on and no depth or cost limits
Found a problem you'd rather not fix yourself?
Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.
Get it fixed by StorenTechVibe Security Weekly
One email a week with new failure patterns and how to fix them.
By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.