A Debian-first guide to detecting attempts to escape intended directories, reviewing sensitive file targeting, and reducing filesystem exposure in web applications.
Path traversal is an attack that attempts to access files outside the intended directory or web root by manipulating file paths.
Attackers often use sequences like ../, encoded traversal strings, or alternate path syntax to reach sensitive files.
Common targets include application configs, environment files, SSH keys, passwd files, logs, backups, and source code.
../ or encoded traversal patterns/etc/passwd, config files, or backupssudo journalctl -u caddy --since "1 hour ago"
sudo grep -Ei "\.\./|%2e%2e|/etc/passwd|/proc/self|/root/|/home/" /var/log/caddy/*.log 2>/dev/null | tail -n 100
sudo grep -Ei "file=|path=|download=|template=|doc=|view=" /var/log/caddy/*.log 2>/dev/null | tail -n 100
sudo awk '{print $1}' /var/log/caddy/*.log 2>/dev/null | sort | uniq -c | sort -nr | head
sudo find /var/www -maxdepth 4 -type f | less
sudo ufw deny from <IP_ADDRESS>
# Limit or disable the vulnerable file-handling path while investigating
sudo find /var/www -type f \( -name ".env" -o -name "*.bak" -o -name "*.old" -o -name "*.zip" \)
sudo find /var/www -type f | less
# Review how the application resolves user-supplied file paths
sudo grep -Ei "Accepted|sudo|login|auth" /var/log/auth.log
sudo journalctl --since "24 hours ago"
Recovery means verifying whether traversal attempts stayed unsuccessful or whether they exposed real files, secrets, or application internals.
# Do not trust user-supplied file paths directly
sudo find /var/www -type f | less
sudo find /var/www -type f \( -name "*.bak" -o -name "*.old" -o -name "*.zip" \)
sudo journalctl -u caddy --since "24 hours ago"
sudo apt update
sudo apt upgrade
Manual review of logs, file exposure, and application path handling should come first. Future recommendations may include tooling that improves visibility, but the best protection is keeping sensitive content out of reach and avoiding unsafe path resolution.
All commands shown are based on Debian-based systems unless otherwise noted.