Skip to main content
Module 6 · Lesson 1 of 420/42 in the course~15 min
Module lessons (1/4)

Path Traversal (../) in File Servers

Lesson preview6 hands-on exercises readyApplication & Web Security · Module 6 — Input Validation, Path Traversal, ReDoS & SSRF

Bypass naive string replacement filters, then enforce canonical path resolution pinned strictly inside a base directory.

What you'll learn in this lesson

  • Exploit weak non-recursive .replace('../', '') sanitizers using nested payloads such as ....//.
  • Explain why resolved.startsWith('/srv/uploads') without a trailing '/' falls for sibling folders (/srv/uploads-secret).
  • Implement canonical POSIX path resolution (decodeURIComponent + null-byte rejection + extension allowlisting) pinned strictly inside rootDir + '/'.

Overview

File download handlers routinely read a query parameter (?file=report.pdf) and join it onto a storage root such as /srv/uploads. Two classic implementation mistakes expose /etc/passwd or .env: naive substring replacement that leaves behind newly formed ../ sequences, and containment checks missing a trailing directory separator.

Trace four real-world failure modes and their canonical defense:

Sections covered in this lesson

  1. 11. Non-Recursive Replacers, Prefix Traps & Canonical Containment
  2. 22. Interactive Explorer: Canonical URL & Path Confusion
  3. 33. Progressive Labs: Warm-Up → Attack → Defend → Harden
  4. 44. Checkpoints & Code Review
Pro Lesson · Module 6 — Input Validation, Path Traversal, ReDoS & SSRF

Unlock "Path Traversal (../) in File Servers" and the full Application & Web Security curriculum

Bypass naive string replacement filters, then enforce canonical path resolution pinned strictly inside a base directory.

Unlock all 6 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Application & Web Security plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.