CWE-625: Permissive Regular Expression
CWE版本: 4.18
更新日期: 2025-09-09
弱点描述
The product uses a regular expression that does not sufficiently restrict the set of allowed values.
常见后果
影响范围: Access Control
技术影响: Bypass Protection Mechanism
潜在缓解措施
阶段: Implementation
描述: When applicable, ensure that the regular expression marks beginning and ending string patterns, such as "/^string$/" for Perl.
检测方法
方法: 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.)
有效性: High
观察示例
参考: 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.
引入模式
| 阶段 | 说明 |
|---|---|
| Implementation | This problem is frequently found when the regular expression is used in input validation or security features such as authentication. |
适用平台
编程语言
分类映射
| 分类名称 | 条目ID | 条目名称 | 映射适配度 |
|---|---|---|---|
| The CERT Oracle Secure Coding Standard for Java (2011) | IDS08-J | Sanitize untrusted data passed to a regex | - |