Part 11 of 13 · 1 min read
Quick notes
- A sandbox limits what code can touch even when you cannot trust it. Agents run model-written code and open model-chosen paths and URLs, so treat those inputs as hostile and enforce limits outside the model.
- Four layers, each assuming the previous failed: validate arguments, limit the process, isolate it (container or microVM) and control the network with an allowlist.
- Naive checks fail in testable ways.
startswith(root)lets most path escapes through;realpathpluscommonpathlets none through. A parsed-host allowlist beats any string check on URLs, and a program-plus-argument allowlist beatsstartswith("ls")on commands. - Process limits really work: a CPU limit killed an infinite loop in about a second, a memory limit raised
MemoryError, a file-size limit stopped a large write, and a scrubbed environment hid a secret from the child. - Limits are not isolation. A limited process can still read any file the user can read and open network connections; only a boundary stops data access. Check-then-use races (TOCTOU) remain.