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

588 results · Clear filters · Feed

  • 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…

  • Critical 9.8
    CVE-2023-6972 Public exploit

    Backup Migration <= 1.3.9 - Unauthenticated Path Traversal to Arbitrary File Deletion

    The Backup Migration plugin for WordPress is vulnerable to Path Traversal in all versions up to, and including, 1.3.9 via the 'content-backups' and 'content-name', 'content-manifest', or 'content-bmitmp' and 'content-identy' HTTP headers. This makes it possib…

  • Critical 9.3
    CVE-2023-50254 Public exploit

    Deepin Reader RCE vulnerability due to a design flaw

    Deepin Linux's default document reader `deepin-reader` software suffers from a serious vulnerability in versions prior to 6.0.7 due to a design flaw that leads to remote command execution via crafted docx document. This is a file overwrite vulnerability. Remo…

  • 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…

  • Critical 9.8
    CVE-2023-47246 Exploited · Ransomware Public exploit Scanner template EPSS 99%

    In SysAid On-Premise before 23.3.36, a path traversal vulnerability leads to code execution after an attacker writes a …

    KEV Nov 13, 2023
  • 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…

  • Low 3.7
    CVE-2023-5142 Public exploit

    H3C ER6300G2 Config File userLogin.asp path traversal

    A vulnerability classified as problematic was found in H3C GR-1100-P, GR-1108-P, GR-1200W, GR-1800AX, GR-2200, GR-3200, GR-5200, GR-8300, ER2100n, ER2200G2, ER3200G2, ER3260G2, ER5100G2, ER5200G2 and ER6300G2 up to 20230908. This vulnerability affects unknown…

  • Low 3.3
    CVE-2023-41044 Public exploit

    Partial path traversal vulnerability in Support Bundle feature of Graylog

    Graylog is a free and open log management platform. A partial path traversal vulnerability exists in Graylog's `Support Bundle` feature. The vulnerability is caused by incorrect user input validation in an HTTP API resource. Graylog's Support Bundle feature a…

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

  • Medium 4.9
    CVE-2023-40028 Public exploit EPSS 66%

    Arbitrary file read via symlinks in Ghost

    Ghost is an open source content management system. Versions prior to 5.59.1 are subject to a vulnerability which allows authenticated users to upload files that are symlinks. This can be exploited to perform an arbitrary file read of any file on the host oper…

  • Critical 9.8
    CVE-2023-39143 Public exploit Scanner template EPSS 80%

    PaperCut NG and PaperCut MF before 22.1.3 on Windows allow path traversal, enabling attackers to upload, read, or delet…

  • 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…

  • Critical 9.8
    CVE-2023-34478 Public exploit

    Apache Shiro before 1.12.0, or 2.0.0-alpha-3, may be susceptible to a path traversal attack when used together with APIs or other web frameworks that route requests based on non-normalized requests.

    Apache Shiro, before 1.12.0 or 2.0.0-alpha-3, may be susceptible to a path traversal attack that results in an authentication bypass when used together with APIs or other web frameworks that route requests based on non-normalized requests. Mitigation: Update …

  • 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 …

  • Medium 5.0
    CVE-2023-35887 Public exploit

    Apache MINA SSHD: Information disclosure bugs with RootedFilesystem

    Exposure of Sensitive Information to an Unauthorized Actor vulnerability in Apache Software Foundation Apache MINA. In SFTP servers implemented using Apache MINA SSHD that use a RootedFileSystem, logged users may be able to discover "exists/does not exist" in…

  • 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…

  • Medium 6.5
    CVE-2023-35840 Public exploit

    elFinder vulnerable to path traversal in LocalVolumeDriver connector

    _joinPath in elFinderVolumeLocalFileSystem.class.php in elFinder before 2.1.62 allows path traversal in the PHP LocalVolumeDriver connector.

  • Medium 6.5
    CVE-2023-34096 Public exploit EPSS 63%

    Thruk has Path Traversal Vulnerability in panorama.pm

    Thruk is a multibackend monitoring webinterface which currently supports Naemon, Icinga, Shinken and Nagios as backends. In versions 3.06 and prior, the file `panorama.pm` is vulnerable to a Path Traversal vulnerability which allows an attacker to upload a fi…

  • 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…

  • Critical 9.8
    CVE-2022-24629 Public exploit EPSS 37%

    An issue was discovered in AudioCodes Device Manager Express through 7.8.20002.47752. Remote code execution can be achi…

  • 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
  • Critical 10.0
    CVE-2023-2825 Public exploit Scanner template EPSS 72%

    An issue has been discovered in GitLab CE/EE affecting only version 16.0.0. An unauthenticated malicious user can use a…

  • Critical 9.1
    CVE-2022-46945 Public exploit

    Nagvis before 1.9.34 was discovered to contain an arbitrary file read vulnerability via the component /core/classes/Nag…

  • Medium 5.4
    CVE-2023-2745 Public exploit Scanner template EPSS 80%

    WordPress Core < 6.2.1 - Directory Traversal

    WordPress Core is vulnerable to Directory Traversal in versions up to, and including, 6.2, via the ‘wp_lang’ parameter. This allows unauthenticated attackers to access and load arbitrary translation files. In cases where an attacker is able to upload a crafte…

  • 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…

  • Medium 6.5
    CVE-2023-23169 Public exploit

    Synapsoft pdfocus 1.17 is vulnerable to local file inclusion and server-side request forgery Directory Traversal.

  • 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…

  • Medium 4.3
    CVE-2023-28458 Public exploit

    pretalx allows path traversal in HTML export

    pretalx 2.3.1 before 2.3.2 allows path traversal in HTML export (a non-default feature). Organizers can trigger the overwriting (with the standard pretalx 404 page content) of an arbitrary file.

  • Medium 6.5
    CVE-2023-28459 Public exploit

    pretalx vulnerable to path traversal in HTML export

    pretalx 2.3.1 before 2.3.2 allows path traversal in HTML export (a non-default feature). Users were able to upload crafted HTML documents that trigger the reading of arbitrary files.

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

  • Medium 4.9
    CVE-2023-0156 Public exploit EPSS 20%

    All-In-One Security (AIOS) < 5.1.5 - Admin+ Arbitrary File/Folder Access via Traversal

    The All-In-One Security (AIOS) WordPress plugin before 5.1.5 does not limit what log files to display in it's settings pages, allowing an authorized user (admin+) to view the contents of arbitrary files and list directories anywhere on the server (to which th…

  • Critical 9.8
    CVE-2023-29478 Public exploit

    BiblioCraft before 2.4.6 does not sanitize path-traversal characters in filenames, allowing restricted write access to …