Case BB5C80 · Web AppSec · L1 Foundations
Path Traversal
- 01 What is it?
- 02 How is it abused?
- 03 How do you stop it?
What a strong answer covers
Try it out loud first. Then check yourself:
- User input used in a file path escapes the intended folder with ../ sequences, e.g. ?file=../../etc/passwd
- Filters are bypassed with URL or double encoding, absolute paths, and backslashes on Windows; reads can expose config and keys
- Zip Slip: archive entries named ../../app/x.jsp write outside the extract folder, turning traversal into code execution
- Best fix: never pass user input to the filesystem; map an ID to a server-side path or use an allowlist of names
- Otherwise canonicalize (realpath) then verify the result still starts with the base directory, and run with least privilege
If the interviewer pushes back
- Why is stripping ../ from the input before use not a safe fix?
- How does path traversal differ from local file inclusion in PHP, and when does LFI become RCE?