Path traversal meaning, in plain words

Path traversal reads files from folders never made public. How it arises, what it exposes, and why outside values must not name files, per IPA, MITRE and OWASP.

Written by: Mio Kanzaki(Security Analyst (AI))Reviewed by: 千葉圭介Updated

Path traversal is a technique that reads files from folders that were never made public. IPA describes it as a flaw in which a parameter handed in from outside names a file on the server directly, so it can be rewritten to name any file. MITRE's CWE-22 organises it as a weakness where the file reference that should stay inside a given folder can point outside it.

How does path traversal work?

Picture a librarian who fetches books by the shelf number written on a request slip. If the librarian never checks that the shelf is inside the reading room, a slip that says "the staff archive, one floor up" is followed too.

A website behaves the same way when a value from outside decides which file is opened. Download features and features that show images or forms are the typical entrance.

The root fix is to avoid builds in which an outside value names the file directly. IPA points to fixing the folder that is opened and using only the file-name part of the input. As a safeguard, set file access permissions correctly so that files not meant to be public cannot be read. How to check your own site is on the path traversal vulnerability page.

Why does path traversal matter?

IPA lists, as the impact, leaks of personal and other information by viewing files inside the server. It also includes tampering with or deleting configuration files, data files and the program's source code.

Configuration files can hold information that feeds other attacks, such as database connection details. Damage can spread from one file that was read.

The checks themselves hide a trap. When checking symbols, IPA says to watch for evasion by encoding (rewriting symbols in another notation) and to choose when the check is made. Do not rely on simply removing characters.

If you want a first look at what your site shows to anyone outside, the free URL check is free and reads only public information.

Related terms

  • OS command injection: a technique that takes over a server because of how input is handled.
  • SSRF: a technique that uses the server as a stepping stone to reach internal devices.
  • XXE: a technique that abuses XML reading to steal internal files.
  • Vulnerability: the security hole itself; this technique exploits flaws in how file names are handled.

Next step

Check whether the download or image-display features on your site decide the file name from an outside value. How to check and fix it is on the path traversal vulnerability page, and preparation against leaks is in information leak measures. If anything worries you, contact us.

Frequently asked questions

Which files are at risk from path traversal?

Any file that was not meant to be public. IPA lists leaks of important information such as personal data, and tampering with or deletion of configuration files and source code. A configuration file can also lead on to other damage.

Is stripping the symbols out of a file name enough?

No. Symbols can be rewritten in another notation to get around the check, so IPA points to taking care over when the check happens. The root fix is a build in which a value from outside never names a file directly.

Frequently asked questions

Which files are at risk from path traversal?

Any file that was not meant to be public. IPA lists leaks of important information such as personal data, and tampering with or deletion of configuration files and source code. A configuration file can also lead on to other damage.

Is stripping the symbols out of a file name enough?

No. Symbols can be rewritten in another notation to get around the check, so IPA points to taking care over when the check happens. The root fix is a build in which a value from outside never names a file directly.

See what an attacker can see, today

The free URL check returns a grade in under a minute. For costs and next steps, book a free consultation.