Filesystem Isolation
In this article
- Choose which directories a sandboxed run may read and write, and keep host secrets out of its view.
- Check a file path by resolving it first and comparing the result with an allowed root.
- Predict whether a path with `..` steps or a symbolic link stays inside its root or escapes it.
- Explain why a path check still needs narrow mounts behind it.
- Terms defined here: workspace, path traversal, symlink escape.
Overview
Code that a model writes can type any file path it likes. Ask it to clean a spreadsheet and it may, by mistake or because a hidden instruction steered it, try to open a password file, an SSH key or a .env full of secrets on the machine it runs on. [4] A polite line in the prompt does not stop it, because what the model does is not a security control. [4]
Here you set up the directories a run is allowed to touch, write the check that decides whether a path actually lies inside them, and watch two classic escape tricks fail: a path that climbs out with .., and a link that points outside. You also see why the check alone is not enough, and what sits behind it.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- What the run can see
- Two ways out
- Resolve first, then compare
- The same rule in sandbox-runtime
- Why the mounts still matter
- The rule at work
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions