Permissive Regular Expression |
Weakness ID: 625 (Weakness Base) | Status: Draft |
Description Summary
Extended Description
This effectively causes the regexp to accept substrings that match the pattern, which produces a partial comparison to the target. In some cases, this can lead to other weaknesses. Common errors include:
not identifying the beginning and end of the target string
using wildcards instead of acceptable character ranges
others
Example 1
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.
Reference | Description |
---|---|
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. |
VIM Mailing list, March 14, 2006 |
When applicable, ensure that your regular expression marks beginning and ending string patterns, such as "/^string$/" for Perl. |
This problem is frequently found when the regular expression is used in input validation or security features such as authentication. |
Ordinality | Description |
---|---|
Primary | (where the weakness exists independent of other weaknesses) |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 185 | Incorrect Regular Expression | Development Concepts (primary)699 Research Concepts (primary)1000 |
PeerOf | ![]() | 183 | Permissive Whitelist | Research Concepts1000 |
PeerOf | ![]() | 184 | Incomplete Blacklist | Research Concepts1000 |
PeerOf | ![]() | 187 | Partial Comparison | Research Concepts1000 |
ParentOf | ![]() | 777 | Regular Expression without Anchors | Development Concepts (primary)699 Research Concepts (primary)1000 |
Modifications | ||||
---|---|---|---|---|
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Eric Dalci | Cigital | External | |
updated Time of Introduction | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Applicable Platforms, Description, Relationships, Observed Example, Other Notes, Weakness Ordinalities | ||||
2009-03-10 | CWE Content Team | MITRE | Internal | |
updated Description | ||||
2009-05-27 | CWE Content Team | MITRE | Internal | |
updated Demonstrative Examples | ||||
2009-07-27 | CWE Content Team | MITRE | Internal | |
updated Relationships |