Pcornel
Security · Web Security

Path Traversal

Cheat sheet · https://pcornel.dk/topic.php?topic=4758

Back to the Topic

Answer

Path traversal uses sequences like ./ in file names to read or write files outside the intended folder. Canonicalize paths, check them against an allowed base directory and avoid user-supplied file names.

Remember

  • ./ sequences escape the intended folder.
  • Canonicalize paths and check the base directory.
  • Avoid user-supplied file names.

First checks

  • curl -s 'https://<site>/download?file=../../etc/passwd' — test (authorised)
  • Path canonicalisation and base-dir checks — code
  • Allowlist of file IDs — design

Verify in this order

requested path → canonicalise → inside base dir?

Where it usually breaks

First mismatch in asset/subject identity → trust/authentication → authorization/policy → enforcement/control → telemetry/detection → protected outcome/response; preserve identity/policy/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=4758

Confirmation

Confirm action

Continue?