Nullify

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Product Security Terms›
Path Traversal

Product Security Terms

Path Traversal

NT
Tim Thacker
November 28, 2026

What Is
Path Traversal
?

Path traversal is a vulnerability in which an application builds a file path from user input without making sure the result stays inside the directory it was meant to use. By sending sequences such as "../" or an absolute path, an attacker can read or overwrite files elsewhere on the server, such as configuration files, credentials or source code.

Also known as:

Directory traversal, dot-dot-slash attack, CWE-22

What Path Traversal Means

Many applications read or write files inside one directory, such as an uploads folder, a template directory or a static asset store. Path traversal happens when the application takes part of a file path from the user and doesn't check that the final path still points inside that directory. MITRE tracks it as CWE-22, Improper Limitation of a Pathname to a Restricted Directory, and notes that it is also called directory traversal. CISA and the FBI call it directory traversal in their Secure by Design guidance.

How a Path Traversal Attack Works

Most operating systems read the sequence ../ as the parent of the current directory. If a handler serves files with code like open("/var/app/uploads/" + filename), a request for ../../../etc/passwd climbs out of the uploads folder and opens a system file instead. MITRE also covers absolute path traversal, where the input is a full path such as /etc/passwd that some path-joining functions use in place of the base directory. Attackers get past simple filters with encoded forms such as %2e%2e%2f, backslashes on Windows, or nested sequences that are still dangerous after a filter strips them once.

Where Path Traversal Shows Up

  • File download and preview endpoints. A parameter that names the file to return is the classic entry point.
  • Upload handlers. A file name taken from the upload request can write the file outside the intended folder or overwrite an existing one.
  • Archive extraction. Entries in a zip or tar file can carry paths with ../ that land outside the extraction directory when they are unpacked.
  • Template, plugin and language loaders. Code that loads a template, theme or locale file by name from a request parameter.
  • CLIs and background jobs. Tools and workers that build paths from job payloads, config values or repository content.

Why Path Traversal Matters

How bad a path traversal flaw is depends on what the attacker can reach. Reading files can expose environment files, cloud credentials, private keys and source code. Writing files can overwrite configuration or drop a script into a directory the server runs, which can lead to remote code execution. CISA and the FBI issued a Secure by Design Alert on directory traversal in May 2024 after threat actors exploited such flaws to compromise software users in critical infrastructure, including healthcare, and directory traversal flaws continue to appear in the CISA Known Exploited Vulnerabilities catalog.

How to Prevent Path Traversal

  • Don't build file paths from user input. CISA recommends generating a random identifier for each stored file and keeping its original name and other metadata separately, for example in a database.
  • If user input must name a file, map it to an allowlist of known files, or strictly limit the characters a file name may contain.
  • Canonicalize the full path with a function such as realpath() and confirm it still starts with the intended base directory before opening the file.
  • Check every entry's path when extracting archives, and reject entries that resolve outside the target directory.
  • Run the service with the lowest file-system privileges it needs, and make sure uploaded files can't be executed.

How Nullify Finds Path Traversal

Nullify code analysis covers path traversal (CWE-22). It tracks file-system access from HTTP handlers, CLIs and background jobs to prevent arbitrary file reads and writes. Its top-down analysis traces user input such as HTTP requests, API calls and file uploads through application logic to find unsafe data flows, and its bottom-up analysis works backward from vulnerable operations to determine whether untrusted data can reach them. Nullify reviews every pull request and every commit on the default branch, so a new unsafe file path is caught before it reaches production. Explore Nullify Code Security.

Key Takeaways

  • Path traversal means an application builds a file path from user input without making sure it stays inside the intended directory.
  • MITRE tracks it as CWE-22, also known as directory traversal.
  • Sequences such as "../", absolute paths and encoded variants let attackers read or overwrite files outside the intended folder.
  • Random file identifiers, allowlists, canonicalizing paths and checking archive entries are the main defenses.

Read More About
Path Traversal

Code Security

See Nullify in Action

Find user input reaching file paths before it ships.

Explore Code Security

Reduce your vulnerability backlog and lower your MTTR

The AI harness that finds, proves and fixes vulnerabilities across your codebase.

Book a demo