ARTEX/docs/managed-execution-scope-and-audit.md

24 KiB

Managed execution scope and access audit

Status: partially implemented; Docker is the current execution backend. Reconciled on 2026-12-02 against main 8f91643. This PR updates the design and completion assessment only; it changes no runtime behavior, dependency or default.

The original 2026-11-27 Go/bubblewrap choice and fixed four-PR delivery order are superseded. Main already implements task isolation and scoped egress with Docker; there is no reason to build a second bubblewrap backend to satisfy those same requirements. The execution foundation has shipped, but the full audit and independent action-authorization design has not. Do not close the feature issues merely because commands run in containers.

Tracking: audit #553, runtime #554, design #555. The issue descriptions retain the earlier proposal; the matrix below identifies what this revision replaces and what remains an acceptance requirement.

Completion assessment

“Main” means code merged at the pinned baseline, not every platform qualified. “Pending PR” means implemented on a review branch, not available in main.

Original requirement Current status Evidence and remaining boundary
Isolated command execution and no silent host fallback Main: implemented with Docker agent/sandbox.go, server/sandbox.go, sandbox/docker.go. ARTEX_SANDBOX=required is the default; off explicitly degrades isolation. One worker container per task, not per logical worker/run.
Private execution network and final-dial scope checks Main: implemented for enrolled paths sandbox/policy.go, sandbox/proxy.go, docker-compose.yml. Per-task internal network and domain/CIDR proxy; panel HTTP/WebFetch have separate scope checks. This is not the entire proposed policy gateway.
Operator scope cannot be widened by agent-discovered assets Main: implemented with regression coverage server/sandbox.go, scope-drift tests, company-grant tests. Operator-approved scope and approved company snapshots; task intercept allow rules also enter the egress scope. Target-gate approval alone does not widen task egress.
Execution failure/timeout cleanup and deletion Main: hardened by merged #764 PR #764, exec cleanup tests, concurrency tests. Unprovable completion/timeouts remove the captured worker; Delete removes worker before network and retains failed cleanup state. This does not prove all policy-revocation/tunnel semantics.
Process and resource containment Main: baseline limits implemented Non-root worker, read-only rootfs, dropped capabilities, no-new-privileges, Docker CPU/memory/PID limits and bounded exec output. Whole-task network quotas, accounting across panel/MCP/proxy paths and a complete capability matrix remain open.
Connection metadata outside worker control Main: implemented Proxy-only egress.jsonl contains task, host/port, resolved address, decision/protocol and bytes. Main's CONNECT/SOCKS are opaque; these logs are not a full URL index.
Capture-independent HTTP(S) URL/time search Pending PR #596: implemented, not merged #596, reviewed head 203185f. Includes existing producers, Docker HTTPS inspection, task proxy authentication, trusted collection and SQLite search/UI. Read the limitations below before calling audit complete.
Exact task/run/tool/action/policy/approval provenance Partial / open #596 has trusted identities where available; Docker observations identify a task, not an exact worker/run/Bash invocation. A common policy-revision/approval/evidence graph is not implemented.
Recognizable secondary destinations and SSRF/RCE investigation Open Submitted-target and command/artifact indexing, exact triggering-action links and independently correlated receipts are missing. A remote second hop is outside Docker's network boundary.
One authoritative action/policy/budget contract for every executor Partial / open Scope checks, target gate, judge and scheduler budgets already exist. Typed deny/port/protocol/method/path rules, independent indirect-action authorization, cross-path consistency and bounded revocation need further implementation/qualification.
Remote-content prompt-injection protection Existing layers; end-to-end qualification incomplete Code-owned prompt tails, nonce framing and judge warnings exist. Docker bounds some resulting actions; neither Docker nor successful boundary unit tests proves model immunity or complete summary/handoff provenance.
Strict audit durability and complete coverage intervals Open #596 uses bounded best-effort queues/spools and reports detected loss. It does not stop all work on audit loss or implement a durable, complete coverage-interval ledger.
New Go/bubblewrap runtime as a release prerequisite Replaced by Docker Backend decision. Preserve the old document path for links; a future alternative requires its own demonstrated need and qualification.

Current architecture and trust boundaries

trusted panel: scheduler, model calls, judge, target approval, task scope
    |
    +-- authenticated runner API --> Docker daemon (trusted host control)
    |                                  |
    |                         task worker + descendants
    |                         task workspace, restricted runtime
    |                                  |
    |                         per-task internal network
    |                                  |
    |                         task egress proxy --> egress network --> target A
    |                         scope + pinned final dial
    |                         private connection log
    |
    +-- panel HTTP/WebFetch: separately enforced task scope
    +-- browser/MCP/file services: explicit coverage inventory required

remote target A --> target B is outside this execution boundary

The Docker socket belongs to the runner, not the worker. The runner is a privileged control-plane service, not a sandbox for attacker code. The logical agent/model loop remains in the panel. A task's logical workers and overlapping Bash calls share its container and writable workspace; this is task separation, not mutually distrusting per-agent/per-run isolation. A timeout destroying that worker also terminates sibling executions in the same task. Other tasks keep their own workers. Workspace contents survive worker recreation by design.

At the pinned main baseline the runner API is authenticated, but the worker-facing HTTP/SOCKS proxies do not yet require #596's task credentials. Broad CIDR grants must account for peer-proxy reachability; a private audit mount alone does not prove which task initiated a request through that proxy.

Bash and custom command tools use the runner when required. Native HTTP and WebFetch run in the panel and use task-scope validation/pinned dialers; they do not all traverse the same container proxy. Browser navigation guards are not proof that every browser subresource/socket is confined. Shared/remote MCP and file-tool paths need their own ownership, confinement and attribution evidence. Wrapping Bash must not be described as wrapping every tool, service or goroutine.

See agent/sandbox.go, server/customtool.go, server/sharedbrowser_guard.go and server/mcpdiscover_sandbox_test.go.

Scope enforcement already in main

The execution boundary has default-deny target permissions when no approved scope is available. Main's EgressPolicy authorizes domain suffixes and explicit IP/CIDR entries, resolves a destination and dials a selected permitted address. Private/metadata/IPv6 destinations are denied by default; explicit CIDR grants can authorize otherwise denied addresses. Do not describe that as an absolute metadata/private-address ban. Mixed DNS answers select a permitted address rather than rejecting the entire response just because another answer is denied.

HTTP, CONNECT and SOCKS5 TCP use this policy. Removing proxy environment variables does not give a worker a direct external route. SOCKS is still an allowed TCP transport, not URL-level inspection. DNS resolution is a separate deployment boundary; proxy destination checks alone are not proof that every DNS channel is contained. UDP, ICMP, QUIC, arbitrary browser traffic and remote executors do not inherit a blanket support claim.

The task gate/judge and the proxy are distinct enforcement layers. Scope lowering currently carries domains/CIDRs and supported task allow rules; it is not a versioned translation of every intercept deny rule or exact-host/port/path rule. Approval of a tool operation does not by itself approve a new network target. Conversely, an allowed target does not authorize every operation on that target.

Scope changes cause proxy reconciliation through task execution/scope snapshots. This is not a demonstrated immediate revocation channel for every in-flight request, pooled connection and existing tunnel. Pause/Kill targets worker processes and may preserve the proxy; Delete removes the proxy/network. Publish and test revocation semantics separately rather than inferring them from Delete.

Audit implementation in pending #596

The reviewed implementation is 203185f, not main. Its implementation/coverage documentation is the source for this section. It must be reconciled with newly merged main work, including #764, before merge; branch test results do not certify a future rebase.

  • native_http, WebFetch trace, local execution proxy, recording proxy and operator-reported imports are separately labeled producers. Docker adds docker_egress request/response-header/error observations while full capture is off. CONNECT alone is not a visited URL, and a response is not proof of business processing at the origin.
  • Each task proxy generates a persistent CA. Only the public trust bundle is mounted read-only into its worker; the signer and audit spool remain private. Upstream TLS verification and scope/pinned dialing stay enabled. HTTP and SOCKS require independent task credentials, preventing another task from borrowing proxy attribution merely because a broad CIDR includes both proxies.
  • The runner exposes authenticated, bounded, task-confined spool reads. The panel imports observations, deduplication keys and cursors transactionally. Docker task identity is supplied by the trusted collector, never by target headers. Unknown worker/run/tool-call identity stays unknown.
  • The chosen store is SQLite traffic/_index/access.sqlite, not the earlier proposed PostgreSQL metadata schema. There is no new PostgreSQL migration; 0024_task_scope_egress remains unrelated and untouched by #596. Retention is 30 days / 500,000 events; task/full-capture deletion does not delete this index.
  • Search supports URL/path substring, exact host, task, source and a bounded time window with keyset pagination. Userinfo, all query keys/values, fragments, headers and bodies are omitted. URL paths can still contain secrets. This is searchable redacted URL/path evidence, not preservation of every original URL byte or the full set of proposed event/filter fields.
  • Proxy spools keep two 4 MiB segments per task. Bounded asynchronous queues, rotation and crashes can lose records. Detected gaps and collection state are visible; normal task networking does not stop merely because audit persistence is unavailable. Startup readiness checks do not turn this into strict durable auditing. Runner-imported observations preserve producer time; HAR/extension reports currently use ingestion time and are labeled external reports.

TLS compatibility and deployment

The selected Docker audit mode decrypts HTTPS to observe paths. Certificate-pinned, mutual-TLS and HTTP/2-only clients are not supported by this inspection path; there is no silent opaque HTTPS fallback. Custom private origin CAs belong in the proxy image's trust store. Client curl -k does not disable upstream verification. SOCKS/raw TCP still have connection-only visibility, so full URL coverage is not universal even after this PR. Do not equate inspection with method/path enforcement.

Deploy matching panel, runner and egress-proxy images. #596 rejects an unready/old proxy image and recreates pre-audit workers to install the trust mount while preserving their workspace. A rollback must restore compatible components and workers; it must not silently set ARTEX_SANDBOX=off or erase retained audit data.

Remaining policy and authorization contract

Extend the existing scope/target-gate/judge and task budget mechanisms rather than creating a competing gateway or scheduler. The following are acceptance targets, not claims about current Docker behavior:

Area Remaining contract
Policy identity Server-owned policy ID/revision/digest, execution binding, effective/expiry/revocation state and approver reference; requests cannot self-select a stronger grant.
Rule semantics Typed host/IP/CIDR, address constraints, explicit deny precedence, port/protocol and optional method/path rules; document exact/suffix/IDNA and normalization behavior without silently changing existing rules.
Final hop Recheck the effective rule at the actual dial/request and each redirect; an upstream proxy must offer equivalent address enforcement or report unsupported.
Revocation Stop affected actions and established channels within a measured bound, including keepalive, CONNECT, SOCKS, WebSocket and SSE. Restart/scope-edit handling must not revive an old grant.
Indirect action Recognizable submitted secondary destinations and action classes receive deterministic scope checks plus applicable judge/operator approval. Unknown remote effects remain unresolved/reviewable, never implicitly authorized.
Control plane Narrow operational grants and protected credentials; model or returned text cannot change policy, approve itself, raise limits, disable audit or borrow a trusted actor identity.
Coverage Explicit contracts for panel-native HTTP, browser, MCP and file tools. Unsupported required capabilities reject that profile; the default Docker setting is not proof of universal enrollment.
Budgets Reuse existing task/intent token, turn and time accounting. Add request/byte/connection/redirect limits and aggregate enforcement across worker, proxy, panel and enrolled services; record limits, stop authority, overshoot and authorized resume.

Docker CPU/memory/PID settings and capped stdout are useful implemented limits; they do not finish this whole-task budget contract. Effective host capabilities, concurrent descendants, failure cleanup and limit exhaustion need measured tests. This status update does not requalify kernel isolation or workspace/download/ storage quotas. Those omitted areas must not acquire an unsupported guarantee.

Remote-content injection and indirect-access investigation

Retain the existing code-owned prompt rules, nonce framing, MCP-description boundaries and judge input rules. Returned pages, headers, MCP output, scanner output, downloaded artifacts and their summaries are untrusted data even when the destination was approved. Source IDs and roles must be assigned outside that text. Compaction, memory and handoff must preserve the distinction; neither summarization nor a forged “human approved” field may create authority.

The missing acceptance chain is: trusted source/artifact reference → proposed exact action → independent decision/policy revision → actual observation. Test it with inert fake roles, delimiters, operator claims, secret-read/callback requests, summary-to-next-turn propagation and benign quoted instructions. Assert the resulting authorization/network/file boundary independently of what the model says. Boundary unit tests are valuable, not a proof of model-level immunity.

Allowed-channel callbacks remain possible. An injected command can use an allowed HTTP(S)/SOCKS destination for data transfer or command exchange. Task isolation, TLS inspection and audit do not make reverse shells universally impossible. Stronger restrictions require explicit action/protocol/target policies and a corresponding compatibility decision.

A request from ARTEX to allowed target A can induce A to contact B. Neither Docker nor a local proxy controls A's network. The original #553 investigation requirement therefore remains open even if every direct request to A is collected:

  1. Index candidate command/script/artifact references and destinations actually submitted in supported query/form/JSON payloads, before general redaction. Keep bounded, versioned extraction, safe target structure, artifact digests and exact trusted action IDs; do not retain arbitrary raw bodies/queries by default.
  2. Distinguish command_reference, submitted_target, network_observation and independently sourced correlated_receipt. A URL merely quoted in a returned document is not an action or a visit. Extraction grants no authority and must not fetch the extracted URL or execute an artifact.
  3. Accept independently obtained callback/OAST or target receipts with real correlation. Host/time proximity alone does not establish a causal edge. Dynamic/opaque code can remain unresolved; Docker cannot prove a remote negative.
  4. Starting with only a reported destination/time window, expose the triggering task and exact action/artifact in the UI/API without live agent disk scanning. Concurrent tasks cannot borrow each other's evidence; archive references and unknown attribution remain explicit.

These are basic investigation requirements, not a new automatic honeypot detector. Keep target claims, observations, operator/judge assessments and corroboration separate. Do not turn a fabricated success response into a verified finding or use suspected honeytokens automatically. The existing advisory review guide helps check vulnerability claims; it does not implement an automated deception/evidence engine.

Audit contract still to complete

Preserve immutable/idempotent observations separately from assessments. Add exact policy/approval links, observation versus ingestion times, actual endpoint details, retry/redirect relationships, capture/artifact/archive references and budget/stop history only where instrumentation establishes them. Do not synthesize all those fields from today's smaller Event struct.

A direct socket blocked outside a proxy may have no per-destination event. A proxy 403 is not an upstream 403; a response-header event is not stream completion. A transcript match is an investigation candidate, not backfilled network history. Never display “no access” when only “no matching retained observation” is known.

The proposed strict audited profile additionally needs measured backpressure, explicit coverage intervals and refusal of new work when neither durable storage nor its bounded spool can accept required evidence. #596 does not implement that profile. Retention/administrative deletion, archived-task pointers and authorized raw evidence/export access need their own tested semantics; existing capture and archive features must remain usable. Do not weaken redaction to fill provenance fields or imply current audit rows are cryptographically tamper-proof.

Upstream distribution and migration contract

Docker execution is already required by default, including the standard Compose configuration. Do not document a new opt-in bwrap rollout or silently migrate users to off. Missing runner/token/daemon/images must fail required task execution with diagnostics; management/audit features do not thereby gain a new bwrap dependency. Preserve the explicitly degraded local mode and its warnings.

Keep all five controller release targets: Linux amd64/arm64, macOS amd64/arm64 and Windows amd64. See release workflow. Container build targets are Linux amd64/arm64; image publication is not equivalent to runtime qualification on every architecture/host. A controller ZIP does not bundle a Docker daemon or establish native macOS/Windows tool isolation. Docker Desktop, Linux guests and separately hosted runners require their own mount/network/trust and failure tests; only claim platforms actually qualified.

The runtime evaluation keeps earlier alternatives as dated research. Native non-Linux sandboxes, VM/gVisor profiles, general browser or nested-container support and fleet orchestration are separate proposals, not prerequisites for claiming the Docker baseline that already exists.

Revised delivery and exit gates

The fixed four-PR sequence no longer describes upstream history. Keep the original requirements as acceptance criteria; do not create three redundant implementation PRs or mark all requirements finished to preserve the old PR count.

Workstream Current disposition Next exit gate
#555 design Update to this Docker baseline and completion matrix Source-backed distinctions between merged, pending, replaced and open work. Documentation only.
Execution backend Already in main; #764 lifecycle fixes merged Maintain Docker regression coverage and qualify declared hosts/architectures; no replacement bwrap prerequisite.
#596 audit/search Direct observation and Docker audit implemented on its Draft branch Reconcile current main, retain safe collection/TLS/identity behavior, and complete the outstanding investigation acceptance before claiming the full audit feature complete.
Policy/action/budget work Existing controls plus remaining contracts above Review changes to the existing paths, with cross-executor policy, indirect-action, prompt-boundary, revocation and quota fixtures; no unimplemented “strict” label.
Additional runtimes/advanced analysis Optional follow-ups A concrete need, support contract, maintenance owner and separate qualification.

Use owned synthetic HTTP/TLS services, controlled DNS and inert artifacts. Required fixtures include scope denials, explicit CIDRs, DNS changes, redirects, missing proxy variables, native transports, task credential forgery, cross-task versus same-task behavior, long-lived channels, timeout/cancel/delete/restart, failed cleanup retry, capture-off collection, spool loss/restart/deduplication, TLS compatibility, and the A→B investigation cases above. Preserve existing capture, rewrite, HAR, archive and governance behavior. Unsupported environments are reported separately; a failed promised property must not be relabeled a skip.

Readiness requires measured functional/security acceptance and review. Passing automated checks does not complete an unmet product requirement. #596 remains Draft for its missing indirect-access investigation workflow; Docker execution itself is already implemented upstream.

Verification record and limits

The earlier cc01 Linux run for #596 head 203185f passed 48 focused Docker/security tests and skipped 3 PostgreSQL-dependent tests in that focused invocation. It covered owned HTTP/TLS targets, curl/Python, task-proxy impersonation across an allowed CIDR, read-only public CA, private-key separation, collection and cleanup. Broad regression/race runs had the known root/local-executor TestPrepareExecPrivilegeOwnsKeysAndConfigAsRoot failure, independently reproduced on then-main 0f22112. These are branch/host-specific results, not qualification of this newer main, all five platforms, every proposed budget or remote RCE effects.

For this documentation revision, validate local/pinned source links, consistent status/defaults, Markdown and git diff --check on the designated Linux checkout, and run focused existing nonce/prompt-tail/sandbox regressions. Record actual commands, base/head and skips in the PR description. No runtime deployment or new containment qualification is performed merely by updating this document.