Log inBook a Demo
SecureMidSecurityAuto-graded

Keep user paths from escaping the base directory

safe_join() should only return paths inside one base folder, but some user-supplied paths still get out.safe_join(base, user_path) in safe_path.py builds the path for files served out of one fixed directory, such as an uploads folder. The base comes from your config. The user path comes from the request and can't be trusted. Crafted requests still get back a path outside the base. Make every escape fail with PathTraversalError and keep normal paths resolving, without touching the real filesystem.
25 min
python

You're done when

  • No user path, in any form, resolves to a location outside the base.
  • Every escape attempt, and any absolute user path, raises PathTraversalError.

What it measures

Application securityKnowing the many forms a path escape can take, beyond the one payload everyone knows.
Security and privacy designDeciding what counts as inside the base and enforcing it for every input.
Fixing without breakingLegitimate paths keep resolving correctly, on any base directory.

Your environment

Terminal + editorA full shell in the browser
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish

Start this lab

25 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo