Part 8 of 13 · 1 min read
How to build it so it holds up
- Run model-written code in a boundary that does not trust it: separate container or microVM, non-root user, read-only root, a writable scratch directory, no host mounts.
- Deny network by default; if needed, route through a proxy with a host allowlist, and log requests.
- Scrub the environment: pass only the variables the task needs; never inherit secrets.
- Set limits on CPU, memory, file size, process count and wall clock, and kill the whole process group on timeout.
- Confine file tools with
realpathpluscommonpathagainst a resolved root, reject null bytes, and prefer opening relative to a directory descriptor withO_NOFOLLOW. - Validate URLs by parsing, and re-validate after each redirect and DNS resolution (rebinding), or block internal ranges at the network layer.
- Allowlist commands and arguments; prefer purpose-built tools to a general shell.
- Make the sandbox disposable: one per task or session, destroyed afterwards, so persistence is limited.
- Log and alert on denials (module 9).