---
title: "CWE-625: Permissive Regular Expression"
url: https://radicalnotion.ai/cwe/cwe-625
type: cwe
description: "The product uses a regular expression that does not sufficiently restrict the set of allowed values."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-625: Permissive Regular Expression

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

## Description

The product uses a regular expression that does not sufficiently restrict the set of allowed values.

Common errors include:

not identifying the beginning and end of the target string

using wildcards instead of acceptable character ranges

others

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | This problem is frequently found when the regular expression is used in input validation or security features such as authentication. |

## Applicable platforms

**Languages:** Perl (Undetermined), PHP (Undetermined), Python (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Access Control | Bypass Protection Mechanism | The regexp could accept substrings that match the pattern, which produces a partial comparison to the target. In some cases, this can allow dangerous substrings to bypass the intended protection. |

## Potential mitigations

### Implementation

When applicable, ensure that the regular expression marks beginning and ending string patterns, such as "/^string$/" for Perl.

## 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

The following code takes phone numbers as input, and uses a regular expression to reject invalid phone numbers.

Bad code:

```perl
$phone = GetPhoneNumber();
if ($phone =~ /\d+-\d+/) {
    # looks like it only has hyphens and digits
    system("lookup-phone $phone");
}
else {
    error("malformed number!");
}
```

An attacker could provide an argument such as: "; ls -l ; echo 123-456" This would pass the check, since "123-456" is sufficient to match the "\\d+-\\d+" portion of the regular expression.

### Example 2

This code uses a regular expression to validate an IP string prior to using it in a call to the "ping" command.

Bad code:

```python
import subprocess
import re

def validate_ip_regex(ip: str):
    ip_validator = re.compile(r"((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}")
    if ip_validator.match(ip):
        return ip
    else:
        raise ValueError("IP address does not match valid pattern.")

def run_ping_regex(ip: str):
    validated = validate_ip_regex(ip)
    # The ping command treats zero-prepended IP addresses as octal
    result = subprocess.call(["ping", validated])
    print(result)
```

Since the regular expression does not have anchors (CWE-777), i.e. is unbounded without ^ or $ characters, then prepending a 0 or 0x to the beginning of the IP address will still result in a matched regex pattern. Since the ping command supports octal and hex prepended IP addresses, it will use the unexpectedly valid IP address (CWE-1389). For example, "0x63.63.63.63" would be considered equivalent to "99.63.63.63". As a result, the attacker could potentially ping systems that the attacker cannot reach directly.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2021-22204 | Chain: regex in EXIF processor code does not correctly determine where a string ends (CWE-625), enabling eval injection (CWE-95), as exploited in the wild per CISA KEV. |
| CVE-2006-1895 | ".\*" regexp leads to static code injection |
| CVE-2002-2175 | insertion of username into regexp results in partial comparison, causing wrong database entry to be updated when one username is a substring of another. |
| CVE-2006-4527 | regexp intended to verify that all characters are legal, only checks that at least one is legal, enabling file inclusion. |
| CVE-2005-1949 | Regexp for IP address isn't anchored at the end, allowing appending of shell metacharacters. |
| CVE-2002-2109 | Regexp isn't "anchored" to the beginning or end, which allows spoofed values that have trusted values as substrings. |
| CVE-2006-6511 | regexp in .htaccess file allows access of files whose names contain certain substrings |
| CVE-2006-6629 | allow load of macro files whose names contain certain substrings. |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2024-49400 | - | critical | 9.8 | - | No | 2024-10-17 |
| CVE-2026-118995 | CallBackery versions before 0.62.0 for Perl accept unintended values in form fields checked by createRxValidator | critical | 9.1 | - | No | 2026-10-30 |
| CVE-2026-64940 | Permissive regular expression vulnerability in Tegalog -Fumy Otegaru Memo Logger- | high | 8.8 | - | No | 2026-08-10 |
| CVE-2026-32973 | OpenClaw \< 2026.3.11 - Exec Allowlist Pattern Overmatch via POSIX Path Normalization | high | 8.8 | - | No | 2026-03-29 |
| CVE-2018-8926 | - | high | 8.8 | - | No | 2018-06-08 |
| CVE-2026-14814 | Permissive Regular Expression in GitLab | high | 8.2 | - | No | 2026-10-13 |
| CVE-2026-34157 | Wails: wildcardPatternToRegex allows Origin bypass via suffix match in BindingsAllowedOrigins | high | 7.6 | - | No | 2026-11-05 |
| CVE-2026-34830 | Rack: Rack::Sendfile regex injection via HTTP\_X\_ACCEL\_MAPPING header allows arbitrary file reads through nginx | high | 7.5 | - | No | 2026-04-02 |
| CVE-2026-123315 | - | high | 7.0 | - | No | 2026-11-06 |
| CVE-2026-133537 | Org.keycloak:keycloak-services: org.keycloak:keycloak-common: uma uri suffix matching authorization bypass | medium | 6.8 | - | No | 2026-11-20 |
| CVE-2026-19278 | Stackrox: stackrox: privilege escalation via unanchored regular expressions in auth m2m role mappings | medium | 6.8 | - | No | 2026-08-10 |
| CVE-2026-23651 | Microsoft ACI Confidential Containers Elevation of Privilege Vulnerability | medium | 6.7 | - | No | 2026-03-05 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-185](https://radicalnotion.ai/cwe/cwe-185) | Incorrect Regular Expression |
| Child | [CWE-777](https://radicalnotion.ai/cwe/cwe-777) | Regular Expression without Anchors |
| Peer | [CWE-183](https://radicalnotion.ai/cwe/cwe-183) | Permissive List of Allowed Inputs |
| Peer | [CWE-184](https://radicalnotion.ai/cwe/cwe-184) | Incomplete List of Disallowed Inputs |
| Peer | [CWE-187](https://radicalnotion.ai/cwe/cwe-187) | Partial String Comparison |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| The CERT Oracle Secure Coding Standard for Java (2011) | Sanitize untrusted data passed to a regex | IDS08-J | - |

## Frequently asked questions

### What is CWE-625?

The product uses a regular expression that does not sufficiently restrict the set of allowed values.

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

22 recorded CVEs are attributed to CWE-625, including CVE-2024-49400, CVE-2026-118995 and CVE-2026-64940.

### How do you prevent CWE-625?

When applicable, ensure that the regular expression marks beginning and ending string patterns, such as "/^string$/" for Perl.

### How is CWE-625 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-625?

Exploiting CWE-625 can lead to: Bypass Protection Mechanism.

### Is CWE-625 actively exploited?

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

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

---

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