9.9 KiB
ARTEX Sandbox MVP (docker-compose.sandbox.yml)
The sandbox overlay separates the privileged panel (artex, holding
PostgreSQL credentials, jwt.key, secret.key, config.json, and LLM keys)
from disposable per-task worker containers (artex-worker:local).
Components
artex(panel): API, UI, DB-only tools (report_finding,insert_assets,record_fact). Never mounts/var/run/docker.sockand never executes agent commands locally whenARTEX_SANDBOX=required(default).artex-runner(:8789on internalrunner-net): The only service mounting an engine socket. The host side comes fromARTEX_DOCKER_SOCK(default/var/run/docker.sock, set automatically for rootless Podman), and it is always mounted at/var/run/docker.sockinside the runner so that path is the only one the runner ever dials. RequiresAuthorization: Bearer $ARTEX_RUNNER_TOKENon every endpoint includingGET /v1/health. Creates and tracks one worker + one egress proxy per task by Docker label (artex.task=<id>).artex-worker-<id>(artex-worker:local): Runs as10001:10001,--read-only,--cap-drop ALL,--security-opt no-new-privileges:true,--pids-limit 512,--memory 2g,--cpus 2, boundedtmpfson/tmpand/home/exec, mounted only with/app/data/tasks/<id>:/workspace:rw, and attached only to the per-taskinternal: truenetworkartex-task-<id>.artex-egress-<id>(artex-egress-proxy:local): Attached toartex-task-<id>andegress-net. Enforces the task's domain suffix and CIDR allowlists (deny by default, blocking RFC1918, loopback, link-local, metadata endpoints169.254.169.254,fd00:ec2::254,168.63.129.16,100.100.100.200, and IPv6 unless explicitly inARTEX_SCOPE_CIDRS) on both HTTP/HTTPS CONNECT (:3128) and SOCKS5 (:1080) with DNS pinning (no rebinding window). Logs one JSON line per connection to/app/data/egress-audit/<id>/egress.jsonland stdout.
Running with the sandbox
The runner, worker and proxy are part of docker-compose.yml and
docker-compose.ghcr.yml. install.sh and update.sh generate
ARTEX_RUNNER_TOKEN and build the three images:
./install.sh # first install
./update.sh # existing checkout
Manual, from a source checkout (put ARTEX_RUNNER_TOKEN in .env once):
docker compose build artex artex-runner
docker compose --profile build-only build artex-worker artex-egress-proxy
docker compose up -d
From the published images:
docker compose -f docker-compose.ghcr.yml --profile build-only pull
docker compose -f docker-compose.ghcr.yml up -d
docker-compose.sandbox.yml is kept as a compatibility overlay; it is no longer
required.
Breaking change: ARTEX_SANDBOX=required by default
Starting with this release, ARTEX_SANDBOX defaults to required. If
artex-runner is unavailable, ARTEX refuses to start new tasks and pauses
running tasks rather than falling back to local execution on the panel.
To opt out explicitly in development (degraded mode — logs a prominent startup
warning banner and records sandbox=off in every task event log):
ARTEX_SANDBOX=off
Tool availability in required mode
Task commands use the tools installed in the worker image. The stock worker includes Bash, curl, DNS utilities, Git, jq, Nmap, and Python. The panel and worker have separate package lists in the panel Dockerfile and the worker Dockerfile. The task egress policy also applies to any runtime dependency downloads initiated inside the worker.
Finding retests run in a conversation without a task sandbox context. In required mode, Bash reports a missing task sandbox context and WebFetch can reject the request for lack of a task egress policy. When these restrictions prevent verification, a retest may return Cannot confirm. Check the retest transcript for the reason before interpreting the result.
Security Hardening Notes
Worker cleanup after execution errors
Command timeout, cancellation or a broken execution stream removes the worker
container that ran the command. The runner also removes it when Docker cannot
confirm that the exec has finished. This terminates detached children and all
other concurrent commands and background services in that task. The next exec
recreates the worker; the task's /workspace directory survives. Successful
commands keep their worker and may leave intentional background services running.
Cleanup uses the captured container ID, so a delayed completion cannot remove a replacement worker or another task's worker. Failed removal returns an error and keeps the worker tracked for retry. Deleting a task removes its worker before its proxy and network, including when no application processes remain in the worker.
Run the unit and simulated Engine tests with go test -race ./sandbox. On a
dedicated Docker host with the sandbox images built, enable the detached-child
cleanup test with:
ARTEX_SANDBOX_DOCKER_TEST=1 go test ./sandbox -run TestDockerTimeoutRemovesDetachedChild -v
-
Tamper-proof egress audit log:
artex-egress-<id>writes JSONL connection logs to a proxy-only bind mount (/app/data/egress-audit/<id>/egress.jsonl, mounted at/audit:rwinside the proxy) and stdout. The worker container only mounts/app/data/tasks/<id>:/workspace:rwand cannot read, truncate, or forge the egress audit log. -
Kernel-backed kill-switch (no agent-writable state):
artex-worker-<id>runs/usr/local/bin/artex-exec-wrap --initas PID 1 (reaping all orphaned children). OnPOST /v1/tasks/{id}/kill,artex-runnerexecutes/usr/local/bin/artex-exec-wrap --kill-uid 10001as uid10001(preserving--cap-drop ALL) scanning/procdirectly (defeatingsetsid,nohup, nested double-forked daemons,trap '' TERM, and/tmptampering), verifies zero non-PID-1 uid-10001 processes remain, and falls back to force-removing the worker container if any check fails. -
Browser &
WebFetchcontainment: InARTEX_SANDBOX=requiredmode, local stdio MCP servers (including the default private browser MCP) are skipped on the panel;WebFetchenforces the task'ssandbox.EgressPolicyon every URL, redirect hop, and pinned dial (with direct retry disabled); and the opt-in panel-hosted shared browser MCP is only attached whentarget_gateis enabled or an explicit egress proxy is configured, with every browser navigation URL gated against the task'ssandbox.EgressPolicy(execution containment + scope-gated panel fetch/browser; full subresource browser network isolation requires running the shared browser behindegress-guardinEGRESS_MODE=enforce). -
No scope drift (
approved_by_operator): Only operator-approvedtask_scoperows (approved_by_operator = true, set exclusively via the operator API/UI orTaskCreateOptions.CompanyIDs) and operatortask_intercept_rulesgrant sandbox egress to Bash,WebFetch, and the shared browser. Agent-added (add_task_scope), auto-added (insert_assets), and expanded rows are coverage-only (approved_by_operator = false). Tasks with no approved scope deny all egress by default.
Operator Scope Writers & Archive Restore Semantics
| Write path | Sets approved_by_operator |
Notes |
|---|---|---|
POST /api/tasks (TaskCreateOptions.CompanyIDs, operator API) |
true |
Operator-selected companies at task creation |
POST /api/tasks/{id}/scope (AddOperatorScope) |
true |
Operator API/UI; promotes existing unapproved coverage row if present |
POST /api/tasks/{id}/retarget (db.RetargetTask) |
true |
Operator retarget to a newly provisioned target host |
add_task_scope (AddAgentScope) |
false |
Agent coverage-only (even if source="manual" is passed) |
insert_assets (AddAutoScope) |
false |
Auto-discovered coverage-only |
spawn_task (CompanyScopeByAgent: true) |
false; true only for a company whose whole inventory the operator approved and the calling task is itself operator-approved for |
Standing consent inherits only through the caller's trust boundary (#841); a spawn with no task caller (chat session, direct API) stays coverage-only pending operator confirmation (#830) |
Archive restore (restoreTaskScopes) |
preserved (false if absent) |
Post-0023 archives preserve approved_by_operator; legacy pre-0023 archives default to false (fail-closed — operators must re-approve scope rows before sandbox egress is granted) |
Target-Gate Approval vs. Worker Egress (MVP Behavior)
In ARTEX_SANDBOX=required mode, target-gate approval only clears the tool-call approval gate; worker egress (as well as sandbox WebFetch and shared-browser navigation) still requires an operator-approved Task Scope entry (POST /api/tasks/{id}/scope) or a task allow rule.
This behavior is surfaced explicitly rather than failing silently:
- Approving a pending target-gate request via
POST /api/intercept/pending/{id}/decideorPOST /api/intercept/pending/batch-decideincludessandbox_egress_notein the JSON response whenARTEX_SANDBOX=required. - Every sandbox egress denial from the per-task proxy (
HTTP 403),WebFetch, and the shared browser states verbatim that target-gate approval only clears the tool gate and directs the operator to approve the target in Task Scope.
Upgrade Notes (Migration 0023)
- Migration
0023_task_scope_operator_approval.sqladdstask_scope.approved_by_operator BOOLEAN NOT NULL DEFAULT FALSEand backfillsapproved_by_operator = TRUEfor all existingsource = 'manual'rows so upgraded operator-scoped tasks retain sandbox egress immediately. - Goal-derived/agent scopes (
source = 'agent', created viaadd_task_scope) and auto-discovered scopes (source = 'auto', created viainsert_assets) remainapproved_by_operator = FALSE(coverage-only) and must be re-approved once via the Task Scope UI (POST /api/tasks/{id}/scope) if sandbox egress is required for those hosts.