目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1336

100%

CWE-777 类漏洞列表 2

CWE-777 类弱点 2 条 CVE 漏洞汇总,含 AI 中文分析。

CWE-777 指未使用锚点的正则表达式漏洞,属于输入验证缺陷。攻击者利用正则缺乏起始或结束锚点,通过构造包含恶意字符的畸形数据,使非法输入绕过允许列表检查并注入系统。开发者应避免此问题,在正则表达式中明确添加起始(^)和结束($)锚点,确保匹配范围严格限定,从而防止部分匹配导致的绕过风险,保障数据处理的完整性与安全性。

MITRE CWE 官方描述
CWE:CWE-777 未使用锚点的正则表达式(Regular Expression without Anchors) 英文:产品使用正则表达式(Regular Expression)来执行中和(Neutralization),但该正则表达式未使用锚点(Anchors),可能导致恶意数据或格式错误的数据绕过检测。 在执行诸如针对允许输入集(Allowlist)进行验证等任务时,会对数据进行检查并可能进行修改,以确保其格式正确并符合安全值列表。如果正则表达式未使用锚点,恶意数据或格式错误的数据可能会出现在匹配正则表达式的字符串之前或之后。允许通过的恶意数据类型取决于应用程序的上下文以及从正则表达式中省略了哪些锚点。
常见影响 (1)
Availability, Confidentiality, Access ControlBypass Protection Mechanism
An unanchored regular expression in the context of an allowlist will possibly result in a protection mechanism failure, allowing malicious or malformed data to enter trusted regions of the program. The specific consequences will depend on what functionality the allowlist was protecting.
缓解措施 (1)
ImplementationBe sure to understand both what will be matched and what will not be matched by a regular expression. Anchoring the ends of the expression will allow the programmer to define an allowlist strictly limited to what is matched by the text in the regular expression. If you are using a package that only matches one line by default, ensure that you can match multi-line inputs if necessary.
代码示例 (2)
Consider a web application that supports multiple languages. It selects messages for an appropriate language by using the lang parameter.
$dir = "/home/cwe/languages"; $lang = $_GET['lang']; if (preg_match("/[A-Za-z0-9]+/", $lang)) { include("$dir/$lang"); } else { echo "You shall not pass!\n"; }
Bad · PHP
../../etc/passwd
Attack
This code uses a regular expression to validate an IP string prior to using it in a call to the "ping" command.
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)
Bad · Python
CVE ID标题CVSS风险等级Published
CVE-2026-40110 Jupyter Server 安全漏洞 — jupyter_server 8.2 -2026-05-05
CVE-2026-39087 ntfy 代码注入漏洞 — ntfy 6.4 Medium2026-04-23

CWE-777 是常见的弱点类别,本平台收录该类弱点关联的 2 条 CVE 漏洞。