Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CWE-22 (对路径名的限制不恰当(路径遍历)) — Vulnerability Class 3427

3427 vulnerabilities classified as CWE-22 (对路径名的限制不恰当(路径遍历)). AI Chinese analysis included.

CWE-22 represents a critical input validation weakness where software fails to properly sanitize external input before constructing file paths. Attackers typically exploit this vulnerability by injecting directory traversal sequences, such as “../”, into user-supplied parameters. These malicious inputs allow the application to resolve file references outside the intended restricted directory, potentially granting unauthorized access to sensitive system files, configuration data, or source code. To mitigate this risk, developers must implement rigorous input validation techniques, ensuring that all path components are strictly checked against allowed characters and structures. Additionally, employing canonicalization to resolve symbolic links and relative paths before validation, combined with strict chroot jails or sandboxing, effectively confines file operations to designated directories, thereby neutralizing the potential for path traversal attacks and preserving system integrity.

MITRE CWE 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. 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" to access unexpected files. This is referred to as absolute path traversal.
Common Consequences (4)
Integrity, Confidentiality, AvailabilityExecute 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.
IntegrityModify 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 the attacker may be able to bypass that mechanism. For example, appending a new account at the end of a password file may allow …
ConfidentialityRead 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 a…
AvailabilityDoS: 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 protection mechanisms such as authentication, it has the potential to lock out product users.
Mitigations (5)
ImplementationAssume 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…
Architecture and DesignFor any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
ImplementationInputs 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. Use a built-in path canonicalization function (such as realpath(…
Architecture and DesignUse a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].
OperationUse an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].
Effectiveness: Moderate
Examples (2)
The following code could be for a social networking application in which each user's profile information is stored in a separate file. All files are stored in a single directory.
my $dataPath = "/users/cwe/profiles"; my $username = param("user"); my $profilePath = $dataPath . "/" . $username; open(my $fh, "<", $profilePath) || ExitError("profile read error: $profilePath"); print "<ul>\n"; while (<$fh>) { print "<li>$_</li>\n"; } print "</ul>\n";
Bad · Perl
../../../etc/passwd
Attack
In the example below, the path to a dictionary file is read from a system property and used to initialize a File object.
String filename = System.getProperty("com.domain.application.dictionaryFile"); File dictionaryFile = new File(filename);
Bad · Java
CVE IDTitleCVSSSeverityPublished
CVE-2016-10331 Synology Photo Station 路径遍历漏洞 — Synology Photo Station 5.3 -2017-05-12
CVE-2017-6629 Cisco Unity Connection 安全漏洞 — Cisco Unity Connection 7.5 -2017-05-03
CVE-2017-3851 Cisco IOx Cisco Application-hosting Framework 路径遍历漏洞 — Cisco Application-Hosting Framework 7.5 -2017-03-22
CVE-2014-2352 Cogent DataHub Path Traversal — DataHub 9.1 -2014-05-30
CVE-2014-0780 InduSoft Web Studio Path Traversal — Web Studio 9.8 -2014-04-25
CVE-2014-0750 GE Proficy HMI/SCADA Path Traversal — Proficy HMI/SCADA - CIMPLICITY 9.8 -2014-01-25
CVE-2014-0751 GE Proficy HMI/SCADA Path Traversal — Proficy HMI/SCADA - CIMPLICITY 9.8 -2014-01-25

Vulnerabilities classified as CWE-22 (对路径名的限制不恰当(路径遍历)) represent 3427 CVEs. The CWE taxonomy describes the weakness; review individual CVEs for product-specific impact.