The product specifies a regular expression in a way that causes data to be improperly matched or compared.
View on MITREWhen the regular expression is used in protection mechanisms such as filtering or validation, this may allow an attacker to bypass the intended restrictions on the incoming data.
When the regular expression is not correctly specified, data might have a different format or type than the rest of the program expects, producing resultant weaknesses or errors.
In PHP, regular expression checks can sometimes be bypassed with a null byte, leading to any number of weaknesses.
No mitigation information available for this CWE.
No detection method information available for this CWE.
This code uses a regular expression to validate an IP string prior to using it in a call to the "ping" command.
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.
Regexp isn't "anchored" to the beginning or end, which allows spoofed values that have trusted values as substrings.
View DetailsRegexp for IP address isn't anchored at the end, allowing appending of shell metacharacters.
View DetailsBypass access restrictions via multiple leading slash, which causes a regular expression to fail.
View Detailschain: Malformed input generates a regular expression error that leads to information exposure.
View DetailsMFV. Regular expression intended to protect against directory traversal reduces ".../...//" to "../".
View DetailsNo relationship information available for this CWE.
CWE-185: Incorrect Regular Expression is a Common Weakness Enumeration (CWE) entry maintained by MITRE. The product specifies a regular expression in a way that causes data to be improperly matched or compared. When the regular expression is used in protection mechanisms such as filtering or validation, this may allow an attacker to bypass the intended restrictions on the incoming data.
If exploited, CWE-185 (Incorrect Regular Expression) it can compromise Other and Access Control, leading to outcomes such as Unexpected State, Varies by Context and Bypass Protection Mechanism.
CWE-185 commonly affects Not Language-Specific. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.
MITRE documents real CVEs mapped to CWE-185, including CVE-2002-2109, CVE-2005-1949, CVE-2001-1072, CVE-2000-0115 and CVE-2002-1527. You can look up the full details of each CVE, including CVSS scores and remediation guidance, on our CVE Lookup tool.
A CWE (Common Weakness Enumeration) like CWE-185 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.