Skip to main content
The Docker sandbox provides isolated execution for untrusted commands with multiple layers of security.

Overview

The sandbox system:
  • Runs commands in ephemeral Docker containers
  • Routes network traffic through a validating proxy
  • Injects credentials at the proxy boundary (never in containers)
  • Enforces resource limits (memory, CPU, timeout)
  • Scans for credential leakage in requests/responses

Architecture

Sandbox Policies

Three policies control filesystem and network access:

Quick Start

Prerequisites

  • Docker installed and running
  • Docker image built: docker build -t ironclaw-worker:latest -f Dockerfile.worker .

Check Docker Status

Output:

Enable Sandbox

Edit ~/.ironclaw/.env or set environment:
Or configure via wizard:

Usage

Execute Commands

The agent automatically uses the sandbox for commands:

Manual Execution (CLI)

For testing:

Programmatic Usage

Configuration

Environment Variables

Network Allowlist

The proxy allows requests to specific domains. Default allowlist includes: Package registries:
  • crates.io, static.crates.io, index.crates.io
  • registry.npmjs.org
  • proxy.golang.org
  • pypi.org, files.pythonhosted.org
Documentation:
  • docs.rs, doc.rust-lang.org
  • nodejs.org, docs.python.org
  • go.dev
Version control:
  • github.com, raw.githubusercontent.com
  • gitlab.com
Build tools:
  • dl.google.com (Android SDK)
  • download.qt.io
Extend the allowlist: Edit src/sandbox/config.rs and rebuild, or configure via environment:

Resource Limits

Default limits:
Customize via environment:

Credential Injection

Credentials are never passed to containers as environment variables. Instead:
  1. Container makes request with placeholder: https://api.github.com/user?token={GITHUB_TOKEN}
  2. Proxy intercepts and checks allowlist
  3. Proxy scans for leaked secrets in request
  4. Proxy replaces {GITHUB_TOKEN} with actual token
  5. Proxy executes request to external API
  6. Proxy scans response for leaked secrets
  7. Proxy returns response to container
Credentials are never visible inside the container.

Security Properties

Isolation

  • Non-root execution: Containers run as UID 1000
  • Read-only root: Container filesystem is immutable
  • Dropped capabilities: All Linux capabilities removed
  • No host network: Container uses internal network
  • Ephemeral: Containers are removed after execution

Credential Protection

  • No environment variables: Secrets not passed via ENV
  • Proxy injection: Secrets replaced at proxy boundary
  • Leak detection: Outgoing requests scanned for secrets
  • Response scanning: Incoming data checked for leakage

Network Control

  • Allowlist enforcement: Only approved domains accessible
  • Path prefix matching: Restrict to specific API endpoints
  • Rate limiting: Per-domain and global limits
  • HTTPS enforcement: No plain HTTP to remote hosts

Resource Control

  • Memory limits: Hard cap on container memory
  • CPU limits: Relative CPU shares
  • Timeout enforcement: Commands killed after timeout
  • Output truncation: Large outputs are truncated

Building the Worker Image

Dockerfile.worker

Build

Verify

Troubleshooting

Docker Not Available

Error: “Docker is not available”
  1. Ensure Docker is installed: docker --version
  2. Start Docker daemon: sudo systemctl start docker (Linux) or start Docker Desktop (Mac/Windows)
  3. Check permissions: docker ps (should not require sudo)
  4. Run doctor: ironclaw doctor

Image Not Found

Error: “Image ‘ironclaw-worker:latest’ not found”
Or enable auto-pull:

Network Requests Blocked

Error: “Host not in allowlist”
  1. Check the allowlist includes the host
  2. Add to allowlist in src/sandbox/config.rs
  3. For testing, use full_access policy (disables sandbox)

Timeout

Error: “Command timed out”
  1. Increase timeout: export SANDBOX_TIMEOUT=300
  2. Check if the command is hanging
  3. Test outside sandbox: ironclaw exec --policy full_access

Permission Denied

Error: “Permission denied” writing to /workspace
  1. Use workspace_write policy: export SANDBOX_POLICY=workspace_write
  2. Check ownership: ls -la /workspace
  3. Fix permissions: chown -R 1000:1000 /workspace

Advanced Usage

Custom Proxy Configuration

Per-Command Policies

Custom Resource Limits

Performance Considerations

  1. Container startup: ~1-2 seconds per execution
  2. Network proxy: Minimal overhead (~10ms per request)
  3. Credential scanning: Fast regex matching
  4. Output collection: Streamed, not buffered
Optimization tips:
  • Reuse containers when possible (future feature)
  • Use polling instead of creating containers per message
  • Batch commands where feasible
  • Keep allowlist focused (fewer regex matches)

Best Practices

  1. Use sandbox by default: Only disable for trusted operations
  2. Minimal allowlist: Only add domains you need
  3. Set timeouts: Prevent runaway commands
  4. Monitor logs: Watch for policy violations
  5. Test policies: Verify commands work with least privilege
  6. Keep images updated: Rebuild worker image regularly
  7. Limit memory: Prevent OOM on host

Next Steps