Path Traversal
Path traversal allows attackers to read arbitrary files on the server by manipulating file path parameters with directory traversal sequences.
These payloads are for authorized testing only — systems you own, authorized bug bounty programs, or controlled lab environments. Unauthorized testing is illegal.
What it is
Path traversal (also known as directory traversal) is a web security vulnerability that allows an attacker to read arbitrary files on the server by inserting ../ sequences into file path parameters. This can expose application code, credentials, system configuration files, and sensitive operating system files.
Attack Vectors
- File download functionality with a filename parameter
- File upload functionality with path components
- Template inclusion parameters
- Image and document display features
- Static resource serving with user-controlled paths
Testing Methodology
- Submit ../etc/passwd in file path parameters
- Try URL-encoded variants: %2e%2e%2fetc%2fpasswd
- Test double-encoded: %252e%252e%252fetc%252fpasswd
- Test Windows paths: ..\..\windows\win.ini
- Try null byte injection: ../etc/passwd%00.jpg to bypass extension checks
Payloads
Reference payloads for authorized testing. Always verify you have permission before use.
Indicators of Vulnerability
- /etc/passwd contents or Windows win.ini in response
- Application reads a different file than expected
- Error messages revealing file system paths
Detection Guidance
Monitor for ../ sequences in file path parameters. Log file access attempts. Alert on access to sensitive paths like /etc/passwd or system directories.
Mitigation & Remediation
- Validate file paths against an allowlist of permitted directories
- Use realpath() or equivalent to resolve the canonical path and verify it starts within the allowed directory
- Avoid using user input to construct file system paths
- Apply principle of least privilege to file system access
References
Responsible Use
All content in this reference is for authorized security testing only. Use only on systems you own or have explicit written permission to test.
- Systems and applications you own
- Authorized penetration testing engagements
- Bug bounty programs with defined scope
- Educational lab environments (DVWA, WebGoat, HackTheBox)