Securely Deploying AI Agents A guide to securing Autohand Code and Agent SDK deployments with isolation, credential management, and network controls.
← Back to Hosting
This guide covers threat models, built-in security features, security principles, isolation technologies, credential management, and filesystem configuration for secure Agent SDK deployments.
Understanding the threat model is essential for securing Agent SDK deployments. Consider the following attack vectors:
Prompt injection: Malicious inputs attempting to manipulate agent behavior
Tool abuse: Agents using tools to access unauthorized resources
Credential exposure: API keys or secrets being leaked
Data exfiltration: Sensitive data being extracted through agent outputs
Sandbox escape: Breaking out of isolated environments
Refer to the model card for detailed information about model capabilities and limitations.
Permissions System
Every tool and bash command can be configured to allow, block, or prompt the user for approval. Use glob patterns to create rules like “allow all npm commands” or “block any command with sudo”. Organizations can set policies that apply across all users. See permissions for details.
Static Analysis
Before executing bash commands, the SDK runs static analysis to identify potentially risky operations. Commands that modify system files or access sensitive directories are flagged and require explicit user approval.
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.
Establish clear security boundaries between the agent and your systems:
Separate agent execution from production infrastructure
Use network segmentation to limit agent access
Implement filesystem isolation for code and data
Apply least privilege to all agent operations
Grant agents only the minimum permissions needed to complete their tasks:
Restrict tool access to only necessary tools
Limit filesystem access to specific directories
Use role-based access control for different agent types
Regularly audit and remove unnecessary permissions
Implement multiple layers of security controls:
Container isolation
Network restrictions
Filesystem controls
Request validation at a proxy
The sandbox runtime provides OS-level isolation for agent execution:
Filesystem
Uses OS primitives (bubblewrap on Linux, sandbox-exec on macOS) to restrict read/write access to configured paths.
Network
Removes network namespace (Linux) or uses Seatbelt profiles (macOS) to route network traffic through a built-in proxy.
Configuration
JSON-based allowlists for domains and filesystem paths.
npm install @anthropic-ai/sandbox-runtime
Limitations
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: The proxy allowlists domains but doesn’t inspect encrypted traffic. If the agent has permissive credentials for an allowed domain, ensure it isn’t possible to use that domain to trigger other network requests or to exfiltrate data.
Docker containers provide additional isolation layers:
Recommended Docker Configuration
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
Security Flags Explained
--cap-drop ALL: Drop all Linux capabilities (except NET_ADMIN and SYS_ADMIN which are needed for networking)
--security-opt no-new-privileges: Prevent processes from gaining additional privileges
--security-opt seccomp=...: Apply seccomp profile to restrict system calls
--read-only: Make container filesystem read-only (use tmpfs for writable directories)
--tmpfs /tmp:...: Create in-memory filesystem for temporary files
--network none: Disable networking (use proxy socket for controlled access)
--memory 2g: Limit memory usage
--pids-limit 100: Limit number of processes
--user 1000:1000: Run as non-root user
-v ...:/workspace:ro: Mount code as read-only (prevents agent from modifying code)
-v .../proxy.sock:...: Mount proxy socket for controlled network access
Additional Security Measures
Avoid mounting sensitive directories like ~/.ssh, ~/.aws, ~/.config
Use --userns-remap for user namespace remapping
Use --ipc private for IPC namespace isolation
gVisor provides user-space kernel for stronger isolation:
** Configure Docker to use gVisor **
** /etc/docker/daemon.json **
{
" runtimes " : {
" runsc " : {
" path " : " /usr/local/bin/runsc "
}
}
}
**Run with gVisor**
docker run --runtime=runsc agent-image
For the strongest isolation, use virtual machines. Consider:
AWS Nitro Enclaves
Google Confidential Computing
Azure Confidential Computing
Firecracker microVMs
VMs provide kernel-level isolation and are suitable for high-security deployments.
For cloud deployments, follow these security practices:
Run agent containers in a private subnet with no internet gateway
Configure cloud firewall rules (AWS Security Groups, GCP VPC firewall) to block all egress except to your proxy
Run a proxy (such as Envoy with its credential_injector filter) that validates requests, enforces domain allowlists, injects credentials, and forwards to external APIs
Assign minimal IAM permissions to the agent’s service account, routing sensitive access through the proxy where possible
Log all traffic at the proxy for audit purposes
The proxy pattern centralizes credential management:
Benefits
The agent never sees the actual credentials
The proxy can enforce an allowlist of permitted endpoints
The proxy can log all requests for auditing
Credentials are stored in one secure location rather than distributed to each agent
For API Requests
export AUTOHAND_BASE_URL = " http://localhost:8080 "
For All Traffic
export HTTP_PROXY = " http://localhost:8080 "
export HTTPS_PROXY = " http://localhost:8080 "
Recommended Proxy Solutions
Envoy Proxy: Production-grade proxy with credential_injector filter for adding auth headers
mitmproxy: TLS-terminating proxy for inspecting and modifying HTTPS traffic
Squid: Caching proxy with access control lists
LiteLLM: LLM gateway with credential injection and rate limiting
Custom Tools
No TLS interception: The external service makes authenticated requests directly
Credentials stay outside: The agent only sees the tool interface, not the underlying credentials
Traffic Forwarding
To intercept all traffic (including from tools):
Running the proxy outside the agent’s container
Installing the proxy’s CA certificate in the agent’s trust store (so the agent trusts the proxy’s certificates)
Configuring HTTP_PROXY/HTTPS_PROXY to route traffic through the proxy
For Node.js, use NODE_USE_ENV_PROXY=1 to ensure fetch() respects proxy settings. Alternatively, use tools like proxychains .
Mount code as read-only to prevent agents from modifying it:
docker run -v /path/to/code:/workspace:ro agent-image
Files to Exclude
Ensure your .dockerignore excludes sensitive files:
.env
.env.local
~ /.git-credentials
~ /.aws/credentials
~ /.config/gcloud/application_default_credentials.json
~ /.azure/
~ /.docker/config.json
~ /.kube/config
.npmrc
.pypirc
* -service-account.json
* .pem
* .key
Use tmpfs for writable directories that don’t need persistence:
docker run --read-only --tmpfs /tmp:rw,noexec,nosuid,size=100m --tmpfs /workspace:rw,noexec,size=500m agent-image
Benefits of tmpfs
Data is stored in memory, not on disk
No persistence between container restarts
Can set size limits to prevent resource exhaustion
Can disable execution with noexec