Axisdream
Written and Published byAxisdream·

How to Secure AI Agents Without Trusting Their Prompts

Security boundary diagram separating the untrusted agent prompt runtime from external kernel-level policy and sandbox enforcement

Key Takeaways

  • •Enforcing runtime security outside probabilistic model prompts enables safe autonomous execution through sandboxing, policy engines, and credential brokering.
  • •Examines the failure mode of prompt-level security controls, analyzing the structural bottlenecks and trade-offs in real-world deployments.
  • •Provides engineering benchmarks and verification criteria for external runtime architecture and sandbox isolation.

On 10 November 2026, the Cloud Native Computing Foundation accepted OpenShell as a Sandbox project, formalizing runtime policy enforcement outside the model as the required security architecture for autonomous agents. Because language model outputs are probabilistic, prompt-based instructions cannot guarantee containment against indirect prompt injections, credential theft, or unauthorized network egress.

Relying on system prompts to enforce security boundaries represents an architectural defect. An instruction such as "never delete customer records" or "only access public GitHub repositories" can be circumvented whenever an agent ingests untrusted third-party text. Once untrusted inputs enter the context window, prompt injection attacks can override developer instructions. True containment requires shifting authorization logic into the underlying execution runtime.

The failure mode of prompt-level security controls

Prompt guards, input classifiers, and negative system instructions operate within the same cognitive plane as the untrusted content being processed. When a model reads a compromised webpage, an email attachment, or a database string containing embedded directives, it cannot reliably differentiate between genuine user commands and malicious payloads.

Security controls fail at the application layer through three primary vectors:

  • Indirect prompt injection: malicious payloads hidden in external data manipulate the agent into issuing unauthorized tool calls.
  • Tool parameter confusion: an attacker formats inputs to mimic legitimate function arguments, bypassing regex-based parameter validators.
  • State-dependent drift: long-running agents accumulate reasoning deviations across multi-turn trajectories, eventually violating initial prompt guidelines.
Attempting to fix these vulnerabilities by expanding system prompts increases latency, inflates token costs, and degrades reasoning performance without establishing a deterministic security boundary. An infrastructure boundary must remain immutable regardless of model belief.

External runtime architecture and sandbox isolation

The OpenShell architecture, contributed by NVIDIA on 9 November 2026, establishes deterministic containment by placing the agent inside a supervised execution environment. Rather than allowing the agent direct access to host resources, the system decouples reasoning from actuation.

text axisdream
┌────────────────────────────────────────────────────────┐
│                   Untrusted Plane                      │
│                                                        │
│  [User Request] ──> [LLM Agent Reasoning Loop]        │
│                                │                       │
│                                ▼ (Proposed Action)     │
└────────────────────────────────┼───────────────────────┘
                                 │
═════════════════════════════════╪════════════════════════ (Security Boundary)
                                 │
┌────────────────────────────────┼───────────────────────┐
│                   Trusted Plane│                       │
│                                ▼                       │
│                   [Policy Evaluation Gateway]          │
│                                │                       │
│             ┌──────────────────┴──────────────────┐    │
│             ▼                                     ▼    │
│  [Credential Broker]                   [MicroVM Sandbox]│
│  (Short-lived tokens)                  (Isolated Egress)│
└────────────────────────────────────────────────────────┘

The runtime enforces least privilege across four core components:

  1. MicroVM sandboxing: each agent session executes inside an isolated lightweight virtual machine or constrained container namespace. File system access is restricted to ephemeral scratch directories mounted with copy-on-write semantics.
  2. Network egress filtering: kernel-level packet filters block all outbound traffic by default, whitelisting only verified API endpoints required for the specific task.
  3. Policy-as-code supervisor: every proposed tool call passes through an external policy evaluator before execution occurs. OpenShell employs Cedar, a declarative policy language originally developed by Amazon Web Services, to write deterministic allow and deny rules.
  4. Credential brokering: raw API keys, database credentials, and cloud tokens are never exposed to the agent context. The runtime acts as a broker, intercepting outbound requests, validating their destination, and injecting short-lived authorization headers at the network gateway.

Writing deterministic policies for non-deterministic agents

A policy-as-code layer evaluates actions against explicit organizational rules. Using a formal language such as Cedar, administrators define what an agent can touch without modifying application prompts.

Consider an agent tasked with auditing code repositories. A standard Cedar policy enforces exact operational boundaries:

cedar
// Permit repository read operations on designated engineering repositories
permit (
    principal == AgentRole::"CodeAuditor",
    action in [Action::"GitClone", Action::"ReadFile"],
    resource in RepositoryFolder::"InternalAudit"
);

// Explicitly forbid network socket creation outside the internal registry
forbid (
    principal == AgentRole::"CodeAuditor",
    action == Action::"OpenSocket",
    resource
)
unless {
    resource.host == "github.company.internal"
};

If an indirect injection payload instructs the agent to exfiltrate private code to an external server, the agent may generate the curl command. However, the runtime supervisor intercepts the tool call, matches it against the forbid rule, drops the packet at the kernel interface, and logs a security violation. The compromise terminates at the network boundary, preventing data exfiltration regardless of the model's internal confusion.

Tamper-evident observability and audit trails

Deterministic enforcement requires comprehensive observability. When an autonomous system operates over external files and APIs, human operators need an unalterable record of actions, decisions, and blocked attempts.

The runtime logs every operational event to an append-only audit stream. Each log entry records:

  • The exact prompt context that triggered the action.
  • The raw tool call and serialized arguments generated by the model.
  • The policy evaluation result, including matching rule IDs.
  • The exit code, standard output, and execution duration returned by the sandbox.
Because these logs reside outside the agent sandbox, a compromised model cannot delete or alter its own audit trail. Security operations teams can inspect blocked actions in real time, identifying injection attempts and refining policy definitions without disrupting operational workloads.

Sandbox maturity and remaining operational constraints

While isolating agents at the runtime layer resolves the prompt injection dilemma, organizations adopting frameworks such as OpenShell must navigate practical engineering constraints:

  • Cold-start overhead: spinning up dedicated microVMs or container namespaces introduces latency that can delay interactive agent responses by hundreds of milliseconds.
  • Policy maintenance: managing granular allow-lists across complex enterprise APIs requires continuous rule authoring to prevent operational false positives.
  • Sandbox escape risks: running arbitrary generated code inside virtualization layers relies entirely on hypervisor security; vulnerabilities in container runtimes or kernel interfaces remain viable attack vectors.
Deterministic security for autonomous systems is an infrastructure engineering problem. Organizations protect enterprise data by treating language models as untrusted operators, delegating authorization decisions to external policy engines and confining all execution to strictly monitored sandboxes.

Sources

Related Dispatches