Vulnerability class

How to prove path traversal, and verify the fix holds after normalisation

Updated

Path traversal is proven when a filename parameter reads or writes a file outside the intended directory. The fix is to resolve the path to a canonical absolute path and confirm it still sits under the base directory — verified after every decode layer.

Where this class of bug actually lives in file paths built from user input

  • Downloads. /download?file=report.pdf with the value concatenated onto a base directory.
  • Uploads. A client-supplied filename written with path.join(dir, name), which escapes dir on ../.
  • Archives. A zip entry named ../../etc/cron.d/x extracted without checking the resolved target — zip slip.
  • Double encoding. %252e%252e%252f decodes twice inside the app and becomes ../.

What to try first

  1. Send ../../../etc/passwd, then the URL-encoded and double-encoded forms, to every file parameter.
  2. Try an absolute path: /etc/passwd, which many join implementations honour.
  3. Upload a file named ../../public/x.html and see whether it lands outside the upload directory.
  4. Extract an archive containing a ../ entry if the app accepts uploads.

A reproduction you can keep

Encoded variants are where the filter usually fails:

Traversal with encoding variants
for f in \
  '../../../etc/passwd' \
  '..%2f..%2f..%2fetc%2fpasswd' \
  '%252e%252e%252f%252e%252e%252f%252e%252e%252fetc%252fpasswd' \
  '/etc/passwd'; do
  echo "== $f"
  curl -sS --get 'https://staging.example.com/download' --data-urlencode "file=$f" | head -2
done

# vulnerable: root:x:0:0 in the response
# fixed: 400 or 404, and no path outside the base is read

What "fixed" has to look like

Resolve the joined path, normalise it, and check the result is still a child of the base directory using a real path comparison rather than a string prefix. Verify all four payloads above, and confirm the double-encoded form is rejected at the layer that decodes last.

Where people get this wrong

  • Rejecting .. as a substring is bypassed by encoding and by absolute paths.
  • A string startsWith(baseDir) check passes for a sibling directory named baseDir-evil.
  • Validating once before a second decode step is the same as not validating.

What Offense does here

Offense runs an agent swarm against your app in a disposable sandbox, keeps the request, the identity and the vulnerable response as evidence, and replays the same attack after the fix so the retest is a control comparison rather than a green check. It does not read your source and it does not patch your code: the finding goes to your coding agent with the reproduction attached. The hosted workspace is invite-only — join the waitlist — and the free dependency audit in /install needs no account.

Questions this page answers

What is the correct path traversal fix?

Canonicalise to an absolute real path and assert containment under the base directory, after all decoding. String filters on .. are bypassable.

Is path traversal only a read bug?

No. On an upload or extract path it writes, which is often remote code execution once the file lands somewhere served or executed.

Written by Offense Research, reviewed December 2, 2026. Correct something? Email imran@offenseresearch.com.