HackBlue

Course · Applications · 09 / 69

Path traversal: when a filename parameter walks out of its folder

How file download and upload features turn user-supplied names into filesystem paths, how traversal sequences and encodings escape the intended folder, what content-discovery tools such as DirBuster and gobuster actually find, and how to fix it with identifiers and canonical path checks.

13 min read · practice only with authorization

Diagram

A download feature resolving a name

Follow the path. One example at a time.
Request

The client names a file to download.

Illustration: Request
GET /download?file=report-2026-10.pdf

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

A short map of the pieces. Each piece says what fails, who is affected, what you would notice, and what you change.

  1. 01Names should be ids
  2. 02Check after decoding
  3. 03Discovery is a different thing

Names should be ids

What fails
When the client sends a filename, the client controls the path.
Who is affected
Owners of any file the service account can read.
What you would notice
Parameters named file, path, template, or page carrying real names.
What you change
Store files under generated names and accept only an id that maps to them.

Check after decoding

What fails
Validation before URL decoding or normalization misses encoded separators.
Who is affected
The same files, through an encoded variant.
What you would notice
A filter that rejects a literal dot-dot but not its percent-encoded form.
What you change
Decode, normalize, resolve, then compare against the base directory.

Discovery is a different thing

What fails
Tools like DirBuster, gobuster, and ffuf guess paths that exist on a web server; they find forgotten files, not traversal.
Who is affected
Owners of backups and admin pages left in the web root.
What you would notice
Directory listings, .bak files, or .git folders served publicly.
What you change
Remove them from the web root and disable directory listing.

Testing it in your lab

Run an intentionally vulnerable app locally and request a file that exists inside the base folder and one you placed just outside it as a canary. If the canary’s content comes back, the feature traverses. Never point traversal tests at system files on a shared host.

# lab setup
echo canary-5521 > /srv/app/canary.txt      # outside /srv/app/reports
# expected safe behavior: requesting the canary by any relative name returns 403 or 404
# finding: the response body contains canary-5521

Content discovery, done within scope

gobuster dir or ffuf with a wordlist, a rate limit, and a scope list finds unlinked paths on an application you are authorized to test. Treat every hit as a question for the owner: is this meant to be public?

$ gobuster dir -u https://staging.example.test -w common.txt -t 10 --delay 100ms
/admin                (Status: 302) [--> /login]
/backup.zip           (Status: 200) [Size: 48211904]
/.git/HEAD            (Status: 200) [Size: 23]

Related pages

Zip Slip covers traversal during archive extraction, and the normalization page covers encodings and platform differences in more depth.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

A filter rejects the literal text ../ before decoding the URL. What does it miss?

Go deeper

Specific techniques, exercises, and glossary cards for this topic.

  1. 01Archive extraction that leaves the directoryA name inside a zip or a similar archive is still a path. Includes the diagram and a defensive fix.
  2. 02Normalize the path before you open itFilters that delete a few character sequences lose to encodings, extra separators, and links. Includes the diagram and a defensive fix.

Exercises

  1. 01Terminal mission: The traversal the filter missedA download endpoint blocks ../ in file names. One request still came back 200 with the size of /etc/passwd. Find the encoding that slipped through and what else it read.
  2. 02Terminal mission: One missing slash in an aliasA location without a trailing slash plus an alias with one lets /assets../ step out of the static folder. Read the config and the log to see what was read through the gap.

Glossary

  1. 01Path traversalA file path built from user input escapes the intended directory and reads or writes elsewhere on the host.