---
title: "CWE-1333: Inefficient Regular Expression Complexity"
url: https://radicalnotion.ai/cwe/cwe-1333
type: cwe
description: "The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-1333: Inefficient Regular Expression Complexity

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **Likelihood of exploit:** High
- **CVEs with this as primary weakness:** 520
- **Of those, in CISA KEV:** 0
- **New in 2026:** 194
- **CWE catalog version:** 4.21

## Description

The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.

## Background

Some regular expression engines have a feature called "backtracking". If the token cannot match, the engine "backtracks" to a position that may result in a different token that can match.

## Alternate terms

- **ReDoS:** ReDoS is an abbreviation of "Regular expression Denial of Service".
- **Regular Expression Denial of Service:** While this term is attack-focused, this is commonly used to describe the weakness.
- **Catastrophic backtracking:** This term is used to describe the behavior of the regular expression as a negative technical impact.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | A RegEx can be easy to create and read using unbounded matching characters, but the programmer might not consider the risk of excessive backtracking. |
| Implementation | Backtracking becomes a weakness if all of these conditions are met: |

## Applicable platforms

**Languages:** Go (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability | DoS: Resource Consumption (CPU) | Attackers can create crafted inputs that intentionally cause the regular expression to use excessive backtracking in a way that causes the CPU consumption to spike. |

## Potential mitigations

### Architecture and Design

Use regular expressions that do not support backtracking, e.g. by removing nested quantifiers.

Effectiveness: High. This is one of the few effective solutions when using user-provided regular expressions.

### System Configuration

Set backtracking limits in the configuration of the regular expression implementation, such as PHP's pcre.backtrack\_limit. Also consider limits on execution time for the process.

Effectiveness: Moderate

### Implementation

Do not use regular expressions with untrusted input. If regular expressions must be used, avoid using backtracking in the expression.

Effectiveness: High

### Implementation

Limit the length of the input that the regular expression will process.

Effectiveness: Moderate

## Detection methods

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Effectiveness: High

## Demonstrative examples

### Example 1

This example attempts to check if an input string is a "sentence" \[REF-1164\].

Bad code:

```javascript
var test_string = "Bad characters: $@#";
var bad_pattern  = /^(\w+\s?)*$/i;
var result = test_string.search(bad_pattern);
```

Good code:

```javascript
var test_string = "Bad characters: $@#";
var good_pattern  = /^((?=(\w+))\2\s?)*$/i;
var result = test_string.search(good_pattern);
```

### Example 2

This example attempts to check if an input string is a "sentence" and is modified for Perl \[REF-1164\].

Bad code:

```perl
my $test_string = "Bad characters: \$\@\#";
my $bdrslt = $test_string;
$bdrslt =~ /^(\w+\s?)*$/i;
```

Good code:

```perl
my $test_string = "Bad characters: \$\@\#";
my $gdrslt = $test_string;
$gdrslt =~ /^((?=(\w+))\2\s?)*$/i;
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2020-5243 | server allows ReDOS with crafted User-Agent strings, due to overlapping capture groups that cause excessive backtracking. |
| CVE-2021-21317 | npm package for user-agent parser prone to ReDoS due to overlapping capture groups |
| CVE-2019-16215 | Markdown parser uses inefficient regex when processing a message, allowing users to cause CPU consumption and delay preventing processing of other messages. |
| CVE-2019-6785 | Long string in a version control product allows DoS due to an inefficient regex. |
| CVE-2019-12041 | Javascript code allows ReDoS via a long string due to excessive backtracking. |
| CVE-2015-8315 | ReDoS when parsing time. |
| CVE-2015-8854 | ReDoS when parsing documents. |
| CVE-2017-16021 | ReDoS when validating URL. |

## Real CVEs with this weakness (sample of 12 of 520)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-82617 | Apache OpenNLP, Apache OpenNLP: ReDoS / stack exhaustion in RegexNameFinderFactory built-in EMAIL and URL patterns | critical | 10.0 | - | No | 2026-09-11 |
| CVE-2025-62484 | Zoom Workplace Clients - Inefficient Regular Expression Complexity | critical | 9.8 | - | No | 2025-11-13 |
| CVE-2023-29486 | - | critical | 9.8 | - | No | 2023-12-21 |
| CVE-2020-28280 | Prototype pollution vulnerability in 'predefine' | critical | 9.8 | - | No | 2020-12-29 |
| CVE-2026-18535 | IBM API Connect Denial of Service | critical | 9.6 | - | No | 2026-11-07 |
| CVE-2026-25547 | Uncontrolled Resource Consumption in @isaacs/brace-expansion | critical | 9.2 | - | No | 2026-02-04 |
| CVE-2025-25200 | Koa has Inefficient Regular Expression Complexity | critical | 9.2 | - | No | 2025-02-12 |
| CVE-2023-29487 | - | critical | 9.1 | - | No | 2023-12-21 |
| CVE-2026-61619 | OWASP CRS: ReDoS in shared unix-shell-evasion regex-assembly include (12 RCE rules) - PCRE2 backtracking-limit exhaustion causes detection bypass and CPU DoS | high | 8.8 | - | No | 2026-11-11 |
| CVE-2022-34749 | Mistune vulnerable to catastrophic backtracking | high | 8.8 | - | No | 2022-07-25 |
| CVE-2026-121707 | Effect: ReDoS in Schema.TemplateLiteral compiled regex | high | 8.7 | - | No | 2026-11-17 |
| CVE-2026-123487 | Parse Server 9.0.0 before 9.10.7-alpha.1 ReDoS via Email Validation Regex | high | 8.7 | - | No | 2026-11-06 |

## Related attack patterns (CAPEC)

- [CAPEC-492](https://radicalnotion.ai/capec/capec-492): Regular Expression Exponential Blowup

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-407](https://radicalnotion.ai/cwe/cwe-407) | Inefficient Algorithmic Complexity |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| OWASP Golang Secure Coding Practices Guide | Regular Expressions | - | - |

## Frequently asked questions

### What is CWE-1333?

The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.

### What CVEs are caused by CWE-1333?

520 recorded CVEs are attributed to CWE-1333, including CVE-2026-82617, CVE-2025-62484 and CVE-2023-29486.

### Is CWE-1333 part of the OWASP Top 10?

CWE-1333 maps to OWASP Golang Secure Coding Practices Guide: Regular Expressions in the OWASP security taxonomy.

### How do you prevent CWE-1333?

Use regular expressions that do not support backtracking, e.g. by removing nested quantifiers.

### How is CWE-1333 detected?

Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

### What are the consequences of CWE-1333?

Exploiting CWE-1333 can lead to: DoS: Resource Consumption (CPU).

### Is CWE-1333 actively exploited?

520 recorded CVEs are caused by CWE-1333; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/1333.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-1333). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
