Defense control

Sandboxing / Containment

How deterministic isolation and resource boundaries outside the model cap the effects of code, tools, interpreters, browsers, document processors and sub-agents. Containment limits blast radius: it does not make output trusted and does not authorize any action.

By Norbert HofmannPublished: 2026-09-27Last reviewed: 2026-09-27Level: AdvancedAudience: Security Engineers, Developers, AI Engineers
Control family
Containment and recovery
Control type
Limiting / preventive
Enforcement
Deterministic, at isolation and resource boundaries outside the model
Core question
If this execution is influenced, how far can its effects reach
Level
Advanced
Table of contents

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.

01
EffectHost filesystem reach

Reading or changing files outside the task workspace.

02
EffectCredential exposure

Access to ambient secrets, tokens or configuration the task does not need.

03
EffectProcess and host control

Influence over other processes, the runtime or the host.

04
EffectResource exhaustion

CPU, memory, process or disk consumption that affects other work.

05
EffectUnbounded network reach

Connections that bypass the separate egress layer.

06
EffectCross-task persistence

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

Scope of a containment boundary
A sandbox isA sandbox is not
An isolation boundary around executionA trust oracle for what ran inside it
A cap on filesystem, process, resource and network effectsA permission grant for the action that started it
One place where least-privilege limits are enforcedThe decision about which capabilities exist
Enforced deterministically outside the modelA classifier verdict or model self-assessment
A way to make failures cheapProof that an artifact is safe to release

Separate Control Planes

Five separate questions
QuestionOwning controlRelation to containment
May this resolved action executeAgent authorizationDecided before execution; the sandbox does not authorize
Which identities, credentials, tools and capabilities existLeast privilegeSets the budget the sandbox enforces
Which network paths existNetwork / egress restrictionsStill required when the sandbox has networking
May this data cross into or out of the sandboxInformation flow controlIsolation is not a data-release decision
How far can effects of this execution reachSandboxing / containmentThis 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.

Proposal, authorization, contained execution and release
UntrustedModel proposes execution
SystemAuthorization decides
SystemSandbox provisioned from policy
UntrustedContained execution
SystemRelease gate for results

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

Isolation options (choose by risk, not label)
OptionTypical propertiesConsiderations
Separate process and unprivileged userLow overhead; shares the host kernelSuited to lower-risk, well-understood workloads
ContainerNamespaces and control groups; shares the host kernelStrength depends heavily on configuration; not a virtual machine
MicroVM or virtual machineSeparate guest kernel behind a hypervisorStronger separation, more startup and operating cost
Dedicated worker or workloadSeparate host, account or service identityLimits 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

01
LimitCPU

Bounded share or quota per workload.

02
LimitMemory

Hard ceiling with termination on breach.

03
LimitProcesses

Maximum process or thread count.

04
LimitDisk

Bounded scratch and export size.

05
LimitWall-clock time

Timeout for the whole run.

06
LimitOutput size, recursion and workers

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

Where containment stops
ControlDecidesWhat containment adds
Agent authorizationWhether a resolved action may executeCaps effects if an authorized execution is influenced
Least privilegeWhich capabilities exist at allOne enforcement point for that budget
Network / egress restrictionsWhich network paths existRemoves direct bypass paths from the workload
Information flow controlWhether data may cross into or out of the sandboxNothing; isolation is not a release decision
Output validationStructure and format of artifacts and valuesNothing; contained output is not semantically safe
Detection, tool-chain analysis, plan driftWhether behavior looks suspiciousA 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
01
StateProposed

Execution was suggested. Nothing ran.

02
StateBlocked

Execution or an effect was denied by policy.

03
StateStarted

The workload ran inside the boundary.

04
StateTerminated

The run was stopped, for example on a limit.

05
StateCompleted

The run finished. Its output is still untrusted.

06
StateExported

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

Interpreting the worked scenarios
ScenarioShowsDoes not show
A: document processingParsing can run with read-only input and no networkThat extracted content is trusted
B: helper scriptGenerated code can run inside a bounded workerThat the script is correct or trusted
C: host secret pathUnmounted paths are unavailableThat a secret was exposed or an attack intended
D: resource quotaExhaustion terminates the task, not the hostThat the workload was malicious
E: export heldResults need a separate release decisionThat the artifact or destination is approved

Testing and Validation

Defensive regression classes
Test classExpected result
Host path accessUnavailable
Network in a no-network sandboxUnavailable
Resource quota breachTask terminated with evidence
Write to a read-only inputDenied
Broad production credentialAbsent from environment and filesystem
Direct host process accessUnavailable
Artifact exportRequires the release gate
Reset between tasksNo prior task state present
Sandbox provisioning failureProtected 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

Operational measures with separate denominators
MetricDenominator
Sandbox coverageExecutions of workloads classified as requiring containment
Successful isolation-test rateLabelled isolation regression tests
Unexpected host-access blocksContained runs
Resource-limit terminationsContained runs
Export-gate coverageArtifacts leaving sandboxes
Network-disabled complianceRuns of workloads classified as no-network
Ephemeral reset coverageContained runs
False-block rate and benign task successLabelled benign tasks
Exception usage and expiry complianceContained runs and active exceptions
Containment provisioning failure rateProvisioning attempts

These are operational measures, not proof of security. Do not combine them into one score.

Common Mistakes

Failure patterns
  1. 01
    Trusting sandboxed output

    Releasing results because they came from a sandbox.

  2. 02
    Broad host mounts

    Exposing host directories or the host root to the workload.

  3. 03
    Runtime control socket exposure

    Mounting a container runtime socket into the workload.

  4. 04
    Broad production credentials

    Ambient secrets in environment, files or context.

  5. 05
    Unrestricted networking

    Networking without a separate egress layer.

  6. 06
    Shared state

    Reusing environments across tenants, users or runs.

  7. 07
    Missing resource limits

    No caps on CPU, memory, processes, disk or time.

  8. 08
    Export without release checks

    Artifacts leave without authorization, flow and validation checks.

  9. 09
    Silent fallback to the host

    Running unrestricted when the sandbox is unavailable.

  10. 10
    Assuming a container is a secure sandbox

    Relying on a label instead of configuration and risk.

  11. 11
    Confusing 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

  1. 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
  2. NIST SP 800-190, Application Container Security GuideNIST · Standard · 2017-09Reviewed 2026-09-27
  3. OWASP Top 10 for Agentic Applications for 2026OWASP GenAI Security Project · Guidance · 2025-12Reviewed 2026-09-27
  4. OWASP GenAI LLM Top 10 2026 (LLM01:2026 Prompt Injection)OWASP GenAI Security Project · GuidanceReviewed 2026-09-27