CWEweakness
CWE-22 Improper Limitation of a Pathname to a Restricted Directory
High
Official page ↗
- Alternate terms
- Path traversal, Directory traversal, Path transversal
- Abstraction
- Base
- Structure
- Simple
- Status
- Stable
- Likelihood of exploit
- High
- Languages
- Go, Not Language-Specific, Python
- CWE version
- 5.0
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" to access unexpected files. This is referred to as absolute path traversal.
Common consequences
• 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 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 to 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 protection mechanisms such as authentication, it has the potential to lock out product users.
Potential 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 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 because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."
Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
When validating filenames, use stringent allowlists that limit the character set to be used. If feasible, only allow a single "." character in the filename to avoid weaknesses such as CWE-23, and exclude directory separators such as "/" to avoid CWE-36. Use a list of allowable file extensions, which will help to avoid CWE-434.
Do not rely exclusively on a filtering mechanism that removes potentially dangerous characters. This is equivalent to a denylist, which may be incomplete (CWE-184). For example, filtering "/" is insufficient protection if the filesystem also supports the use of "\" as a directory separator. Another possible error could occur when the filtering is applied in a way that still produces dangerous data (CWE-182). For example, if "../" sequences are removed from the ".../...//" string in a sequential fashion, two instances of "../" would be removed from the original string, but the remaining characters would still form the "../" string.
• [Architecture and Design] For 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.
• [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.
Use a built-in path canonicalization function (such as realpath() in C) that produces the canonical version of the pathname, which effectively removes ".." sequences and symbolic links (CWE-23, CWE-59). This includes:
• realpath() in C
• getCanonicalPath() in Java
• GetFullPath() in ASP.NET
• realpath() or abs_path() in Perl
• realpath() in PHP
• [Architecture and Design] Use 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].
• [Operation] Use 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].
• [Architecture and Design, Operation] Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
• [Architecture and Design] When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.
For example, ID 1 could map to "inbox.txt" and ID 2 could map to "profile.txt". Features such as the ESAPI AccessReferenceMap [REF-185] provide this capability.
• [Architecture and Design, Operation] Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software.
OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations.
This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise.
Be careful to avoid CWE-243 and other weaknesses related to jails.
• [Architecture and Design, Operation] Store library, include, and utility files outside of the web document root, if possible. Otherwise, store them in a separate directory and use the web server's access control capabilities to prevent attackers from directly requesting them. One common practice is to define a fixed constant in each calling program, then check for the existence of the constant in the library/include file; if the constant does not exist, then the file was directly requested, and it can exit immediately.
This significantly reduces the chance of an attacker being able to bypass any protection mechanisms that are in the base program but not in the include files. It will also reduce the attack surface.
• [Implementation] Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success.
If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files.
Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not.
In the context of path traversal, error messages which disclose path information can help attackers craft the appropriate attack strings to move through the file system hierarchy.
• [Operation, Implementation] When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.
Detection methods
• Automated Static Analysis: Automated techniques can find areas where path traversal weaknesses exist. However, tuning or customization may be required to remove or de-prioritize path-traversal problems that are only exploitable by the product's administrator - or other privileged users - and thus potentially valid behavior or, at worst, a bug instead of a vulnerability.
• Manual Static Analysis: Manual white box techniques may be able to provide sufficient code coverage and reduction of false positives if all file access operations can be assessed within limited time constraints.
• Automated Static Analysis - Binary or Bytecode: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Bytecode Weakness Analysis - including disassembler + source code weakness analysis
Cost effective for partial coverage:
• Binary Weakness Analysis - including disassembler + source code weakness analysis
• Manual Static Analysis - Binary or Bytecode: According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
• Binary / Bytecode disassembler - then use manual analysis for vulnerabilities & anomalies
• Dynamic Analysis with Automated Results Interpretation: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Web Application Scanner
• Web Services Scanner
• Database Scanners
• Dynamic Analysis with Manual Results Interpretation: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Fuzz Tester
• Framework-based Fuzzer
• Manual Static Analysis - Source Code: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Manual Source Code Review (not inspections)
Cost effective for partial coverage:
• Focused Manual Spotcheck - Focused manual analysis of source
• Automated Static Analysis - Source Code: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Source code Weakness Analyzer
• Context-configured Source Code Weakness Analyzer
• Architecture or Design Review: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Formal Methods / Correct-By-Construction
Cost effective for partial coverage:
• Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.)
Observed examples
• CVE-2024-37032: Large language model (LLM) management tool does not
validate the format of a digest value (CWE-1287) from a
private, untrusted model registry, enabling relative
path traversal (CWE-23), a.k.a. Probllama
• CVE-2024-4315: Chain: API for text generation using Large Language Models (LLMs) does
not include the "\" Windows folder separator in its denylist (CWE-184)
when attempting to prevent Local File Inclusion via path traversal
(CWE-22), allowing deletion of arbitrary files on Windows systems.
• CVE-2024-0520: Product for managing datasets for AI model training and evaluation allows both relative (CWE-23) and absolute (CWE-36) path traversal to overwrite files via the Content-Disposition header
• CVE-2022-45918: Chain: a learning management tool debugger uses external input to locate previous session logs (CWE-73) and does not properly validate the given path (CWE-20), allowing for filesystem path traversal using "../" sequences (CWE-24)
• CVE-2019-20916: Python package manager does not correctly restrict the filename specified in a Content-Disposition header, allowing arbitrary file read using path traversal sequences such as "../"
• CVE-2022-31503: Python package constructs filenames using an unsafe os.path.join call on untrusted input, allowing absolute path traversal because os.path.join resets the pathname to an absolute path that is specified as part of the input.
• CVE-2022-24877: directory traversal in Go-based Kubernetes operator app allows accessing data from the controller's pod file system via ../ sequences in a yaml file
• CVE-2021-21972: Chain: Cloud computing virtualization platform does not require authentication for upload of a tar format file (CWE-306), then uses .. path traversal sequences (CWE-23) in the file to access unexpected files, as exploited in the wild per CISA KEV.
• CVE-2020-4053: a Kubernetes package manager written in Go allows malicious plugins to inject path traversal sequences into a plugin archive ("Zip slip") to copy a file outside the intended directory
• CVE-2020-3452: Chain: security product has improper input validation (CWE-20) leading to directory traversal (CWE-22), as exploited in the wild per CISA KEV.
• CVE-2019-10743: Go-based archive library allows extraction of files to locations outside of the target folder with "../" path traversal sequences in filenames in a zip file, aka "Zip Slip"
• CVE-2010-0467: Newsletter module allows reading arbitrary files using "../" sequences.
• CVE-2006-7079: Chain: PHP app uses extract for register_globals compatibility layer (CWE-621), enabling path traversal (CWE-22)
• CVE-2009-4194: FTP server allows deletion of arbitrary files using ".." in the DELE command.
• CVE-2009-4053: FTP server allows creation of arbitrary directories using ".." in the MKD command.
• CVE-2009-0244: FTP service for a Bluetooth device allows listing of directories, and creation or reading of files using ".." sequences.
• CVE-2009-4013: Software package maintenance program allows overwriting arbitrary files using "../" sequences.
• CVE-2009-4449: Bulletin board allows attackers to determine the existence of files using the avatar.
• CVE-2009-4581: PHP program allows arbitrary code execution using ".." in filenames that are fed to the include() function.
• CVE-2010-0012: Overwrite of files using a .. in a Torrent file.
• CVE-2010-0013: Chat program allows overwriting files using a custom smiley request.
• CVE-2008-5748: Chain: external control of values for user's desired language and theme enables path traversal.
• CVE-2009-1936: Chain: library file sends a redirect if it is directly requested but continues to execute, allowing remote file inclusion and path traversal.
Related
Attack pattern · CAPEC (5)
- CAPEC-126 Path Traversal attack pattern
- CAPEC-64 Using Slashes and URL Encoding Combined to Bypass Validation Logic attack pattern
- CAPEC-76 Manipulating Web Input to File System Calls attack pattern
- CAPEC-78 Using Escaped Slashes in Alternate Encoding attack pattern
- CAPEC-79 Using Slashes in Alternate Encoding attack pattern
Observed example · CVE (23)
- CVE-2024-4315 parisneo/lollms version 9.5 is vulnerable to Local File Inclusion (LFI) attacks due to insufficient path sanitization. vulnerability
- CVE-2024-0520 A vulnerability in mlflow/mlflow version 8.2.1 allows for remote code execution due to improper neutralization of special elements used in… vulnerability
- CVE-2024-37032 Ollama before 0.1.34 does not validate the format of the digest (sha256 with 64 hex digits) when getting the model path, and thus… vulnerability
- CVE-2022-45918 ILIAS before 7.16 allows External Control of File Name or Path. vulnerability
- CVE-2022-31503 The orchest/orchest repository before 2022.05.0 on GitHub allows absolute path traversal because the Flask send_file function is used… vulnerability
- CVE-2022-24877 Flux is an open and extensible continuous delivery solution for Kubernetes. vulnerability
- CVE-2021-21972 The vSphere Client (HTML5) contains a remote code execution vulnerability in a vCenter Server plugin. vulnerability
- CVE-2019-20916 The pip package before 19.2 for Python allows Directory Traversal when a URL is given in an install command, because a Content-Disposition… vulnerability
- CVE-2020-3452 A vulnerability in the web services interface of Cisco Adaptive Security Appliance (ASA) Software and Cisco Firepower Threat Defense (FTD)… vulnerability
- CVE-2020-4053 In Helm greater than or equal to 3.0.0 and less than 3.2.4, a path traversal attack is possible when installing Helm plugins from a tar… vulnerability
- CVE-2019-10743 All versions of archiver allow attacker to perform a Zip Slip attack via the "unarchive" functions. vulnerability
- CVE-2009-4013 Multiple directory traversal vulnerabilities in Lintian 1.23.x through 1.23.28, 1.24.x through 1.24.2.1, and 2.x before 2.3.2 allow remote… vulnerability
- CVE-2010-0467 Directory traversal vulnerability in the ccNewsletter (com_ccnewsletter) component 1.0.5 for Joomla! vulnerability
- CVE-2010-0013 Directory traversal vulnerability in slp.c in the MSN protocol plugin in libpurple in Pidgin 2.6.4 and Adium 1.3.8 allows remote attackers… vulnerability
- CVE-2010-0012 Directory traversal vulnerability in libtransmission/metainfo.c in Transmission 1.22, 1.34, 1.75, and 1.76 allows remote attackers to… vulnerability
- CVE-2009-4581 Directory traversal vulnerability in modules/admincp.php in RoseOnlineCMS 3 B1 and earlier, when magic_quotes_gpc is disabled, allows… vulnerability
- CVE-2009-4449 Directory traversal vulnerability in MyBB (aka MyBulletinBoard) 1.4.10, and possibly earlier versions, when changing the user avatar from… vulnerability
- CVE-2009-4194 Directory traversal vulnerability in Golden FTP Server 4.30 Free and Professional, 4.50, and possibly other versions allows remote… vulnerability
- CVE-2009-4053 Multiple directory traversal vulnerabilities in Home FTP Server 1.10.1.139 allow remote authenticated users to (1) create arbitrary… vulnerability
- CVE-2009-1936 _functions.php in cpCommerce 1.2.x, possibly including 1.2.9, sends a redirect but does not exit when it is called directly, which allows… vulnerability
- CVE-2009-0244 Directory traversal vulnerability in the OBEX FTP Service in the Microsoft Bluetooth stack in Windows Mobile 6 Professional, and probably… vulnerability
- CVE-2008-5748 Directory traversal vulnerability in plugins/spaw2/dialogs/dialog.php in BloofoxCMS 0.3.4 allows remote attackers to read arbitrary files… vulnerability
- CVE-2006-7079 Variable extraction vulnerability in include/common.php in exV2 2.0.4.3 and earlier allows remote attackers to overwrite arbitrary program… vulnerability
Can precede · CWE (1)
- CWE-668 Exposure of Resource to Wrong Sphere weakness
Child of · CWE (1)
- CWE-706 Use of Incorrectly-Resolved Name or Reference weakness
Referenced by CAPEC · weakness (5)
- CAPEC-126 Path Traversal attack pattern
- CAPEC-64 Using Slashes and URL Encoding Combined to Bypass Validation Logic attack pattern
- CAPEC-76 Manipulating Web Input to File System Calls attack pattern
- CAPEC-78 Using Escaped Slashes in Alternate Encoding attack pattern
- CAPEC-79 Using Slashes in Alternate Encoding attack pattern
Referenced by CVE · weakness (10,889)
- CVE-2026-104309 IBM Langflow OSS 1.0.0 through 1.12.3 could allow a remote authenticated attacker to obtain sensitive information due to improper… vulnerability
- CVE-2026-104312 IBM Langflow OSS 1.0.0 through 1.12.3 could allow an authenticated attacker to produce a server-generated ZIP archive containing entry… vulnerability
- CVE-2026-110190 IBM Langflow OSS 1.0.0 through 1.12.4 could allow an authenticated user to traverse directories on the system. vulnerability
- CVE-2026-110244 IBM Langflow OSS 1.0.0 through 1.12.4 could allow a remote authenticated attacker to obtain sensitive information due to improper… vulnerability
- CVE-2026-113576 Adobe Digital Editions is affected by an Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability that… vulnerability
- CVE-2026-113617 The Automated Import Products to Cart WordPress plugin before 1.0.4 does not sanitize a user-supplied file path before using it to read and… vulnerability
- CVE-2026-113692 Path traversal in the SmartIT file-management feature of BMC IT Service Management Suite versions 25.3.01, 25.4.01, and 26.1.01 allows… vulnerability
- CVE-2026-118758 Kubeflow Pipelines enables users to build and deploy portable, scalable machine learning workflows. vulnerability
- CVE-2026-119145 Frappe before 15.121.0 and 16.x before 16.34.0 contains a path traversal vulnerability because certain file-upload handling does not… vulnerability
- CVE-2026-77819 IBM Langflow OSS 1.0.0 through 1.12.3 could allow a remote authenticated attacker to overwrite arbitrary files due to improper limitation… vulnerability
- CVE-2026-80067 MasterStudy LMS plugin for WordPress before 3.7.50 contains a path traversal vulnerability that allows authenticated Subscriber-level users… vulnerability
- CVE-2026-80069 MasterStudy LMS plugin for WordPress before 3.7.50 contains a missing authorization vulnerability that allows any authenticated user,… vulnerability
- CVE-2026-84294 Improper limitation of pathname in the Ad Hoc Transfer component of Progress Software WS_FTP Server versions prior to 2024.0.6 and 2025.0.3… vulnerability
- CVE-2026-90864 A path traversal vulnerability in Progress Software WS_FTP Server versions prior to 2024.0.7 and 2025.0.4 on Windows could allow a… vulnerability
- CVE-2026-90866 A path traversal vulnerability in Progress Software WS_FTP Server versions prior to 2024.0.7 and 2025.0.4 on Windows could allow a… vulnerability
- CVE-2026-90871 Improper limitation of a pathname to a restricted directory in Progress Software WS_FTP Server versions prior to 2024.0.7 and 2025.0.4 on… vulnerability
- CVE-2026-93571 Szafir is vulnerable to Path Traversal in the uploaded filename. vulnerability
- CVE-2026-103407 An Improper Limitation of a Pathname to a Restricted Directory vulnerability in ConfigDirector in Juniper Networks Session Smart Router and… vulnerability
- CVE-2026-104743 The Tainacan plugin for WordPress is vulnerable to Directory Traversal in all versions up to, and including, 1.3.0 via the 'tmp_file'… vulnerability
- CVE-2026-105420 Wing FTP Server does not verify user's base folder. vulnerability
- CVE-2026-105457 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability in HAVELSAN Inc. vulnerability
- CVE-2026-107745 The AI Engine – The Chatbot, AI Framework & MCP for WordPress plugin for WordPress is vulnerable to limited media file deletion due to… vulnerability
- CVE-2026-118038 In Progress® Telerik® Document Processing Libraries prior to version 2026.3.1027, a path traversal vulnerability in the Convert and Merge… vulnerability
- CVE-2026-118619 Ultralytics Google Drive Download Path Traversal Remote Code Execution Vulnerability. vulnerability
- CVE-2026-118654 Echo is a Go web framework. vulnerability
- CVE-2026-118667 LangGraph Python SDK is used to connect to running LangGraph API servers, manage assistants, threads and stream runs from Python… vulnerability
- CVE-2026-118680 SiYuan 3.8.7 through 3.8.8 fails to normalize Windows GLOBALROOT device-namespace aliases, bypassing the IsSensitivePath denylist. vulnerability
- CVE-2026-118756 gopass before 1.17.0 contains a path traversal vulnerability in the filesystem storage backend that allows attackers to delete directories… vulnerability
- CVE-2026-15323 The Product Designer for WooCommerce WordPress | Lumise plugin for WordPress is vulnerable to Directory Traversal in all versions up to,… vulnerability
- CVE-2026-59179 OpenHop is a tool for creating interactive data-flow diagrams. vulnerability
Referenced by CWE · can precede (3)
Referenced by CWE · child of (2)
Referenced by CWE · has member (11)
- CWE-1200 Weaknesses in the 2019 CWE Top 25 Most Dangerous Software Errors view
- CWE-1337 Weaknesses in the 2021 CWE Top 25 Most Dangerous Software Weaknesses view
- CWE-1340 CISQ Data Protection Measures view
- CWE-1350 Weaknesses in the 2020 CWE Top 25 Most Dangerous Software Weaknesses view
- CWE-1387 Weaknesses in the 2022 CWE Top 25 Most Dangerous Software Weaknesses view
- CWE-1425 Weaknesses in the 2023 CWE Top 25 Most Dangerous Software Weaknesses view
- CWE-1430 Weaknesses in the 2024 CWE Top 25 Most Dangerous Software Weaknesses view
- CWE-1435 Weaknesses in the 2025 CWE Top 25 Most Dangerous Software Weaknesses view
- CWE-1468 Weaknesses Addressed by the OWASP Golang Secure Coding Practices Guide view
- CWE-635 Weaknesses Originally Used by NVD from 2008 to 2016 view
- CWE-884 CWE Cross-section view