Vulnerability Fixation
Path Traversal Attack

Path Traversal Attack In Applications

Path Traversal, also known as Directory Traversal, is a critical security vulnerability that allows attackers to access files and directories stored outside the intended directory. This can expose sensitive system files, application configurations or even user data, leading to severe security risks.

This exposes the system to replay and automation attacks, where attackers can capture and reuse the same OTP to gain unauthorized access. To prevent this, OTPs should be generated securely on the server side, tied to a specific session or user, and validated only once with proper expiration controls.

Attack

  • The attack occurs when user input for file paths isn’t properly validated.
  • Attackers can use patterns like ../../ to navigate outside the allowed directory and read restricted files.
  • Example: file_path = "/var/www/uploads/" + request.GET['filename']
  • Input like ../../etc/passwd exposes sensitive files such as /etc/passwd.

Impact

  • Access to sensitive files and credentials.
  • System compromise through privilege escalation.
  • Data leaks and regulatory violations.
  • Application crashes due to file tampering.
Solution

  • Sanitize user input; allow only specific filenames/extensions.
  • Restrict file access to safe directories using chroot or permissions.
  • Normalize paths before use to block ../ traversal.
  • Use indirect file references (IDs instead of paths).
  • Enable WAF/IDS and disable directory listing on the server.
  • Keep all frameworks and dependencies updated.

Also Read :