Incorrect Behavior Order: Validate Before Canonicalize |
Weakness ID: 180 (Weakness Base) | Status: Draft |
Description Summary
Extended Description
This can be used by an attacker to bypass the validation and launch attacks that expose weaknesses that would otherwise be prevented, such as injection.
Example 1
The following code attempts to validate a given input path by checking it against a whitelist and then return the canonical path. In this specific case, the path is considered valid if it starts with the string "/safe_dir/".
The problem with the above code is that the validation step occurs before canonicalization occurs. An attacker could provide an input path of "/safe_dir/../" that would pass the validation step. However, the canonicalization process sees the double dot as a traversal to the parent directory and hence when canonicized the path would become just "/".
To avoid this problem, validation should occur after canonicalization takes place. In this case canonicalization occurs during the initialization of the File object. The code below fixes the issue.
Reference | Description |
---|---|
CVE-2002-0433 | |
CVE-2003-0332 | |
CVE-2002-0802 | |
CVE-2000-0191 | Overlaps "fakechild/../realchild" |
CVE-2004-2363 | Product checks URI for "<" and other literal characters, but does it before hex decoding the URI, so "%3E" and other sequences are allowed. |
Inputs should be decoded and canonicalized to the application's current internal representation before being validated. Make sure that your application does not decode the same input twice. Such errors could be used to bypass whitelist schemes by introducing dangerous inputs after they have been checked. |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 171 | Cleansing, Canonicalization, and Comparison Errors | Development Concepts (primary)699 |
ChildOf | ![]() | 179 | Incorrect Behavior Order: Early Validation | Research Concepts (primary)1000 |
ChildOf | ![]() | 722 | OWASP Top Ten 2004 Category A1 - Unvalidated Input | Weaknesses in OWASP Top Ten (2004) (primary)711 |
Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
---|---|---|---|
PLOVER | Validate-Before-Canonicalize | ||
OWASP Top Ten 2004 | A1 | CWE More Specific | Unvalidated Input |
CAPEC-ID | Attack Pattern Name | (CAPEC Version: 1.4) |
---|---|---|
3 | Using Leading 'Ghost' Character Sequences to Bypass Input Filters | |
4 | Using Alternative IP Address Encodings | |
78 | Using Escaped Slashes in Alternate Encoding | |
79 | Using Slashes in Alternate Encoding | |
71 | Using Unicode Encoding to Bypass Validation Logic | |
80 | Using UTF-8 Encoding to Bypass Validation Logic |
Submissions | ||||
---|---|---|---|---|
Submission Date | Submitter | Organization | Source | |
PLOVER | Externally Mined | |||
Modifications | ||||
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Eric Dalci | Cigital | External | |
updated Potential Mitigations, Time of Introduction | ||||
2008-08-15 | Veracode | External | ||
Suggested OWASP Top Ten 2004 mapping | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Relationships, Other Notes, Taxonomy Mappings, Type | ||||
2008-10-14 | CWE Content Team | MITRE | Internal | |
updated Description | ||||
2009-05-27 | CWE Content Team | MITRE | Internal | |
updated Other Notes, Relationship Notes | ||||
Previous Entry Names | ||||
Change Date | Previous Entry Name | |||
2008-04-11 | Validate-Before-Canonicalize | |||