---
title: "CWE-186: Overly Restrictive Regular Expression"
url: https://radicalnotion.ai/cwe/cwe-186
type: cwe
description: "A regular expression is overly restrictive in a way that does not match all intended values."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-186: Overly Restrictive Regular Expression

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 2
- **Of those, in CISA KEV:** 0
- **New in 2026:** 1
- **CWE catalog version:** 4.21

## Description

A regular expression is overly restrictive in a way that does not match all intended values.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Access Control | Bypass Protection Mechanism, Varies by Context | An overly restrictive regexp misses some potentially security-relevant values, leading to either false positives \*or\* false negatives, depending on how the regexp is being used within the code. |

## Potential mitigations

### Implementation (Refactoring)

Regular expressions can become error prone when defining a complex language even for those experienced in writing grammars. Determine if several smaller regular expressions simplify one large regular expression. Also, subject your regular expression to thorough testing techniques such as equivalence partitioning, boundary value analysis, and robustness. After testing and a reasonable confidence level is achieved, a regular expression may not be foolproof. If an exploit is allowed to slip through, then record the exploit and refactor your regular expression.

## Demonstrative examples

### Example 1

Consider the use of a regexp to identify acceptable values or to spot unwanted terms.

Bad code:

```algorithm
An overly restrictive regexp misses some potentially security-relevant values, leading to either false positives *or* false negatives, depending on how the regexp is being used within the code.
```

Consider the expression /\[0-8\]/, which omits "9" although the programmer might have intended to match any digit with /\[0-9\]/.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2005-1604 | MIE. ".php.ns" bypasses ".php$" regexp but is still parsed as PHP by Apache. (manipulates an equivalence property under Apache) |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-121373 | Symfony: HtmlSanitizer MetaRefreshAttributeSanitizer Matches Only a Narrow Subset of the Browser Refresh Grammar (Incomplete Fix for CVE-2026-48761) | medium | 5.3 | - | No | 2026-11-04 |
| CVE-2025-46821 | Envoy vulnerable to bypass of RBAC uri\_template permission | medium | 5.3 | - | No | 2025-05-07 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-185](https://radicalnotion.ai/cwe/cwe-185) | Incorrect Regular Expression |
| Can also be | [CWE-183](https://radicalnotion.ai/cwe/cwe-183) | Permissive List of Allowed Inputs |
| Can also be | [CWE-184](https://radicalnotion.ai/cwe/cwe-184) | Incomplete List of Disallowed Inputs |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Overly Restrictive Regular Expression | - | - |

## Frequently asked questions

### What is CWE-186?

A regular expression is overly restrictive in a way that does not match all intended values.

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

2 recorded CVEs are attributed to CWE-186, including CVE-2026-121373 and CVE-2025-46821.

### How do you prevent CWE-186?

Regular expressions can become error prone when defining a complex language even for those experienced in writing grammars. Determine if several smaller regular expressions simplify one large regular expression. Also, subject your regular expression to thorough testing techniques such as equivalence partitioning, boundary value analysis, and robustness. After testing and a reasonable confidence level is achieved, a regular expression may not be foolproof. If an exploit is allowed to slip through, then record the exploit and refactor your regular expression.

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

Exploiting CWE-186 can lead to: Bypass Protection Mechanism, Varies by Context.

### Is CWE-186 actively exploited?

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

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

---

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