Code RoomPath traversal in file download
MediumPrep Room Coding #4470

Path traversal in file download

Vibe & agenticAlgorithms & data structuresEntry–Mid~13 min

An AI agent wrote this Node.js route to let users download files from a per-user uploads folder. It works for normal filenames. What input would let a user read files they shouldn't, and how do you fix it on review?

Implement
resolve_upload_path(base_dir: str, requested_name: str) → str
Examples
in["/srv/uploads","notes.txt"]out"/srv/uploads/notes.txt"
in["/srv/uploads","../../etc/passwd"]out""
in["/srv/uploads","%2e%2e%2fetc%2fpasswd"]out""
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 13 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.