techlist.io

Sandbox

2 posts

Cloudflare2026-04-134 min readCurated summary

Dynamic, identity-aware, and secure Sandbox auth

Sandboxes for AI agents need more than isolation: they also require fast startup, platform control, and safe access to external services. The post introduces outbound Workers, programmable egress proxies that intercept sandbox traffic and can authenticate, restrict, modify, log, or cancel requests. This approach combines zero-trust security with identity-aware, flexible, observable, and dynamic authorization without exposing secrets to untrusted agents. ## Sandbox Requirements Sandboxes provide three core benefits: - **Security:** Untrusted users or agents can run code without compromising the host or neighboring sandboxes, often through microVM isolation. - **Speed:** Users can quickly start new sandboxes and restore existing state. - **Control:** The trusted platform can mount files, execute commands, and control network access inside the sandbox. Outbound Workers add network-level control to this model by acting as programmatic egress proxies for Sandboxes and Containers. ## How Outbound Workers Work - A sandbox can define handlers for all outbound requests or for requests to specific hosts. - For example, requests to `github.com` can be intercepted through `static outboundByHost`. - The handler can: - Add authentication headers. - Log requests. - Modify request data. - Reject or cancel requests. - Secrets remain outside the sandbox and can be accessed by the Worker through its environment. - Workers run near the sandbox, can access distributed state, and can be updated using ordinary JavaScript. A sample handler copies the request headers and injects `x-auth-token` from `env.SECRET` before forwarding the request. ## Challenges with Existing Agent Authentication Agent workloads cannot be fully trusted, even when the underlying language model is not intentionally malicious. Credentials must therefore limit accidental misuse and prevent data exfiltration. ### Standard API Tokens - Tokens are commonly passed through environment variables or mounted secret files. - They are simple to implement but expose credentials to the sandboxed workload. - A compromised or misbehaving agent could leak the token. - Expiration and rotation are required, creating operational overhead. ### Workload Identity Tokens - Systems such as OIDC provide an identity assertion rather than a general-purpose service token. - The agent can exchange the identity token for a short-lived access token. - Tokens can be invalidated when a workflow ends, simplifying expiration. - The drawback is limited upstream support: many services do not natively accept OIDC, forcing platforms to build custom token-exchange services. ### Custom Proxies - Proxies provide maximum control and can enforce granular permissions even when an upstream service has weak RBAC. - They can be combined with workload identity tokens. - However, intercepting all sandbox traffic and building an efficient, dynamic, programmable proxy is difficult. ## Characteristics of an Ideal Agent Auth System The post argues that agent authentication should be: - **Zero trust:** Never expose a reusable token to an untrusted workload. - **Simple:** Avoid complicated token minting, rotation, and decryption systems. - **Flexible:** Enforce permissions independently of the upstream service. - **Identity-aware:** Apply rules based on which sandbox is making the request. - **Observable:** Record and inspect outbound calls. - **Performant:** Avoid slow, centralized authorization round trips. - **Transparent:** Require no changes to the sandboxed application. - **Dynamic:** Allow authorization rules to change while systems are running. Outbound Workers are presented as a way to satisfy all of these requirements. ## Restriction and Observability A basic outbound handler can enforce network policy with only a few lines of JavaScript: - Inspect each outgoing HTTP request. - Log requests using disallowed methods. - Return a `405 Method Not Allowed` response for anything other than `GET`. - Forward permitted requests with `fetch(req)`. This demonstrates that outbound Workers can enforce restrictions and provide observability without modifying the application running inside the sandbox. ## Practical Recommendation Use outbound Workers as a trusted egress layer for agent sandboxes. Keep sensitive credentials outside the workload, inject or exchange them only at the proxy, and use the Worker to enforce identity-specific policies, logging, and request restrictions dynamically.

Anthropic2026-04-084 min readCurated summary

Scaling Managed Agents with stable interfaces

Anthropic's Managed Agents is a hosted service that runs long-horizon agents through stable interfaces, so the underlying harness, sandbox, and session implementations can change without breaking callers. The design borrows from operating systems, which kept abstractions like `read()` stable while the hardware beneath them changed. Anthropic separates the agent into a session (a durable event log), a harness (the loop that calls Claude), and a sandbox (where code runs), so each can fail or be replaced independently. The result is faster startup, better reliability, and a stronger security boundary. ## Problems with the Coupled Container Design - The first version put the session, harness, and sandbox in a single container. This was simple and let file edits run as direct syscalls, but it treated the server as a "pet." If a container failed, the session was lost, and unresponsive containers had to be nursed back to health. - Debugging was hard. The WebSocket event stream could not show whether a failure came from the harness, a dropped packet, or a dead container. Engineers had to open a shell in the container, which often held user data. - The harness assumed all resources were in the same container. Connecting to a customer's VPC required peering networks or running the harness in the customer's environment. ## Decoupling the Brain, Hands, and Session - **Hands as tools:** The harness no longer runs in the container. It calls sandboxes like any other tool through `execute(name, input) → string`. If a container dies, the harness returns the error to Claude, which can request a new one with `provision({resources})`. - **Crash recovery:** The harness is also stateless. A new harness calls `wake(sessionId)`, retrieves the log with `getSession(id)`, and resumes from the last event. During the loop, it writes durable records with `emitEvent(id, event)`. - **Credential isolation:** Previously, generated code ran alongside credentials, so a prompt injection could expose tokens. Now tokens never enter the sandbox: - Git repositories are cloned during sandbox initialization with the token wired into the remote, so `push` and `pull` work without the agent seeing the token. - MCP tools are called through a proxy that takes a session-scoped token, fetches the real OAuth credentials from a vault, and makes the external call. The harness never sees credentials. ## The Session as an External Context Object - Long tasks exceed the context window, and common fixes like compaction, memory files, and context trimming are irreversible. Once content is discarded, the agent may later need it and be unable to recover it. - The session log stores the full history outside Claude's context window. The `getEvents()` interface lets the harness read positional slices, such as resuming from the last read position, rewinding to see what led up to an event, or rereading context before an action. - The harness can transform fetched events before they reach Claude's context, for example to improve prompt cache hit rates. Anthropic keeps storage in the session and context management in the harness, since future models may need different context strategies. ## Scaling to Many Brains and Many Hands - **Faster startup:** Previously, every session waited for a container to provision and repository to clone, even if it never used one. Now containers are provisioned only when a tool call requires them. Inference starts as soon as pending events are pulled from the log. This cut p50 time-to-first-token by about 60% and p95 by over 90%. - **Many brains:** Stateless harnesses can be started on demand and connected to hands only when needed. - **Many hands:** A brain can use multiple execution environments. Since each hand is just a tool with a name and input, the harness does not need to know whether the sandbox is a container, a phone, or an emulator. Brains can also pass hands to one another. ## Conclusion Managed Agents is a meta-harness: it does not prescribe a single harness design. Its interfaces are opinionated about the surrounding components, namely state (the session), computation (the sandbox), and scaling to many brains and hands, but not about the harness itself. This lets it support Claude Code, task-specific harnesses, and future designs without redesigning the system.