Skip to content
uencoder

Path Traversal

Path traversal is attackers using ../ sequences to escape the intended directory and access arbitrary files; a common vulnerability in file operations.

Purpose

To understand arbitrary file read/write caused by path traversal and the defenses; a common defect in file upload/download.

Mechanism

The program concatenates base_dir + user_filename; the attacker enters ../../etc/passwd to escape base_dir. Defenses: resolve the path with path.resolve and check it stays inside base_dir, basename, whitelists.

Use cases

  • File operation security
  • Path validation
  • Directory restriction

Related tools

References