Security Objective
Sandboxing and containment limit the effects of code, tools, interpreters, browsers, document processors, sub-agents and other potentially influenced execution by placing them behind deterministic isolation and resource boundaries outside the model. The objective is not to prevent influence. It is to make sure that influenced execution can only touch what the boundary allows.
Threat Model
Prompt injection can change what an agent proposes, and some proposals lead to execution: a generated script, a parser run on an untrusted file, a browser session on an unknown page, or a delegated sub-agent. Detection may miss the influence, and authorization may correctly allow the execution because the task legitimately requires it. Containment assumes that some influenced execution will run and limits what it can reach.
Reading or changing files outside the task workspace.
Access to ambient secrets, tokens or configuration the task does not need.
Influence over other processes, the runtime or the host.
CPU, memory, process or disk consumption that affects other work.
Connections that bypass the separate egress layer.
State that survives into another user's, tenant's or run's execution.
A contained denial does not prove malicious intent. It proves that the attempted effect was outside the boundary.
What a Sandbox Is and Is Not
| A sandbox is | A sandbox is not |
|---|---|
| An isolation boundary around execution | A trust oracle for what ran inside it |
| A cap on filesystem, process, resource and network effects | A permission grant for the action that started it |
| One place where least-privilege limits are enforced | The decision about which capabilities exist |
| Enforced deterministically outside the model | A classifier verdict or model self-assessment |
| A way to make failures cheap | Proof that an artifact is safe to release |
Separate Control Planes
| Question | Owning control | Relation to containment |
|---|---|---|
| May this resolved action execute | Agent authorization | Decided before execution; the sandbox does not authorize |
| Which identities, credentials, tools and capabilities exist | Least privilege | Sets the budget the sandbox enforces |
| Which network paths exist | Network / egress restrictions | Still required when the sandbox has networking |
| May this data cross into or out of the sandbox | Information flow control | Isolation is not a data-release decision |
| How far can effects of this execution reach | Sandboxing / containment | This page |
Keep these as separate decisions with separate evidence. Do not collapse trust, authorization, reachability, information flow and containment into one score.
Architecture Placement
Place containment around components that execute or interpret content whose behavior the application cannot fully predict: code interpreters, generated scripts, shell-like tools, browsers and renderers, document and archive processors, media decoders and delegated sub-agents or tool workers.
The execution itself stays untrusted even inside the boundary. The boundary, its policy and its release gate are application-owned.
Isolation Choices and Trade-offs
| Option | Typical properties | Considerations |
|---|---|---|
| Separate process and unprivileged user | Low overhead; shares the host kernel | Suited to lower-risk, well-understood workloads |
| Container | Namespaces and control groups; shares the host kernel | Strength depends heavily on configuration; not a virtual machine |
| MicroVM or virtual machine | Separate guest kernel behind a hypervisor | Stronger separation, more startup and operating cost |
| Dedicated worker or workload | Separate host, account or service identity | Limits shared state and credentials; highest cost |
No single technology is universally sufficient. A container is not a virtual machine, and a virtual machine with broad mounts, credentials and networking can still expose far more than intended. The configuration and the surrounding controls determine the effective boundary.
Per-Task and Per-Run Isolation
Where practical, provision a fresh environment per task or run. Never share a sandbox, workspace or cache across users or tenants. Shared long-lived sandboxes let influenced execution in one task leave state that affects another.
Filesystem Containment
Filesystem posture
- Ephemeral workspace created for the task and destroyed afterwards
- Inputs mounted read-only where possible
- Minimal writable mounts, limited to scratch space
- No broad host mounts and never the host root
- No container runtime or orchestration control socket by default
- A narrow, dedicated export directory if results must leave
A path that is not mounted does not exist for the workload. That is stronger than a rule that tells the workload not to read it.
Process and Operating System Containment
Run workloads as a non-root or otherwise unprivileged identity with reduced capabilities. Apply system-call or process policy where the platform supports it, use a separate process namespace where applicable and do not let the workload inherit host environment variables, credentials or handles. NIST SP 800-53 SC-39 describes maintaining separate execution domains for processes; this page applies that general principle to agent execution.
Resource Limits
Bounded share or quota per workload.
Hard ceiling with termination on breach.
Maximum process or thread count.
Bounded scratch and export size.
Timeout for the whole run.
Caps on produced data and on spawned sub-work where relevant.
Exhaustion should terminate the task with evidence, not take down the host or neighbouring workloads. Exhaustion alone is not evidence of malicious intent.
Network Posture
Workloads that do not need a network get none. Where networking is required, route it through brokered, separately controlled network and egress restrictions. A sandbox must not provide a direct path around the egress layer, and having networking inside a sandbox does not decide which destinations are reachable.
Secrets and Credentials
Do not place broad production secrets in the sandbox, its environment, its filesystem or the model context. When a task genuinely needs a credential, issue a task-scoped, short-lived one and revoke or let it expire when the task ends. A credential that was never provided cannot be exposed by influenced execution. This is engineering guidance that follows from least privilege, not a quotation from a cited source.
IPC, Local Services, Metadata and Management Planes
Isolate or block inter-process channels, local host services, cloud metadata endpoints and management planes unless the workload explicitly requires them. These interfaces often carry credentials or control functions and can turn a contained workload into an uncontained one.
Browser and Document-Processing Workers
Browsers, renderers and document or archive processors handle content whose origin the application does not control, including documents and retrieved pages. Run them in isolated workers and treat rendered content, extracted text and produced artifacts as untrusted. Browser isolation limits what rendering can affect; it is not authorization for anything the page asks the agent to do.
Sub-Agent and Tool-Worker Containment
Delegated workers run with their own bounded environment and cannot inherit broader capabilities than the delegation intended. Their results return as variable data, the same as tool output, and do not carry the parent's authority.
Artifact Export and Release Boundary
Anything leaving the sandbox crosses a separate release boundary. Export requires independent authorization for the resulting action, information flow checks for the data, output validation of structure and format and, where applicable, content scanning. Containment does not make outputs semantically safe.
Lifecycle and Reset
Start from a fresh or reliably reset state, clean up after completion and destroy ephemeral environments. Persistence across runs is avoided unless explicitly required, scoped and governed, and even then it is treated as untrusted input for the next run.
Fail-Closed Behavior
If required containment cannot be provisioned or its policy cannot be enforced, protected execution does not run. It never silently falls back to unrestricted host execution. Record SANDBOX_UNAVAILABLE and surface the failure.
Relationship to Other Controls
| Control | Decides | What containment adds |
|---|---|---|
| Agent authorization | Whether a resolved action may execute | Caps effects if an authorized execution is influenced |
| Least privilege | Which capabilities exist at all | One enforcement point for that budget |
| Network / egress restrictions | Which network paths exist | Removes direct bypass paths from the workload |
| Information flow control | Whether data may cross into or out of the sandbox | Nothing; isolation is not a release decision |
| Output validation | Structure and format of artifacts and values | Nothing; contained output is not semantically safe |
| Detection, tool-chain analysis, plan drift | Whether behavior looks suspicious | A boundary that holds even when detection misses |
Tool-chain analysis and plan drift detection may flag suspicious sequences or deviations, but the containment boundary remains deterministic and enforceable without them.
Policy, Versioning and Exceptions
Containment policy is versioned configuration: image or runtime version, mounts, network mode, limits and credential rules. Exceptions carry an explicit owner, scope and expiry. Model output never grants an exception or widens a sandbox.
Observability, Evidence and Reason Codes
Containment record fields
- Task, run and workload identity, and initiating principal
- Image or runtime version and containment policy version
- Mounts, network mode and resource limits applied
- Start and stop times and termination or kill reason
- Export attempts, release decision and artifact hashes or IDs where appropriate
Execution was suggested. Nothing ran.
Execution or an effect was denied by policy.
The workload ran inside the boundary.
The run was stopped, for example on a limit.
The run finished. Its output is still untrusted.
An artifact passed the separate release gate.
Example reason codes, as engineering guidance and not a standard: FILESYSTEM_PATH_DENIED, NETWORK_DISABLED, RESOURCE_LIMIT_EXCEEDED, PROCESS_POLICY_DENIED, SECRET_NOT_AVAILABLE, EXPORT_REQUIRES_RELEASE and SANDBOX_UNAVAILABLE.
Worked Scenario A: Read-Only Document Processing
A user asks for a summary of an archive, quarterly-report.example.zip. Extraction and parsing run in an ephemeral workspace with the archive mounted read-only, no network and bounded scratch space. Execution is allowed inside the sandbox. The extracted text remains untrusted, and any file meant to leave waits for release checks.
Worked Scenario B: Generated Helper Script
The agent generates a helper script to reformat a table. It runs in a no-network worker with read-only input and bounded scratch space. It is allowed to run inside the sandbox. This does not mean the script is trusted, correct or safe to run elsewhere.
Worked Scenario C: Host-Only Secret Path Denied
Code in the sandbox attempts to read a host-only path, represented as /host-secrets/service.example, that is not mounted. The access fails at the filesystem and capability boundary with FILESYSTEM_PATH_DENIED. No secret was exposed, and the event alone does not establish intent.
Worked Scenario D: Resource Quota Exceeded
A workload exceeds its memory or process quota, or its wall-clock timeout. It is terminated with RESOURCE_LIMIT_EXCEEDED and the limit that triggered. The host and other workloads continue. The run is not labeled malicious solely because it exhausted resources.
Worked Scenario E: Export Held for Release
The sandbox produces report-draft.example.csv and proposes sending it to records.partner.example.test. Export is held with EXPORT_REQUIRES_RELEASE until independent authorization, information flow control, output validation and release policy pass. Nothing has been exported while it is held.
What the Scenarios Prove and Do Not Prove
| Scenario | Shows | Does not show |
|---|---|---|
| A: document processing | Parsing can run with read-only input and no network | That extracted content is trusted |
| B: helper script | Generated code can run inside a bounded worker | That the script is correct or trusted |
| C: host secret path | Unmounted paths are unavailable | That a secret was exposed or an attack intended |
| D: resource quota | Exhaustion terminates the task, not the host | That the workload was malicious |
| E: export held | Results need a separate release decision | That the artifact or destination is approved |
Testing and Validation
| Test class | Expected result |
|---|---|
| Host path access | Unavailable |
| Network in a no-network sandbox | Unavailable |
| Resource quota breach | Task terminated with evidence |
| Write to a read-only input | Denied |
| Broad production credential | Absent from environment and filesystem |
| Direct host process access | Unavailable |
| Artifact export | Requires the release gate |
| Reset between tasks | No prior task state present |
| Sandbox provisioning failure | Protected execution fails closed |
These tests verify that the boundary holds. They are not a catalogue of isolation-escape techniques, and this page intentionally contains none.
Metrics
| Metric | Denominator |
|---|---|
| Sandbox coverage | Executions of workloads classified as requiring containment |
| Successful isolation-test rate | Labelled isolation regression tests |
| Unexpected host-access blocks | Contained runs |
| Resource-limit terminations | Contained runs |
| Export-gate coverage | Artifacts leaving sandboxes |
| Network-disabled compliance | Runs of workloads classified as no-network |
| Ephemeral reset coverage | Contained runs |
| False-block rate and benign task success | Labelled benign tasks |
| Exception usage and expiry compliance | Contained runs and active exceptions |
| Containment provisioning failure rate | Provisioning attempts |
These are operational measures, not proof of security. Do not combine them into one score.
Common Mistakes
- 01Trusting sandboxed output
Releasing results because they came from a sandbox.
- 02Broad host mounts
Exposing host directories or the host root to the workload.
- 03Runtime control socket exposure
Mounting a container runtime socket into the workload.
- 04Broad production credentials
Ambient secrets in environment, files or context.
- 05Unrestricted networking
Networking without a separate egress layer.
- 06Shared state
Reusing environments across tenants, users or runs.
- 07Missing resource limits
No caps on CPU, memory, processes, disk or time.
- 08Export without release checks
Artifacts leave without authorization, flow and validation checks.
- 09Silent fallback to the host
Running unrestricted when the sandbox is unavailable.
- 10Assuming a container is a secure sandbox
Relying on a label instead of configuration and risk.
- 11Confusing detection with containment
Relying on a detector instead of an enforceable boundary.
Implementation Checklist
Before relying on containment
- High-risk execution runs in an isolation technology chosen by risk
- Environments are per task or run and never shared across tenants
- Inputs are read-only, writable mounts are minimal, no host root or runtime socket
- Workloads run unprivileged with reduced capabilities and no inherited credentials
- CPU, memory, process, disk, time and output limits are set
- Network is off by default or brokered through separate egress control
- Credentials are absent or task-scoped and short-lived
- Exports pass a separate release gate
- Provisioning failure fails closed
- Policy is versioned; exceptions have owner, scope and expiry
Standards and Sources
Standards and guidance referenced
- NIST
- SP 800-53 Rev. 5 SC-39 Process Isolation, SP 800-53 Rev. 5 AC-6 Least Privilege and SC-7 Boundary Protection (boundaries only), SP 800-190 Application Container Security Guide
- OWASP
- Top 10 for Agentic Applications 2026 (risk context), LLM01:2026 Prompt Injection
Source scope: NIST SC-39 is general process-isolation guidance, and AC-6 and SC-7 are cited only to mark the boundaries to least privilege and network boundary protection. NIST SP 800-190 is general container security guidance published in 2017; it predates modern LLM agents and does not address them. The OWASP agentic list provides risk context for agent and tool misuse, and LLM01:2026 is prompt-injection risk context only. No cited source defines sandboxing / containment as a complete AI-agent control standard. Isolation choices, reason codes, record fields, scenarios and metrics on this page are engineering guidance.
Frequently Asked Questions
Does running in a sandbox make output trusted?
No. Output remains variable data and needs separate release checks.
Does a sandbox authorize the action?
No. Agent authorization decides whether a resolved action may execute.
Is a container a secure sandbox?
Not by label. Its strength depends on configuration and on the surrounding controls, and it shares the host kernel.
If the sandbox has networking, is egress handled?
No. Network and egress restrictions still decide which paths exist.
Does a resource-limit termination prove an attack?
No. It proves the run exceeded its limits.
What happens if the sandbox cannot start?
Protected execution fails closed and does not fall back to the host.
References
- NIST SP 800-53 Rev. 5, Security and Privacy Controls for Information Systems and Organizations (SC-39, AC-6, SC-7)NIST · StandardReviewed 2026-09-27
- NIST SP 800-190, Application Container Security GuideNIST · Standard · 2017-09Reviewed 2026-09-27
- OWASP Top 10 for Agentic Applications for 2026OWASP GenAI Security Project · Guidance · 2025-12Reviewed 2026-09-27
- OWASP GenAI LLM Top 10 2026 (LLM01:2026 Prompt Injection)OWASP GenAI Security Project · GuidanceReviewed 2026-09-27