Text of code.claude.com › docs › en › agent-sdk › secure-deployment as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Securely deploying AI agents - Claude Code Docs

Documentation Index Fetch the complete documentation index at: /docs/llms.txt Use this file to discover all available pages before exploring further. Skip to main content Assistant Responses are generated using AI and may contain mistakes. Claude Code and the Agent SDK can execute code, access files, and interact with external services on your behalf. Unlike traditional software that follows predetermined code paths, these tools generate their actions dynamically based on context and goals.

This flexibility is what makes them useful, but it also means their behavior can be influenced by the content they process: files, webpages, or user input. This is sometimes called prompt injection. For example, if a repository’s README contains unusual instructions, Claude Code might incorporate those into its actions in ways the operator didn’t anticipate. This guide covers practical ways to reduce this risk. Not every deployment needs maximum security.

A developer running Claude Code on their laptop has different requirements than a company processing customer data in a multi-tenant environment. This guide presents options ranging from Claude Code’s built-in security features to hardened production architectures, so you can choose what fits your situation. Threat model Agents can take unintended actions due to prompt injection (instructions embedded in content they process) or model error.

Claude models are designed to resist this; see the model overview and the system card for the model you deploy for evaluation details. Defense in depth is still good practice though. For example, if an agent processes a malicious file that instructs it to send customer data to an external server, network controls can block that request entirely. Built-in security features Claude Code includes several security features that address common concerns.

See the security documentation for full details. Permissions system : Permission rules decide whether a tool call runs, is blocked, or asks for approval first. For the forms a Bash rule misses and how rules combine with permission modes, see What a Bash rule doesn’t match and Configure permissions . Administrators can also set rules in managed settings . Critical-path removals : With the permission mode set to default , an rm or rmdir command recognized as removing your working directory or another critical path needs approval.

A matching allow rule doesn’t skip that approval. This is a permission gate, not a sandbox. To control what the agent can write, use filesystem controls . Web search summarization : Search results are summarized rather than passing raw content directly into the context, reducing the risk of prompt injection from malicious web content. Sandbox mode : Bash commands can run in a sandboxed environment that restricts filesystem and network access.

See the sandboxing documentation for details. Security principles For deployments that require additional hardening beyond Claude Code’s defaults, these principles guide the available options. Security boundaries A security boundary separates components with different trust levels. For high-security deployments, you can place sensitive resources (like credentials) outside the boundary containing the agent. If something goes wrong in the agent’s environment, resources outside that boundary remain protected.

For example, rather than giving an agent direct access to an API key, you could run a proxy outside the agent’s environment that injects the key into requests. The agent can make API calls, but it never sees the credential itself. This pattern is useful for multi-tenant deployments or when processing untrusted content. Least privilege When needed, you can restrict the agent to only the capabilities required for its specific task: Resource Restriction options Filesystem Mount only needed directories, prefer read-only Network Restrict to specific endpoints via proxy Credentials Inject via proxy rather than exposing directly System capabilities Drop Linux capabilities in containers Defense in depth For high-security environments, layering multiple controls provides additional protection.

Options include: Container isolation Network restrictions Filesystem controls Request validation at a proxy The right combination depends on your threat model and operational requirements. Isolation technologies Different isolation technologies offer different tradeoffs between security strength, performance, and operational complexity. In all of these configurations, Claude Code (or your Agent SDK application) runs inside the isolation boundary (the sandbox, container, or VM).

The security controls described below restrict what the agent can access from within that boundary. Technology Isolation strength Performance overhead Complexity Sandbox runtime Good (secure defaults) Very low Low Containers (Docker) Setup dependent Low Medium gVisor Excellent (with correct setup) Medium/High Medium VMs (Firecracker, QEMU) Excellent (with correct setup) High Medium/High Sandbox runtime For lightweight isolation without containers, sandbox-runtime enforces filesystem and network restrictions at the OS level.

The main advantage is simplicity: no Docker configuration, container images, or networking setup required. The proxy and filesystem restrictions are built in. How it works: Filesystem : Uses OS primitives ( bubblewrap on Linux, sandbox-exec on macOS) to restrict read/write access to configured paths Network : Runs commands in their own network namespace (Linux) or under a Seatbelt profile (macOS) and routes their traffic through a built-in proxy that allows the configured domains.

A connection to an outside host that skips the proxy fails. Configuration : JSON-based allowlists for domains and filesystem paths Setup: For the install, configuration, and launch steps, see Set up and launch the runtime . Security considerations: Same-host kernel : Unlike VMs, sandboxed processes share the host kernel. A kernel vulnerability could theoretically enable escape. For some threat models this is acceptable, but if you need kernel-level isolation, use gVisor or a separate VM.

No TLS inspection : By default, the proxy enforces the allowlist based on the client-supplied hostname and doesn’t terminate or inspect encrypted traffic. Code running inside the sandbox can potentially use domain fronting or similar techniques to reach hosts outside the allowlist. If your threat model requires stronger guarantees, use a TLS-terminating proxy that inspects traffic, as Traffic forwarding describes. For more information, see the sandboxing security limitations .

Credentials for allowed domains : If the agent has permissive credentials for an allowed domain, ensure it cannot use that domain to trigger other network requests or to exfiltrate data. For many single-developer and CI/CD use cases, sandbox-runtime raises the bar significantly with minimal setup. The sections below cover containers and VMs for deployments requiring stronger isolation. Containers Containers provide isolation through Linux namespaces.

Each container has its own view of the filesystem, process tree, and network stack, while sharing the host kernel. A security-hardened container configuration might look like this: docker run \ --cap-drop ALL \ --security-opt no-new-privileges \ --security-opt seccomp=/path/to/seccomp-profile.json \ --read-only \ --tmpfs /tmp:rw,noexec,nosuid,size=100m \ --tmpfs /home/agent:rw,noexec,nosuid,size=500m \ --network none \ --memory 2g \ --cpus 2 \ --pids-limit 600 \ --user 1000:1000 \ -v /path/to/code:/workspace:ro \ -v /var/run/proxy.sock:/var/run/proxy.sock:ro \ agent-image Here’s what each option does: Option Purpose --cap-drop ALL Removes Linux capabilities like NET_ADMIN and SYS_ADMIN that could enable privilege escalation --security-opt no-new-privileges Prevents processes from gaining privileges through setuid binaries --security-opt seccomp=...

Restricts available syscalls; Docker’s defaul

The rest of this page is on the live site.