Skip to main content

Docker Sandbox

Commands classified as forbidden or restricted by the Dual-Tool Evaluator are executed in hardened Docker containers for isolation.

When Sandbox Is Used​

The sandbox is invoked when the evaluator classifies a command as:

  • Forbidden - Matches the forbidden_commands list
  • Restricted - Targets a path in the restricted_paths list
  • Unknown tool - Defense-in-depth for unrecognized tool names

Container Configuration​

Each sandbox execution creates a short-lived container with aggressive hardening:

SettingValuePurpose
network_disabledTrueNo network access
mem_limit256mMemory ceiling
CPU50%CPU limit
pids_limit100Process count limit
read_onlyTrueRead-only root filesystem
tmpfs/tmp:64MSmall writable scratch space
security_optno-new-privilegesPrevent privilege escalation
usernobodyNon-root user
cap_drop["ALL"]Drop all Linux capabilities
labels{"contop.sandbox": "ephemeral"}Container identification

Docker Desktop Auto-Start​

The server checks platform-specific paths for Docker Desktop and starts it if needed:

  • Polls the Docker daemon every 2 seconds
  • Waits up to 45 seconds for Docker to become available
  • Reports status to the mobile UI via real-time status callback messages

Fallback Without Docker​

When Docker is unavailable (not installed or failed to start), the sandbox falls back to a restricted host subprocess:

SettingValue
auto_confirmFalse (always requires confirmation)
timeoutmin(timeout_s, 10) - 10 seconds maximum
Output limit50 KB (standard max_output_bytes default)

This fallback is intentionally restrictive - it prevents unattended execution of potentially dangerous commands without Docker's isolation guarantees.

Environment Sanitization​

The sandbox container does not inherit the host's environment variables. Sensitive variables (API keys, tokens) are never passed to the container.

Base Image​

The Docker container uses python:3.12-slim as its base image. The image is pulled on first use if not present locally.


Related: Dual-Tool Evaluator · Core Tools · Security Overview