# Path Traversal

> Adding ../ to a file name to climb out of the folder an app should use.

**Field:** Software Development  
**Category:** Security  
**Also known as:** Directory Traversal, Dot-Dot-Slash Attack

## Think of it like

Think of it like a note that says go back two rooms and bring the safe.

## Definition

Path traversal tricks an app into opening files outside the folder it should use. The app builds a file path from user text. The attacker adds ../, which means one folder up. With enough of them, the path climbs out to secret files on the server. The fix is to check that the final path stays inside the allowed folder, or to use a fixed list of names.

## Example

A site shows a picture when you ask for cat.png. An attacker asks for ../../../etc/passwd and gets a server file back instead.

## Example code

```http
GET /view?file=../../../etc/passwd HTTP/1.1
Host: example.com
```

Each ../ climbs one folder up, out of the picture folder and into the system.

## Why it matters

Server files hold passwords, keys and settings. One leaked file can open the whole system.

## Common mistake

Removing ../ from the text once. A trick like ....// leaves a fresh ../ behind after the cut.

## Three principles

- **Climb with ../.** Each one goes a folder up.
- **Check the final path.** It must stay in its folder.
- **Prefer fixed names.** Map each choice to a known file.

## Related terms

- [File Path](https://learn.benibix.com/term/development/file-path)
- [Directory](https://learn.benibix.com/term/development/directory)
- [Input Validation](https://learn.benibix.com/term/development/input-validation)
- [Broken Access Control](https://learn.benibix.com/term/development/broken-access-control)
- [Security Vulnerability](https://learn.benibix.com/term/development/vulnerability)

![A table of four attacks, with what the attacker sends and what goes wrong. SSRF sends preview?url=http://10.0.0.5/admin, and the server fetches its own private page. Path traversal sends view?file=../../../etc/passwd, and a server file is sent back. Broken access control asks for /orders/1042, not his own, and a stranger's order is shown. Remote code execution, lit up, sends a booby-trapped upload or request, and the attacker's code runs on the server.](https://learn.benibix.com/diagrams/dev2-server-attacks.svg)

---

Source: https://learn.benibix.com/term/development/path-traversal
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
