Cloud & infrastructure

Securing AI agents on Kubernetes with OpenShell and Agent Sandbox

OpenShell provides fine-grained runtime controls for AI agents on Kubernetes, complementing the cost-focused scaling of Agent Substrate.

A glass cube with a glowing robot inside, surrounded by security locks and shields.
Illustration generated for this article

AI agents are no longer simple API callers; they execute shell commands, install packages, and access file systems using credentials that often originate from untrusted internet sources. To address the security risks of running such untrusted code, NVIDIA launched OpenShell, which has recently become a CNCF Sandbox project. This guide details how platform engineers can deploy OpenShell on Kubernetes to enforce strict isolation and policy controls for these autonomous agents.

What happened

OpenShell introduces a runtime environment that places each AI agent into a dedicated sandbox, managed by a trusted supervisor outside the agent’s execution context. The project allows administrators to declare specific controls in YAML for filesystem access, process privileges, network connectivity, and credential handling. For instance, Landlock limits which paths an agent can read or write, while seccomp and non-root user settings restrict process capabilities. Network traffic is denied by default, requiring explicit rules for specific binaries, hosts, and HTTP methods.

The integration with Kubernetes relies on the Agent Sandbox project from SIG Apps, rather than bringing its own scheduler. This means OpenShell agents appear as standard Kubernetes objects like Pods, Services, and NetworkPolicies. However, OpenShell adds visibility that native Kubernetes lacks, such as identifying which specific binary made a request or whether a POST action is permitted. Unlike standard NetworkPolicies that operate at the IP and port level, OpenShell can enforce application-layer policies, such as allowing curl to read GitHub issues but blocking it from creating them.

A demonstration repository illustrates this workflow on a two-node kind cluster using Kubernetes 1.35, Cilium 1.20, and Kyverno 1.18.2. The setup highlights that sandboxes are currently created via the Gateway API, not directly through the Kubernetes API, though a custom resource definition is planned. The architecture uses a supervisor pod per agent to ensure strong isolation, a model that may face scaling challenges in large environments without future optimizations.

How it works

The OpenShell gateway acts as the central controller for all sandboxes, translating requests into Kubernetes objects via the Agent Sandbox controller. When a user creates a sandbox, the gateway authenticates the caller and records the request in a provisioning phase. It then generates NetworkPolicies to block all outbound traffic from the workload pod, allowing inbound connections only from the supervisor on a specific port. The Agent Sandbox controller subsequently creates the workload pod and a persistent volume claim, holding the pod back with a scheduling gate until security checks pass.

Once the pod is admitted, the driver verifies that it runs as a non-root user with no added capabilities and default seccomp profiles. If these checks fail, creation is aborted. Upon success, the system launches a supervisor pod, which connects to the workload through a service. The supervisor receives a short-lived token and applies filesystem, process, and DNS controls before the agent’s command starts. Every outbound request from the agent is routed through the supervisor, which validates the destination and HTTP method against the policy before opening the upstream connection.

This architecture allows for dynamic policy updates without restarting the sandbox. Administrators can modify rules to allow or deny specific actions, such as switching from blocking all curl requests to permitting read-only access to specific APIs. Logs provide detailed visibility into allowed and denied requests, ensuring that platform teams can audit agent behavior effectively. The lifecycle management includes stopping, starting, and deleting sandboxes, with automatic cleanup of associated Kubernetes resources.

Key details

  • OpenShell uses the SIG Apps Agent Sandbox project to manage agents as standard Kubernetes Pods, Services, and PVCs.
  • Filesystem access is restricted using Landlock, allowing read-only access to system paths and write access only to designated sandbox directories.
  • Network policies are enforced at the application layer, enabling controls based on binary, host, port, and HTTP method rather than just IP addresses.
  • Credentials are never exposed to the agent directly; a supervisor swaps placeholders for real keys only at allowed endpoints.
  • Current creation of sandboxes occurs via the Gateway API, with a Kubernetes CRD operator planned for future releases.
  • The demo environment utilizes Kyverno policies to enforce image hygiene, resource bounds, and RBAC restrictions that native Kubernetes controls cannot handle alone.

Why it matters

For software builders, the shift toward autonomous agents introduces significant security surface area. Traditional container security measures are insufficient because agents actively execute code and make decisions based on external inputs. OpenShell addresses this by providing per-request policy enforcement, ensuring that an agent cannot perform unauthorized actions even if it compromises its own process. This level of granularity is critical for enterprises deploying agents that interact with production systems and hold sensitive credentials.

The distinction between OpenShell and other projects like Agent Substrate is also vital for architectural decisions. While Substrate focuses on cost-effective scaling of idle agents through snapshotting and shared worker pods, OpenShell prioritizes detailed policy control and visibility within the Kubernetes ecosystem. Teams must choose based on their primary constraint: if cost and density are paramount, Substrate may be preferable; if security and auditability are the main concerns, OpenShell offers a more robust solution integrated with existing Kubernetes tools.

What you can do

  • Install a CNI plugin like Cilium that supports both ingress and egress NetworkPolicy enforcement in your cluster.
  • Deploy the Agent Sandbox controller and CRDs, followed by the OpenShell gateway Helm chart, to establish the runtime environment.
  • Use Kyverno or similar policy engines to enforce admission controls on sandbox images, resource limits, and RBAC configurations.
  • Configure workspaces to group sandboxes, policies, and logs, ensuring clear separation of concerns for different teams or projects.
  • Monitor agent activity through the supervisor logs to identify and adjust policies for denied requests in real time.
  • Evaluate the trade-offs between OpenShell’s strong isolation and Agent Substrate’s scaling efficiency based on your specific workload patterns.
  • #kubernetes
  • #ai-security
  • #openshell
  • #cncf
  • #platform-engineering

Tools from the Bytechap store

Keep reading

All stories