Agent sandbox
Also known as: sandboxing
A walled-off space where an AI agent runs code and uses tools, so a mistake or trick cannot reach the rest of your systems.
Draft - this entry has not been reviewed yet.
Formal
A closed-off place to run code - often a container or small virtual machine - in which an agent's commands execute with only chosen folders, network destinations and rights, and which is thrown away after the task.
In plain English
Like letting a new cook practise in a test kitchen instead of the restaurant - if they set the pan on fire, only the test kitchen gets burnt.
In practice
A developer in a region's IT department lets a coding agent run tests inside a fresh container that sees only the booking app's folder and cannot reach the internet; when the task ends, the container is deleted.
Why it matters
No one can promise an agent will never be tricked or wrong, so limiting what it can touch is what turns a possible disaster into a small failure that goes no further.
Technical deep dive
An agent sandbox is a containment boundary for code whose behaviour is chosen at runtime by a model that can be wrong or manipulated. The threat model therefore assumes that any command inside the boundary may be hostile, and the design question is what that command can read, write, execute and reach over the network. Isolation strength forms a spectrum. Process-level sandboxes apply kernel policy to an ordinary process: seccomp-bpf syscall filters and Landlock on Linux, unprivileged namespace tools such as bubblewrap, and the Seatbelt framework on macOS. Containers add namespaces and cgroups but still share the host kernel, so a kernel vulnerability can become an escape, a limitation NIST SP 800-190 discusses at length. gVisor interposes a user-space kernel that services most syscalls itself, and microVMs such as Firecracker give each workload its own KVM guest kernel while booting in around 125 ms with a few MiB of memory overhead, which is why many hosted code-execution services use them.
The filesystem policy usually mounts only the working directory read-write, keeps system paths read-only, and deliberately omits credential locations such as ~/.ssh, ~/.aws or browser profiles. Network policy is typically default-deny egress with an allowlist enforced by a proxy, since blocking only by IP misses DNS-based exfiltration and CDN-hosted endpoints. Credentials that the task genuinely needs should be short-lived and narrowly scoped, and some designs never expose them inside the sandbox at all, letting the egress proxy inject them into requests to approved hosts. Ephemerality matters as much as walls: a fresh sandbox per task prevents persistence, and snapshots make it cheap to reset.
Claude Code's sandboxed Bash tool illustrates a local implementation: it uses Seatbelt on macOS and bubblewrap plus a socat-relayed proxy on Linux and WSL2, allows writes to the working and session temp directories by default, and restricts egress to allowed domains. Notably, if dependencies are missing it warns and runs unsandboxed unless configured to fail closed, a detail auditors should check.
Common misconceptions: a sandbox does not stop prompt injection, it bounds its blast radius; and it does not neutralise misuse of channels it allows. An agent permitted to push to GitHub can exfiltrate through a commit, and code written inside the sandbox may plant a malicious git hook or CI step that executes later outside it. The sandbox is thus the enforcement mechanism for least privilege, complementary to human-in-the-loop approval, and it reduces the approval fatigue that arises when every command needs a click.
What to learn first
Everything this builds on, foundations first.
- Token
- →Transformer
- →Large language model (LLM)
- →Prompt
- →AI agent
- →Agent sandbox
Relationships
- Requires
- AI agent
- Mitigates
- Excessive agencyPrompt injection
Sources & further reading
Standards & official texts
- NIST SP 800-190 - Application Container Security Guide · NIST
Official documentation
Reference works
- OWASP Top 10 for LLM Applications 2025 (LLM06 Excessive Agency) · OWASP
Where this data comes from
This entry was drafted by an AI from the sources above and has not yet been checked by a person. Treat it as a starting point, and check anything important against the sources.
See the review queueSuggest a correction on GitHubThis term as JSON
Check yourself
Loading…