76
Scope Impact Likelihood
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
the attacker may be able to bypass that mechanism.
For example, appending a new account at the end
of a password file may allow an attacker to bypass
authentication.
Confidentiality Read Files or Directories
The attacker may be able read the contents of unexpected
files and expose sensitive data. If the targeted file is used
for a security mechanism, then the attacker may be able
to bypass that mechanism. For example, by reading a
password file, the attacker could conduct brute force
password guessing attacks in order to break into an
account on the system.
Availability DoS: Crash, Exit, or Restart
The attacker may be able to overwrite, delete, or corrupt
unexpected critical files such as programs, libraries, or
important data. This may prevent the product from working
at all and in the case of a protection mechanisms such as
authentication, it has the potential to lockout every user of
the product.
Detection Methods
Automated Static Analysis
Automated static analysis, commonly referred to as Static Application Security Testing (SAST),
can find some instances of this weakness by analyzing source code (or binary/compiled code)
without having to execute it. Typically, this is done by building a model of data flow and control
flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input)
with "sinks" (destinations where the data interacts with external components, a lower layer such
as the OS, etc.)
Effectiveness = High
Demonstrative Examples
Example 1:
In the example below, the path to a dictionary file is read from a system property and used to
initialize a File object.
Example Language: Java (Bad)
String filename = System.getProperty("com.domain.application.dictionaryFile");
File dictionaryFile = new File(filename);
However, the path is not validated or modified to prevent it from containing relative or absolute
path sequences before creating the File object. This allows anyone who can control the system
property to determine what file is used. Ideally, the path should be resolved relative to some kind of
application or user home directory.
Example 2:
This script intends to read a user-supplied file from the current directory. The user inputs the
relative path to the file and the script uses Python's os.path.join() function to combine the path to
the current working directory with the provided path to the specified file. This results in an absolute
CWE Version 4.14
CWE-36: Absolute Path Traversal
CWE-36: Absolute Path Traversal