[Forgot Password]
Login  Register Subscribe

30479

 
 

423868

 
 

248268

 
 

909

 
 

195051

 
 

282

Paid content will be excluded from the download.


Download | Alert*
CWE
view XML

Incorrect Regular Expression

ID: 185Date: (C)2012-05-14   (M)2022-10-10
Type: weaknessStatus: DRAFT
Abstraction Type: Class





Description

The software specifies a regular expression in a way that causes data to be improperly matched or compared.

Extended Description

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.

Applicable Platforms
Language Class: All

Time Of Introduction

  • Implementation

Related Attack Patterns

Common Consequences

ScopeTechnical ImpactNotes
Access_Control
 
Bypass protection mechanism
 
In PHP, regular expression checks can sometimes be bypassed with a null byte, leading to any number of weaknesses.
 

Detection Methods
None

Potential Mitigations

PhaseStrategyDescriptionEffectivenessNotes
Architecture and Design
 
Refactoring
 
Regular expressions can become error prone when defining a complex language even for those experienced in writing grammars. Determine if several smaller regular expressions simplify one large regular expression. Also, subject the regular expression to thorough testing techniques such as equivalence partitioning, boundary value analysis, and robustness. After testing and a reasonable confidence level is achieved, a regular expression may not be foolproof. If an exploit is allowed to slip through, then record the exploit and refactor the regular expression.
 
  

Relationships

Related CWETypeViewChain
CWE-185 ChildOf CWE-896 Category CWE-888  

Demonstrative Examples   (Details)

  1. (Demonstrative Example Id DX-37)

Observed Examples

  1. CVE-2002-2109 : Regexp isn't "anchored" to the beginning or end, which allows spoofed values that have trusted values as substrings.
  2. CVE-2005-1949 : Regexp for IP address isn't anchored at the end, allowing appending of shell metacharacters.
  3. CVE-2001-1072 : Bypass access restrictions via multiple leading slash, which causes a regular expression to fail.
  4. CVE-2000-0115 : Local user DoS via invalid regular expressions.
  5. CVE-2002-1527 : chain: Malformed input generates a regular expression error that leads to information exposure.
  6. CVE-2005-1061 : Certain strings are later used in a regexp, leading to a resultant crash.
  7. CVE-2005-2169 : MFV. Regular expression intended to protect against directory traversal reduces ".../...//" to "../".
  8. CVE-2005-0603 : Malformed regexp syntax leads to information exposure in error message.
  9. CVE-2005-1820 : Code injection due to improper quoting of regular expression.
  10. CVE-2005-3153 : Null byte bypasses PHP regexp check.
  11. CVE-2005-4155 : Null byte bypasses PHP regexp check.

For more examples, refer to CVE relations in the bottom box.

White Box Definitions
None

Black Box Definitions
None

Taxynomy Mappings

TaxynomyIdNameFit
PLOVER  Regular Expression Error
 
 

References:

  1. M. Howard D. LeBlanc .Writing Secure Code 2nd Edition. Microsoft. Section:'Chapter 10, "Using Regular Expressions for Checking Input" Page 350'. Published on 2002.
CVE    11
CVE-2020-2288
CVE-2018-11615
CVE-2018-17984
CVE-2018-20801
...

© SecPod Technologies