Skip to main content
guidesSource-backed

Secure Deployment for Claude Agent SDK Applications

A practical walkthrough of securely deploying Claude Agent SDK applications: the prompt-injection threat model, isolation options (sandbox runtime, containers, gVisor, VMs), least privilege, the proxy credential pattern, and filesystem controls.

by JPette1783·added 2026-06-05·
Review first review before installing

Open the source and read safety notes before installing.

Citation facts

Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.

Source URLs
https://code.claude.com/docs/en/agent-sdk/secure-deployment, https://github.com/JSONbored/awesome-claude/blob/main/content/guides/secure-deployment-for-claude-agent-sdk-applications.mdx
Safety notes
Agents generate actions dynamically and can be influenced by content they process (prompt injection); apply defense in depth, not a single control., Use least privilege: mount only needed directories (prefer read-only), restrict network to specific endpoints, and drop Linux capabilities in containers., Inject credentials via a proxy outside the agent boundary so the agent never sees secrets; do not mount ~/.ssh, ~/.aws, .env, or similar into the agent.
Privacy notes
Even read-only code mounts can expose credentials in .env, ~/.git-credentials, ~/.aws, .npmrc, and key files; exclude or sanitize them before mounting., Route egress through a proxy that enforces a domain allowlist and logs requests, so a compromised agent cannot exfiltrate data to arbitrary hosts., The built-in sandbox proxy does not inspect TLS; for stronger guarantees use a TLS-terminating proxy with its CA installed in the agent's trust store.
Author
JPette1783
Submitted by
JPette1783
Claim status
unclaimed
Last verified
2026-06-05

Decision playbook

Review trust signals before you adopt

Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.

Compare context
Selected

0

Current score

63

Baseline

Delta

No baseline selected

No major trust-signal divergence detected in the current selection.

Source and provenance checks

Needs review

Confirm ownership and provenance before trusting install instructions.

  • Source link availableRequired

    Open the canonical repository and verify ownership.

    Done
  • Source provenance statusRequired

    Marked as source-backed.

    Done
  • Metadata reviewed

    No reviewed flag detected in metadata.

    Pending

Safety and privacy checks

Complete

Validate risk disclosures before installation or API wiring.

  • Safety notes presentRequired

    Review the listed safety guidance before running commands.

    Done
  • Privacy notes presentRequired

    Review data handling notes before connecting accounts or secrets.

    Done
  • Trust level risk gateRequired

    Trust level does not block evaluation.

    Done

Package and install checks

Needs review

Check package metadata and artifact integrity signals.

  • Install payload available

    Install or copy payload is available for review.

    Done
  • Package verification flag

    No package verification flag provided.

    Pending
  • Checksum metadata

    No checksum provided for downloaded artifact.

    Pending

Compare-driven decision checks

Needs review

Use compare context to validate trade-offs before adoption.

  • Compare tray has multiple entries

    Add at least one more entry to compare trust differences.

    Pending
  • Baseline comparison available

    No baseline peer selected yet.

    Pending
  • Diverging trust signals identified

    No major trust-signal divergence found.

    Pending

Setup at a glance

Copy & paste

Copy-ready — paste the snippet to get started.

Adoption plan

Balanced adoption plan

Current risk score 24/100. Use staged verification before broader rollout.

Risk 24

Pre-adoption checks

Validate source and review signals before any execution.

  • Confirm source provenanceRequired

    Source URL/provenance metadata is present.

    Done
  • Confirm metadata review state

    No review metadata found; increase manual validation.

    Pending
  • Verify install payload

    Install/config payload exists and can be inspected.

    Done

Security checks

Confirm safety, privacy, and package integrity signals.

  • Review safety notesRequired

    Safety notes are present.

    Done
  • Review privacy notesRequired

    Privacy notes are present.

    Done
  • Verify package integrity metadata

    No package verification/checksum metadata.

    Pending

Rollout

Adopt in controlled steps based on the selected plan.

  • Run in isolated sandbox firstRequired

    Use a constrained sandbox and observe behavior across multiple tasks.

    Pending
  • Roll out graduallyRequired

    Roll out to a small cohort before wider usage.

    Pending
  • Set monitoring and fallback

    Define rollback path and monitor errors after adoption.

    Pending

Evidence readiness

Evidence readiness matrix · balanced

Missing required evidence: Metadata review. Risk score 31.

Risk 31

Source provenance

Present

Source repository/provenance is listed.

Required in this preset

Metadata review

Missing

Review metadata is missing.

Required in this preset

Safety notes

Present

Safety notes are present.

Required in this preset

Privacy notes

Present

Privacy notes are present.

Optional in this preset

Package integrity

Missing

Package integrity metadata is missing.

Optional in this preset

Install payload

Present

Install payload is available.

Required in this preset

Required gaps: Metadata review

Decision timeline

Decision timeline · balanced

Blocking gaps: Check metadata review status. Risk 28.

Risk 28

triage

Confirm source provenanceRequired

Source/provenance metadata is available.

Done

triage

Check metadata review statusRequired

Review metadata is missing.

Pending

verify

Review safety notesRequired

Safety notes are available.

Done

verify

Review privacy notes

Privacy notes are available.

Done

verify

Validate package integrity metadata

Package integrity metadata is missing.

Pending

rollout

Verify install payload and commandsRequired

Install payload is available.

Done

Blockers: Check metadata review status

Prerequisite readiness

Prerequisite readiness

3 prerequisites to line up before setup. Have accounts and credentials ready first.

0/3 ready
Account & credentials1Install & runtime1General1

Safety & privacy surface

Safety & privacy surface

3 safety and 3 privacy notes across 3 risk areas. Review closely: credentials & tokens, network access.

3 areas
  • SafetyExecution & processesAgents generate actions dynamically and can be influenced by content they process (prompt injection); apply defense in depth, not a single control.
  • SafetyNetwork accessUse least privilege: mount only needed directories (prefer read-only), restrict network to specific endpoints, and drop Linux capabilities in containers.
  • SafetyCredentials & tokensInject credentials via a proxy outside the agent boundary so the agent never sees secrets; do not mount ~/.ssh, ~/.aws, .env, or similar into the agent.
  • PrivacyCredentials & tokensEven read-only code mounts can expose credentials in .env, ~/.git-credentials, ~/.aws, .npmrc, and key files; exclude or sanitize them before mounting.
  • PrivacyNetwork accessRoute egress through a proxy that enforces a domain allowlist and logs requests, so a compromised agent cannot exfiltrate data to arbitrary hosts.
  • PrivacyExecution & processesThe built-in sandbox proxy does not inspect TLS; for stronger guarantees use a TLS-terminating proxy with its CA installed in the agent's trust store.

Safety notes

  • Agents generate actions dynamically and can be influenced by content they process (prompt injection); apply defense in depth, not a single control.
  • Use least privilege: mount only needed directories (prefer read-only), restrict network to specific endpoints, and drop Linux capabilities in containers.
  • Inject credentials via a proxy outside the agent boundary so the agent never sees secrets; do not mount ~/.ssh, ~/.aws, .env, or similar into the agent.

Privacy notes

  • Even read-only code mounts can expose credentials in .env, ~/.git-credentials, ~/.aws, .npmrc, and key files; exclude or sanitize them before mounting.
  • Route egress through a proxy that enforces a domain allowlist and logs requests, so a compromised agent cannot exfiltrate data to arbitrary hosts.
  • The built-in sandbox proxy does not inspect TLS; for stronger guarantees use a TLS-terminating proxy with its CA installed in the agent's trust store.

Prerequisites

  • A Claude Agent SDK application you intend to run beyond a trusted local laptop.
  • Knowledge of which files, endpoints, and credentials the agent legitimately needs.
  • Container, sandbox, or VM tooling appropriate to your isolation choice.

Schema details

Install type
copy
Troubleshooting
No
Full copyable content
## Overview

Claude Code and the Agent SDK can execute code, access files, and call external
services. Because they generate actions dynamically based on the content they
process, their behavior can be influenced by files, web pages, or user input
(prompt injection). Securing a deployment uses familiar principles: isolation,
least privilege, and defense in depth.

Not every deployment needs maximum security. A laptop differs from a multi-tenant
service processing customer data. Choose controls that fit your threat model.

## Built-in features

Claude Code includes a permissions system (allow/block/prompt per tool and bash
command, with org policies), AST-based command parsing for permission matching,
web-search summarization (reduces injection from web content), and a sandbox mode
that restricts filesystem and network access.

## Isolation options

| Technology | Isolation | Overhead | Complexity |
| --- | --- | --- | --- |
| Sandbox runtime | Good defaults | Very low | Low |
| Containers (Docker) | Setup dependent | Low | Medium |
| gVisor | Excellent | Medium/High | Medium |
| VMs (Firecracker/QEMU) | Excellent | High | Medium/High |

The agent always runs inside the boundary. `@anthropic-ai/sandbox-runtime`
enforces filesystem and network restrictions at the OS level with minimal setup.
A hardened container drops all capabilities, runs read-only with tmpfs, runs as a
non-root user, sets `--network none`, and reaches the outside only through a
mounted Unix socket to a host proxy. gVisor intercepts syscalls in userspace for a
smaller kernel attack surface; VMs add hardware-level isolation.

## Hardened Container Example

A security-hardened container configuration might look like this:

```bash
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 100 \
  --user 1000:1000 \
  -v /path/to/code:/workspace:ro \
  -v /var/run/proxy.sock:/var/run/proxy.sock:ro \
  agent-image
```

| 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 |
| `--read-only` | Makes the container's root filesystem immutable, preventing the agent from persisting changes |
| `--network none` | Removes all network interfaces; the agent communicates through the mounted Unix socket below |
| `--memory 2g` | Limits memory usage to prevent resource exhaustion |
| `--pids-limit 100` | Limits process count to prevent fork bombs |
| `--user 1000:1000` | Runs as a non-root user |

## Least privilege

Restrict the agent to what its task needs: mount only required directories
(prefer read-only), restrict network to specific endpoints via a proxy, inject
credentials rather than exposing them, and drop Linux capabilities in containers.

## The credential proxy pattern

Run a proxy outside the agent boundary that injects credentials into outgoing
requests. The agent sends requests without secrets; the proxy adds them, enforces
an endpoint allowlist, and logs traffic. For Claude API calls, set
`ANTHROPIC_BASE_URL` to your proxy (plaintext, can inject) or `HTTP_PROXY` /
`HTTPS_PROXY` (system-wide; HTTPS needs a TLS-terminating proxy with a trusted CA
to modify). For other services, prefer a custom tool/MCP server that performs the
authenticated call outside the boundary.

## Filesystem controls

Mount code read-only when the agent only needs to analyze it, and exclude or
sanitize credential files (`.env`, `~/.git-credentials`, `~/.aws/credentials`,
`.npmrc`, `*.pem`) even from read-only mounts. For writable workspaces, use tmpfs
(ephemeral) or a dedicated volume kept separate from sensitive directories; an
overlay filesystem lets you review changes before persisting.

## Cloud deployments

Run agents in a private subnet with no internet gateway, block egress except to
your proxy with cloud firewall rules, validate and log requests at the proxy, and
assign minimal IAM to the agent's service account.

## Source

- Securely deploying AI agents: https://code.claude.com/docs/en/agent-sdk/secure-deployment

About this resource

Overview

Claude Code and the Agent SDK can execute code, access files, and call external services. Because they generate actions dynamically based on the content they process, their behavior can be influenced by files, web pages, or user input (prompt injection). Securing a deployment uses familiar principles: isolation, least privilege, and defense in depth.

Not every deployment needs maximum security. A laptop differs from a multi-tenant service processing customer data. Choose controls that fit your threat model.

Built-in features

Claude Code includes a permissions system (allow/block/prompt per tool and bash command, with org policies), AST-based command parsing for permission matching, web-search summarization (reduces injection from web content), and a sandbox mode that restricts filesystem and network access.

Isolation options

Technology Isolation Overhead Complexity
Sandbox runtime Good defaults Very low Low
Containers (Docker) Setup dependent Low Medium
gVisor Excellent Medium/High Medium
VMs (Firecracker/QEMU) Excellent High Medium/High

The agent always runs inside the boundary. @anthropic-ai/sandbox-runtime enforces filesystem and network restrictions at the OS level with minimal setup. A hardened container drops all capabilities, runs read-only with tmpfs, runs as a non-root user, sets --network none, and reaches the outside only through a mounted Unix socket to a host proxy. gVisor intercepts syscalls in userspace for a smaller kernel attack surface; VMs add hardware-level isolation.

Hardened Container Example

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 100 \
  --user 1000:1000 \
  -v /path/to/code:/workspace:ro \
  -v /var/run/proxy.sock:/var/run/proxy.sock:ro \
  agent-image
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
--read-only Makes the container's root filesystem immutable, preventing the agent from persisting changes
--network none Removes all network interfaces; the agent communicates through the mounted Unix socket below
--memory 2g Limits memory usage to prevent resource exhaustion
--pids-limit 100 Limits process count to prevent fork bombs
--user 1000:1000 Runs as a non-root user

Least privilege

Restrict the agent to what its task needs: mount only required directories (prefer read-only), restrict network to specific endpoints via a proxy, inject credentials rather than exposing them, and drop Linux capabilities in containers.

The credential proxy pattern

Run a proxy outside the agent boundary that injects credentials into outgoing requests. The agent sends requests without secrets; the proxy adds them, enforces an endpoint allowlist, and logs traffic. For Claude API calls, set ANTHROPIC_BASE_URL to your proxy (plaintext, can inject) or HTTP_PROXY / HTTPS_PROXY (system-wide; HTTPS needs a TLS-terminating proxy with a trusted CA to modify). For other services, prefer a custom tool/MCP server that performs the authenticated call outside the boundary.

Filesystem controls

Mount code read-only when the agent only needs to analyze it, and exclude or sanitize credential files (.env, ~/.git-credentials, ~/.aws/credentials, .npmrc, *.pem) even from read-only mounts. For writable workspaces, use tmpfs (ephemeral) or a dedicated volume kept separate from sensitive directories; an overlay filesystem lets you review changes before persisting.

Cloud deployments

Run agents in a private subnet with no internet gateway, block egress except to your proxy with cloud firewall rules, validate and log requests at the proxy, and assign minimal IAM to the agent's service account.

Source

Source citations

Add this badge to your README

Show that Secure Deployment for Claude Agent SDK Applications is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/guides/secure-deployment-for-claude-agent-sdk-applications.svg)](https://heyclau.de/entry/guides/secure-deployment-for-claude-agent-sdk-applications)

How it compares

Secure Deployment for Claude Agent SDK Applications side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

2 trust signals differ across this comparison (Source provenance, Submitter).

Field

A practical walkthrough of securely deploying Claude Agent SDK applications: the prompt-injection threat model, isolation options (sandbox runtime, containers, gVisor, VMs), least privilege, the proxy credential pattern, and filesystem controls.

Open dossier

Isolate Claude Agent SDK tenants in shared containers using documented options: per-tenant cwd, settingSources disabled, CLAUDE_CONFIG_DIR, CLAUDE_CODE_DISABLE_AUTO_MEMORY, and per-tenant egress rules from official hosting documentation.

Open dossier

A practical walkthrough of least-privilege permission design in the Claude Agent SDK. Learn the evaluation order (hooks → deny → mode → allow → canUseTool), how allowedTools and disallowedTools differ, the six permission modes, and how to lock an agent to a fixed tool surface with dontAsk.

Open dossier

Defend tool-connected agents against prompt injection using documented Claude Code security practices: MCP trust verification, approval gates, least-privilege tools, untrusted content handling, and human review before side-effect tool calls.

Open dossier
Next steps
Trust
Review statusNot reviewedNot reviewedNot reviewedNot reviewed
Package trustPackage not verifiedPackage not verifiedPackage not verifiedPackage not verified
Source provenanceDiffersSource-backedSubmission linkedSource submissionSource-backedSubmission linkedSource submission
SubmitterDiffersJPette1783kiannidevJPette1783kiannidev
Install riskReview firstReview firstReview firstReview first
Notes Safety ✓ Privacy ✓ Safety ✓ Privacy ✓ Safety ✓ Privacy ✓ Safety ✓ Privacy ✓
Brand
Categoryguidesguidesguidesguides
SourceSource-backedSource-backedSource-backedSource-backed
AuthorJPette1783kiannidevJPette1783kiannidev
Added2026-06-052026-06-162026-06-052026-06-16
Platforms
Harness
Source repo
Safety notesAgents generate actions dynamically and can be influenced by content they process (prompt injection); apply defense in depth, not a single control. Use least privilege: mount only needed directories (prefer read-only), restrict network to specific endpoints, and drop Linux capabilities in containers. Inject credentials via a proxy outside the agent boundary so the agent never sees secrets; do not mount ~/.ssh, ~/.aws, .env, or similar into the agent.Default SDK behavior can leak one tenant's CLAUDE.md or settings into another session without isolation options. Auto memory at ~/.claude/projects/.../memory/ loads regardless of settingSources unless CLAUDE_CODE_DISABLE_AUTO_MEMORY=1. Each agent session maps to one subprocess—size RAM for concurrent tenants per hosting docs.allowedTools only pre-approves tools; it does NOT constrain bypassPermissions, where every tool runs. To block tools under bypass, use disallowedTools or scoped deny rules. Deny rules (for example Bash(rm *)) are enforced in every mode, including bypassPermissions; a bare-name deny removes the tool from context entirely. When the parent uses bypassPermissions, acceptEdits, or auto, subagents inherit it and cannot override per-subagent; prefer the least permissive mode that works.MCP servers that fetch external content can carry prompt injection—official security docs warn operators to verify trust before use. Project-scoped .mcp.json servers require trust verification and approval prompts in Claude Code before first use. Auto-approve or bypass permission modes increase injection blast radius—avoid for repos with untrusted inputs. Side-effect tools (write, bash, network) need explicit human gates when content origin is untrusted.
Privacy notesEven read-only code mounts can expose credentials in .env, ~/.git-credentials, ~/.aws, .npmrc, and key files; exclude or sanitize them before mounting. Route egress through a proxy that enforces a domain allowlist and logs requests, so a compromised agent cannot exfiltrate data to arbitrary hosts. The built-in sandbox proxy does not inspect TLS; for stronger guarantees use a TLS-terminating proxy with its CA installed in the agent's trust store.Session transcripts default to local disk under ~/.claude/projects/ unless mirrored with SessionStore. Per-tenant cwd should exclude other tenants' artifact directories. Proxy logs may capture tool URLs—apply retention policies per tenant policy.Permissions govern tool execution, not data flow; code and context still go to the model provider regardless of mode. The canUseTool callback sees tool inputs at runtime; avoid logging sensitive arguments from it. Settings-based allow/deny rules live in .claude/settings.json; keep secrets out of rule patterns.Injected prompts may exfiltrate data through tool arguments—scope OAuth tokens and filesystem paths narrowly. Logs of tool calls may contain injected instructions—restrict log sharing externally. Revoke MCP OAuth and remove servers promptly when injection is suspected.
Prerequisites
  • A Claude Agent SDK application you intend to run beyond a trusted local laptop.
  • Knowledge of which files, endpoints, and credentials the agent legitimately needs.
  • Container, sandbox, or VM tooling appropriate to your isolation choice.
  • Agent SDK application hosting multiple tenants in one container or host.
  • Per-tenant filesystem paths no other tenant can read.
  • Outbound proxy supporting per-tenant credentials or domain allowlists.
  • Understanding that default SDK behavior loads shared CLAUDE.md and settings from disk.
  • The Claude Agent SDK installed for Python or TypeScript.
  • Knowledge of which tools and command patterns the agent legitimately needs.
  • For settings-based rules, the project setting source enabled (default).
  • Inventory of MCP servers, plugins, and tools connected to Claude Code.
  • Team policy for permission modes and auto-approve settings.
  • Ability to test workflows in an isolated profile before production use.
  • Maintainer or security reviewer for side-effect tool approvals.
Install
Config
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed
Open 4 picks in the interactive comparison tool

Related guides

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.