Menu

πŸ—‚οΈ Path Traversal: Why Your ../ Filter Fails (and the Fix That Holds)
πŸ“°

πŸ—‚οΈ Path Traversal: Why Your ../ Filter Fails (and the Fix That Holds)

DEV Community: appsecΒ·Krishna KumarΒ·14 days ago
#mMnACypA
#devtoappsec#devto#dev#path#file
Reading 0:00
15s threshold

Somewhere in most web apps there's an endpoint like GET /download?file=report.pdf . The code takes the filename, sticks it onto a folder path and reads the file. It works, the tests pass, and nobody looks at it again.

Then someone sends ?file=../../../etc/passwd , and the "download" endpoint turns out to read any file the app's process can open.

Path traversal is old, well documented and still everywhere, mostly because the first fix people reach for, removing ../ from the input, doesn't work. This article covers where the bug hides, how to prove it without pulling anything sensitive, the five ways common filters fail, and a fix that holds, with code I've run.

Only test applications you own or are explicitly authorized to test. Every example here uses stand-ins like app.example.com and /srv/app/downloads .

What it is

Path traversal (also called directory traversal) happens when user input ends up in a filesystem path and the app doesn't stop it pointing outside the folder it was meant for.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.