Overview
IronClaw’s Docker sandbox system provides complete isolation for executing untrusted commands. All tool executions run in ephemeral Docker containers with strict resource limits, network controls, and security constraints.
Architecture
Sandbox Policies
Policy Selection
IronClaw automatically selects the appropriate policy based on the tool being executed:
- Bash tool:
WorkspaceWrite for commands that modify files
- Read tool:
ReadOnly for read-only operations
- Write/Edit tools:
WorkspaceWrite when modifying files
Security Properties
No Credentials in Containers
Environment variables containing API keys and secrets never enter containers. Instead:
- The network proxy intercepts outgoing HTTPS requests
- Credentials are injected by the proxy on the host
- Containers only see
http_proxy and https_proxy environment variables
Network Isolation
All network traffic routes through a validating HTTP proxy:
Requests to non-allowlisted domains are blocked at the proxy level.
Container Security
- Non-root execution: Containers run as UID 1000
- Read-only root: Container filesystem is read-only (except workspace mount)
- Capability dropping: All Linux capabilities dropped, only essential ones added back
- Auto-cleanup: Containers are removed after execution (
--rm + explicit cleanup)
- Timeout enforcement: Commands are killed after the timeout (default: 120s)
Resource Limits
Container Configuration
Environment Variables
Containers receive:
No API keys or secrets are passed directly.
Volume Mounts
Tmpfs Mounts
Ephemeral storage for build artifacts:
Docker Connection
IronClaw tries these socket locations in order:
$DOCKER_HOST (if set)
/var/run/docker.sock (Linux default, OrbStack, Podman Desktop)
~/.docker/run/docker.sock (Docker Desktop 4.13+)
~/.colima/default/docker.sock (Colima)
~/.rd/docker.sock (Rancher Desktop)
$XDG_RUNTIME_DIR/docker.sock (rootless Docker)
/run/user/$UID/docker.sock (rootless fallback)
Configuration
Environment Variables
Programmatic Configuration
Execution Flow
- Initialization: Manager connects to Docker, starts network proxy
- Container Creation: Create ephemeral container with policy-based mounts
- Command Execution: Run command in container with timeout
- Output Collection: Collect stdout/stderr (max 64KB)
- Cleanup: Remove container, return results
Example Execution
Troubleshooting
Docker Not Available
Image Pull Failures
Network Proxy Issues
Check proxy logs:
Resource Limit Errors
Increase limits if commands are being killed:
Advanced Topics
Custom Network Allowlist
Add domains to the allowlist:
Credential Injection
The network proxy automatically injects credentials for allowed domains:
Default mappings:
- GitHub:
GITHUB_TOKEN → Authorization: Bearer <token>
- npm:
NPM_TOKEN → Authorization: Bearer <token>
- PyPI:
PYPI_TOKEN → Authorization: Bearer <token>
Bypassing the Sandbox
For trusted operations, use FullAccess policy:
FullAccess policy runs commands directly on the host without any isolation. Use only for trusted operations.
Source Code
Key files:
src/sandbox/mod.rs - Module overview and exports
src/sandbox/manager.rs - Sandbox manager lifecycle
src/sandbox/container.rs - Docker container creation and execution
src/sandbox/config.rs - Configuration and resource limits
src/sandbox/proxy/mod.rs - Network proxy implementation