CWE WEAKNESSES / CWE-25
CWE-25
Path Traversal: '/../filedir'
Variant
What it is
The product uses external input to construct a pathname that should be within a restricted directory, but it does not properly neutralize "/../" sequences that can resolve to a location that is outside of that directory.
This allows attackers to traverse the file system to access files or directories that are outside of the restricted directory.Sometimes a program checks for "../" at the beginning of the input, so a "/../" can bypass that check.
Impact
| Confidentiality, Integrity | Read Files or Directories, Modify Files or Directories |
Mitigations
- [Implementation]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 r
- [Implementation] 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.
Real-world CVE examples
- CVE-2022-20775 — A cloud management tool allows attackers to bypass the restricted shell using path traversal sequences like "/../" in the USER environment variable.
Related weaknesses
Test & detect
Browse all common weaknesses, check related exploited CVEs, or map to ATT&CK techniques.
Source: MITRE CWE. View on cwe.mitre.org →