33
[REF-48]Jeremiah Grossman. "Input validation or output filtering, which is better?". 2007 January 0.
< https://blog.jeremiahgrossman.com/2007/01/input-validation-or-output-filtering.html >.2023-04-07.
[REF-170]Kevin Beaver. "The importance of input validation". 2006 September 6. < http://
searchsoftwarequality.techtarget.com/tip/0,289483,sid92_gci1214373,00.html >.
[REF-7]Michael Howard and David LeBlanc. "Writing Secure Code". 2nd Edition. 2002
December 4. Microsoft Press. < https://www.microsoftpressstore.com/store/writing-securecode-
9780735617223 >.
[REF-1109]"LANGSEC: Language-theoretic Security". < http://langsec.org/ >.
[REF-1110]"LangSec: Recognition, Validation, and Compositional Correctness for Real World
Security". < http://langsec.org/bof-handout.pdf >.
[REF-1111]Sergey Bratus, Lars Hermerschmidt, Sven M. Hallberg, Michael E. Locasto, Falcon D.
Momot, Meredith L. Patterson and Anna Shubina. "Curing the Vulnerable Parser: Design Patterns
for Secure Input Handling". USENIX ;login:. 2017. < https://www.usenix.org/system/files/login/
articles/login_spring17_08_bratus.pdf >.
[REF-1287]MITRE. "Supplemental Details - 2022 CWE Top 25". 2022 June 8. < https://
cwe.mitre.org/top25/archive/2022/2022_cwe_top25_supplemental.html#problematicMappingDetails
>.
CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path
Traversal')
Weakness ID : 22
Structure : Simple
Abstraction : Base
Description
The product uses external input to construct a pathname that is intended to identify a file or
directory that is located underneath a restricted parent directory, but the product does not properly
neutralize special elements within the pathname that can cause the pathname to resolve to a
location that is outside of the restricted directory.
Extended Description
Many file operations are intended to take place within a restricted directory. By using special
elements such as ".." and "/" separators, attackers can escape outside of the restricted location
to access files or directories that are elsewhere on the system. One of the most common special
elements is the "../" sequence, which in most modern operating systems is interpreted as the
parent directory of the current location. This is referred to as relative path traversal. Path traversal
also covers the use of absolute pathnames such as "/usr/local/bin", which may also be useful in
accessing unexpected files. This is referred to as absolute path traversal.
In many programming languages, the injection of a null byte (the 0 or NUL) may allow an attacker
to truncate a generated filename to widen the scope of attack. For example, the product may add
".txt" to any pathname, thus limiting the attacker to text files, but a null injection may effectively
remove this restriction.
Relationships
The table(s) below shows the weaknesses and high level categories that are related to this
weakness. These relationships are defined as ChildOf, ParentOf, MemberOr and give insight to
similar items that may exist at higher and lower levels of abstraction. In addition, relationships such
as PeerOf and CanAlsoBe are defined to show similar weaknesses that may want to be explored.
Relevant to the view "Research Concepts" (CWE-1000)
CWE Version 4.14
CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
CWE-22: Improper Limitation of a Pathname
to a Restricted Directory ('Path Traversal') 34
Nature Type ID Name Page
ChildOf 668 Exposure of Resource to Wrong Sphere 1469
ChildOf 706 Use of Incorrectly-Resolved Name or Reference 1544
ParentOf 23 Relative Path Traversal 46
ParentOf 36 Absolute Path Traversal 75
CanFollow 20 Improper Input Validation 20
CanFollow 73 External Control of File Name or Path 132
CanFollow 172 Encoding Error 433
Relevant to the view "Weaknesses for Simplified Mapping of Published
Vulnerabilities" (CWE-1003)
Nature Type ID Name Page
ChildOf 706 Use of Incorrectly-Resolved Name or Reference 1544
Relevant to the view "CISQ Quality Measures (2020)" (CWE-1305)
Nature Type ID Name Page
ParentOf 23 Relative Path Traversal 46
ParentOf 36 Absolute Path Traversal 75
Relevant to the view "CISQ Data Protection Measures" (CWE-1340)
Nature Type ID Name Page
ParentOf 23 Relative Path Traversal 46
ParentOf 36 Absolute Path Traversal 75
Relevant to the view "Software Development" (CWE-699)
Nature Type ID Name Page
MemberOf 1219 File Handling Issues 2480
Weakness Ordinalities
Primary :
Resultant :
Applicable Platforms
Language : Not Language-Specific (Prevalence = Undetermined)
Alternate Terms
Directory traversal :
Path traversal : "Path traversal" is preferred over "directory traversal," but both terms are attackfocused.
Likelihood Of Exploit
High
Common Consequences
Scope Impact Likelihood
Integrity
Confidentiality
Availability
Execute Unauthorized Code or Commands
The attacker may be able to create or overwrite critical
files that are used to execute code, such as programs or
libraries.
Integrity Modify Files or Directories
The attacker may be able to overwrite or create critical
files, such as programs, libraries, or important data. If
the targeted file is used for a security mechanism, then
CWE Version 4.14
CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
CWE-22: Improper Limitation of a Pathname
to a Restricted Directory ('Path Traversal')