CWE-41: Improper Resolution of Path Equivalence
Description
The product is vulnerable to file system contents disclosure through path equivalence. Path equivalence involves the use of special characters in file and directory names. The associated manipulations are intended to generate multiple names for the same object.
Path equivalence is usually employed in order to circumvent access controls expressed using an incomplete set of file name or file path representations. This is different from path traversal, wherein the manipulations are performed to generate a name for a different object.
- Abstraction
- BaseA weakness specific enough to point to detection and prevention methods.
- Likelihood of exploit
- Not rated by MITRE
- Status
- Incomplete
Common consequences
- ConfidentialityIntegrityAccess Control
Read Files or Directories; Modify Files or Directories; Bypass Protection Mechanism
An attacker may be able to traverse the file system to unintended locations and read or overwrite the contents of unexpected files. If the files are used for a security mechanism than an attacker may be able to bypass the mechanism.
Potential mitigations
- ImplementationInput Validation
Assume all input is malicious. Use an accept known good input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, boat may be syntactically valid...
- ImplementationOutput Encoding
Use and specify an output encoding that can be handled by the downstream component that is reading the output. Common encodings include ISO-8859-1, UTF-7, and UTF-8. When an encoding is not specified, a downstream component may choose a different encoding, either by assuming a default encoding or automatically inferring which encoding is being used, which can be erroneous. When the encodings are inconsistent, the downstream component might treat some character or byte sequences as special, even if they are not special in the original encoding. Attackers might then be able to exploit this...
- ImplementationInput Validation
Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.
Related weaknesses
Parent weaknesses
Child weaknesses
- CWE-42Path Equivalence: 'filename.' (Trailing Dot)
- CWE-44Path Equivalence: 'file.name' (Internal Dot)
- CWE-46Path Equivalence: 'filename ' (Trailing Space)
- CWE-47Path Equivalence: ' filename' (Leading Space)
- CWE-48Path Equivalence: 'file name' (Internal Whitespace)
- CWE-49Path Equivalence: 'filename/' (Trailing Slash)
- CWE-50Path Equivalence: '//multiple/leading/slash'
- CWE-51Path Equivalence: '/multiple//internal/slash'
- CWE-52Path Equivalence: '/multiple/trailing/slash//'
- CWE-53Path Equivalence: 'multipleinternalbackslash'
- CWE-54Path Equivalence: 'filedir' (Trailing Backslash)
- CWE-55Path Equivalence: '/./' (Single Dot Directory)
- CWE-56Path Equivalence: 'filedir*' (Wildcard)
- CWE-57Path Equivalence: 'fakedir/../realdir/filename'
- CWE-58Path Equivalence: Windows 8.3 Filename