Skip to content
OpenAdvisories

Weakness (CWE)

CWE-22: Improper Limitation of a Pathname to a Restricted Directory

Base

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.

More detail

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.

How to prevent it (8 mitigations)
  1. 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.

  2. 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.

  3. 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

  4. 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].

  5. 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].

  6. 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.

  7. 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.

  8. 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.

Source: MITRE CWE-22

269 results · Clear filters · Feed

  • High 7.5
    CVE-2024-4956 Public exploit Scanner template EPSS 19%

    Nexus Repository 3 - Path Traversal

    Path Traversal in Sonatype Nexus Repository 3 allows an unauthenticated attacker to read system files. Fixed in version 3.68.1.

  • High 7.5
    CVE-2024-27821 Public exploit

    A path handling issue was addressed with improved validation. This issue is fixed in iOS 17.5 and iPadOS 17.5, macOS So…

  • High 7.8
    CVE-2024-35205 Public exploit

    The WPS Office (aka cn.wps.moffice_eng) application before 17.0.0 for Android fails to properly sanitize file names bef…

  • High 7.8
    CVE-2023-44451 Public exploit

    Linux Mint Xreader EPUB File Parsing Directory Traversal Remote Code Execution Vulnerability

    Linux Mint Xreader EPUB File Parsing Directory Traversal Remote Code Execution Vulnerability. This vulnerability allows remote attackers to execute arbitrary code on affected installations of Linux Mint Xreader. User interaction is required to exploit this vu…

  • High 8.2
    CVE-2023-27326 Public exploit

    Parallels Desktop Toolgate Directory Traversal Local Privilege Escalation Vulnerability

    Parallels Desktop Toolgate Directory Traversal Local Privilege Escalation Vulnerability. This vulnerability allows local attackers to escalate privileges on affected installations of Parallels Desktop. An attacker must first obtain the ability to execute high…

  • High 7.8
    CVE-2024-23774 Public exploit

    An issue was discovered in Quest KACE Agent for Windows 12.0.38 and 13.1.23.0. An unquoted Windows search path vulnerab…

  • High 7.8
    CVE-2024-23773 Public exploit

    An issue was discovered in Quest KACE Agent for Windows 12.0.38 and 13.1.23.0. An Arbitrary file delete vulnerability e…

  • High 8.8
    CVE-2024-32258 Public exploit

    The network server of fceux 2.7.0 has a path traversal vulnerability, allowing attackers to overwrite any files on the …

  • High 7.6
    CVE-2024-32399 Public exploit Scanner template

    Directory Traversal vulnerability in RaidenMAILD Mail Server v.4.9.4 and before allows a remote attacker to obtain sens…

  • High 7.5
    CVE-2023-40279 Public exploit

    An issue was discovered in OpenClinic GA 5.247.01. An attacker can perform a directory path traversal via the Page para…

  • High 8.4
    CVE-2024-1708 Exploited · Ransomware Public exploit Scanner template EPSS 95%

    Improper limitation of a pathname to a restricted directory (“path traversal”)

    ConnectWise ScreenConnect 23.9.7 and prior are affected by path-traversal vulnerability, which may allow an attacker the ability to execute remote code or directly impact confidential data or critical systems.

    KEV Apr 28, 2026
  • High 8.5
    CVE-2024-23673 Public exploit

    Apache Sling Servlets Resolver: Malicious code execution via path traversal

    Malicious code execution via path traversal in Apache Software Foundation Apache Sling Servlets Resolver.This issue affects all version of Apache Sling Servlets Resolver before 2.11.0. However, whether a system is vulnerable to this attack depends on the exac…

  • High 8.5
    CVE-2023-52076 Public exploit

    Remote Code Execution Vulnerability in Atril's EPUB ebook parsing

    Atril Document Viewer is the default document reader of the MATE desktop environment for Linux. A path traversal and arbitrary file write vulnerability exists in versions of Atril prior to 1.26.2. This vulnerability is capable of writing arbitrary files anywh…

  • High 7.5
    CVE-2023-51127 Public exploit

    FLIR AX8 thermal sensor cameras up to and including 1.46.16 are vulnerable to Directory Traversal due to improper acces…

  • High 7.8
    CVE-2024-21633 Public exploit Scanner template

    Arbitrary file write on Decoding

    Apktool is a tool for reverse engineering Android APK files. In versions 2.9.1 and prior, Apktool infers resource files' output path according to their resource names which can be manipulated by attacker to place files at desired location on the system Apktoo…

  • High 7.5
    CVE-2023-28465 Public exploit

    HL7 FHIR Partial Path Zip Slip due to bypass of CVE-2023-24057

    The package-decompression feature in HL7 (Health Level 7) FHIR Core Libraries before 5.6.106 allows attackers to copy arbitrary files to certain directories via directory traversal, if an allowed directory name is a substring of the directory name chosen by t…

  • High 7.5
    CVE-2023-45277 Public exploit

    Yamcs Path Traversal vulnerability

    Yamcs 5.8.6 is vulnerable to directory traversal (issue 1 of 2). The vulnerability is in the storage functionality of the API and allows one to escape the base directory of the buckets, freely navigate system directories, and read arbitrary files.

  • High 8.9
    CVE-2023-42819 Public exploit

    Path traversal in Jumpserver

    JumpServer is an open source bastion host. Logged-in users can access and modify the contents of any file on the system. A user can use the 'Job-Template' menu and create a playbook named 'test'. Get the playbook id from the detail page, like 'e0adabef-c38f-4…

  • High 7.5
    CVE-2022-4244 Public exploit

    Codehaus-plexus: directory traversal

    A flaw was found in codeplex-codehaus. A directory traversal attack (also known as path traversal) aims to access files and directories stored outside the intended folder. By manipulating files with "dot-dot-slash (../)" sequences and their variations or by u…

  • High 7.5
    CVE-2023-39141 Public exploit Scanner template

    webui-aria2 Path Traversal vulnerability

    webui-aria2 commit 4fe2e was discovered to contain a path traversal vulnerability.

  • High 8.1
    CVE-2023-37460 Public exploit

    Plexus Archiver vulnerable to Arbitrary File Creation in AbstractUnArchiver

    Plexis Archiver is a collection of Plexus components to create archives or extract archives to a directory with a unified `Archiver`/`UnArchiver` API. Prior to version 4.8.0, using AbstractUnArchiver for extracting an archive might lead to an arbitrary file c…

  • High 7.5
    CVE-2023-37474 Public exploit Scanner template EPSS 45%

    Path traversal in copyparty

    Copyparty is a portable file server. Versions prior to 1.8.2 are subject to a path traversal vulnerability detected in the `.cpr` subfolder. The Path Traversal attack technique allows an attacker access to files, directories, and commands that reside outside …

  • High 7.5
    CVE-2023-35844 Public exploit Scanner template

    packages/backend/src/routers in Lightdash before 0.510.3 has insecure file endpoints, e.g., they allow .. directory tra…

  • High 7.5
    CVE-2023-35843 Public exploit Scanner template

    NocoDB through 0.106.0 (or 0.109.1) has a path traversal vulnerability that allows an unauthenticated attacker to acces…

  • High 7.8
    CVE-2023-33747 Public exploit

    CloudPanel v2.2.2 allows attackers to execute a path traversal.

  • High 8.8
    CVE-2023-33177 Public exploit

    Xibo CMS vulnerable to Remote Code Execution through Zip Slip

    Xibo is a content management system (CMS). A path traversal vulnerability exists in the Xibo CMS whereby a specially crafted zip file can be uploaded to the CMS via the layout import function by an authenticated user which would allow creation of files outsid…

  • High 7.5
    CVE-2021-27825 Public exploit

    A directory traversal vulnerability on Mercury MAC1200R devices allows attackers to read arbitrary files via a web-stat…

  • High 8.6
    CVE-2023-32315 Exploited Public exploit Scanner template EPSS 100%

    Openfire administration console authentication bypass

    Openfire is an XMPP server licensed under the Open Source Apache License. Openfire's administrative console, a web-based application, was found to be vulnerable to a path traversal attack via the setup environment. This permitted an unauthenticated user to us…

    KEV Aug 24, 2023
  • High 7.5
    CVE-2023-32309 Public exploit

    Arbitrary file inclusion with the pymdowm-snippets extension

    PyMdown Extensions is a set of extensions for the `Python-Markdown` markdown project. In affected versions an arbitrary file read is possible when using include file syntax. By using the syntax `--8<--"/etc/passwd"` or `--8<--"/proc/self/environ"` the content…

  • High 7.5
    CVE-2023-32235 Public exploit Scanner template EPSS 39%

    Path Traversal in Ghost

    Ghost before 5.42.1 allows remote attackers to read arbitrary files within the active theme's folder via /assets/built%2F..%2F..%2F/ directory traversal. This occurs in frontend/web/middleware/static-theme.js.

  • High 7.5
    CVE-2023-25289 Public exploit

    Directory Traversal vulnerability in virtualreception Digital Receptie version win7sp1_rtm.101119-1850 6.1.7601.1.0.657…

  • High 8.8
    CVE-2022-47875 Public exploit EPSS 10%

    A Directory Traversal vulnerability in /be/erpc.php in Jedox GmbH Jedox 2020.2.5 allows remote authenticated users to e…

  • High 7.5
    CVE-2023-31059 Public exploit Scanner template

    Repetier Server through 1.4.10 allows ..%5c directory traversal for reading files that contain credentials, as demonstr…

  • High 7.5
    CVE-2022-34127 Public exploit

    The Managentities plugin before 4.0.2 for GLPI allows reading local files via directory traversal in the inc/cri.class.…

  • High 7.5
    CVE-2023-27856 Public exploit EPSS 77%

    Rockwell Automation ThinManager ThinServer Path Traversal Download

    In affected versions, path traversal exists when processing a message of type 8 in Rockwell Automation's ThinManager ThinServer. An unauthenticated remote attacker can exploit this vulnerability to download arbitrary files on the disk drive where ThinServer.e…

  • High 7.5
    CVE-2023-26255 Public exploit Scanner template EPSS 47%

    An unauthenticated path traversal vulnerability affects the "STAGIL Navigation for Jira - Menu & Themes" plugin before …

  • High 7.5
    CVE-2023-26256 Public exploit Scanner template EPSS 12%

    An unauthenticated path traversal vulnerability affects the "STAGIL Navigation for Jira - Menu & Themes" plugin before …

  • High 7.8
    CVE-2023-20943 Public exploit

    In clearApplicationUserData of ActivityManagerService.java, there is a possible way to remove system files due to a pat…

  • High 8.8
    CVE-2023-22629 Public exploit Scanner template EPSS 12%

    An issue was discovered in TitanFTP through 1.94.1205. The move-file function has a path traversal vulnerability in the…

  • High 7.8
    CVE-2022-4510 Public exploit EPSS 23%

    Path Traversal in binwalk

    A path traversal vulnerability was identified in ReFirm Labs binwalk from version 2.1.2b through 2.3.3 included. By crafting a malicious PFS filesystem file, an attacker can get binwalk's PFS extractor to extract files at arbitrary locations when binwalk is r…