Axisdream
Written and Published byAxisdream·

How Sandboxes and Policy Engines Contain AI Agents

Layered security diagram showing reasoning plane decoupled from sandbox isolation and policy-as-code enforcement

Key Takeaways

  • •Containing autonomous AI agents requires pairing kernel-level sandbox isolation with deterministic policy engines to enforce boundaries outside the model.
  • •Examines the threat model of autonomous execution, analyzing the structural bottlenecks and trade-offs in real-world deployments.
  • •Provides engineering benchmarks and verification criteria for isolation spectrum: processes, containers, and microvms.

On 10 November 2026, the Cloud Native Computing Foundation accepted OpenShell into its Sandbox program, formalizing the requirement that autonomous agent execution must be constrained by kernel-level isolation and deterministic policy engines. Relying on system prompts or application-layer filters fails to protect host infrastructure against prompt injection, unvetted dependencies, or rogue command execution.

Autonomous agents operate by translating natural language into terminal commands, network requests, and database transactions. If an agent executes commands directly on a developer workstation or production host, any security failure in the reasoning layer directly compromises the host environment. Establishing true containment requires isolating the execution environment and delegating access control to external policy supervisors.

The threat model of autonomous execution

Securing an autonomous agent requires modeling threat vectors that originate both inside and outside the model context:

  • Indirect prompt injection: an agent reading external content, such as a Git pull request, documentation webpage, or customer support ticket, encounters hidden adversarial instructions designed to hijack control flow.
  • Compromised package dependencies: when an agent executes build commands such as npm install or pip install, malicious setup scripts execute arbitrary code on the local file system.
  • Tool parameter poisoning: an attacker manipulates API outputs to feed deceptive values into subsequent tool invocations, tricking the agent into modifying unauthorized files.
  • Lateral network movement: an unconstrained agent operating inside a corporate virtual private network can scan internal subnets, access metadata endpoints, and exfiltrate private credentials.
Prompt guards and output classifiers cannot eliminate these risks because they operate within the same probabilistic boundary as the compromised reasoning loop. Infrastructure security requires deterministic enforcement at the operating system layer.

text axisdream
┌────────────────────────────────────────────────────────┐
│                   Untrusted Plane                      │
│                                                        │
│  [User Command] ──> [Probabilistic Agent Reasoning]    │
│                                │                       │
│                                ▼ (Proposed Action)     │
└────────────────────────────────┼───────────────────────┘
                                 │
═════════════════════════════════╪════════════════════════ (Security Perimeter)
                                 │
┌────────────────────────────────┼───────────────────────┐
│                   Trusted Plane│                       │
│                                ▼                       │
│                   [Cedar Policy Engine Gateway]        │
│                                │                       │
│           (Permitted) ┌────────┴────────┐ (Denied)     │
│                       ▼                 ▼              │
│            [MicroVM Sandbox]       [Block & Log]       │
│            - Virtualized guest     - Security alert    │
│            - Filtered egress       - Immutable record  │
└────────────────────────────────────────────────────────┘

Isolation spectrum: processes, containers, and microVMs

Infrastructure teams employ three distinct tiers of runtime isolation to contain autonomous workloads:

  • Operating system process isolation: utilizes basic user permissions and cgroups. While introducing minimal startup latency, processes share the host operating system kernel directly. A malicious agent executing root exploits or kernel privilege escalations can compromise the entire host machine.
  • Container namespaces: tools such as Docker and Podman package workloads within isolated file system mounts and network namespaces. However, standard containers still share the underlying host kernel. Container breakouts remain a persistent attack surface when agents compile arbitrary C extensions or load raw kernel modules.
  • Hardware-virtualized microVMs: technologies such as Firecracker and lightweight virtual machine runtimes provide dedicated guest kernels per agent session. Hardware virtualization prevents kernel-level escapes, providing a deterministic boundary between the agent sandbox and host hardware.
For coding agents that compile untrusted code or run arbitrary shell scripts, microVM sandboxes provide the only acceptable security floor.

Policy-as-code: deterministic evaluation outside the prompt

Even within an isolated sandbox, an agent must interact with external APIs to perform productive work. Restricting these interactions requires a policy engine that evaluates proposed actions against explicit organizational rules.

OpenShell integrates Cedar, an open-source policy-as-code language, to define exact execution parameters. Rather than trusting the model to remember restrictions, the gateway evaluates Cedar policies before every tool call:

cedar
// Allow git read operations on authorized repositories
permit (
    principal == Role::"JuniorAuditor",
    action == Action::"GitClone",
    resource in Organization::"PublicRepos"
);

// Block all network socket connections to cloud metadata IP addresses
forbid (
    principal,
    action == Action::"ConnectNetwork",
    resource
)
when {
    resource.ip == "169.254.169.254"
};

If an injection payload tricks the agent into requesting cloud instance metadata credentials, the Cedar evaluator intercepts the system call, matches the forbidden IP address, terminates the network request, and transmits a security alert to administrative logs. The agent cannot bypass the rule because policy evaluation occurs outside the container.

Egress filtering and ephemeral secret brokering

Securing the network perimeter requires strict outbound traffic controls:

  • Default-deny egress: agent sandboxes must block all outbound network traffic by default. The host gateway whitelists only the exact fully qualified domain names required for the assigned task, such as specific package registries or API gateways.
  • Ephemeral credentials: long-lived cloud keys, database passwords, and production tokens must never enter the agent sandbox. The host acts as a credential broker, injecting short-lived, narrowly scoped authorization tokens at the gateway boundary immediately before network packets leave the trusted perimeter.

Layered operational defense for autonomous systems

Containing autonomous systems requires an end-to-end security architecture:

  • MicroVM isolation for all arbitrary code execution.
  • Policy-as-code evaluation for all external tool calls and system operations.
  • Default-deny network egress with domain whitelisting.
  • Append-only audit logging outside the sandbox to record all blocked attempts.
Engineering teams ensure security by treating language models as untrusted operators. By enforcing boundaries at the hypervisor and network layers, organizations can deploy autonomous agents with confidence that unexpected model actions remain contained.

Sources

Related Dispatches