Skip to main content

Threat model

This page consolidates the threat tables from three plans and the findings logs: the gateway model (P2.G plan section 11), the sandbox model (P2.5 plan section 9, threats T1 to T17) and the factory model (P3 plan section 9, threats F1 to F16). Test ids (GW…, SEC…, SB-…, FX-…) refer to the acceptance checks named in those plans; the findings logs in docs/p2-findings.md record which ran and how. Anything a plan lists as residual or UNVERIFIED is repeated here as such.

Assets​

AssetWhere it livesWhy it matters
Model provider key (ANTHROPIC_API_KEY)gateway process env onlyspend and data access at the provider
Gateway control tokens (GATEWAY_CONTROL_TOKEN_API, GATEWAY_CONTROL_TOKEN_WORKER)gateway env; the api and core worker read their own one from a _FILEminting job tokens = spending under any ledger row
Job tokens (afj_ + 43 chars)gateway memory (sha256 only); runtime env for one turnmodel calls charged to one ledger row
Subject tokens and exchanged tokens (OBO)gateway memory (SubjectTokenCache), zeroed on deleteuser-scoped access to MCP servers
Ledger, audit, settings (gateway_audit, settings.agents_disabled)Postgresthe spend control, the kill switch, the evidence trail
Temporal payload keys (TEMPORAL_PAYLOAD_KEYS)api, workers, fleet exec hostsprompts and transcripts cross Temporal encrypted
GitHub App private keys (read-pr, push)factory worker memory, from _FILE mountsrepository write access (push is fork-only)
Database credential (DATABASE_URL)api, core worker, gateway; never on a fleet exec hosteverything above that is in Postgres
Target repository content and patchessandbox volume, host extraction dirsupply-chain integrity of what reaches a PR

Actors​

Gateway threats (P2.G plan section 11)​

ThreatVectorControl (built)Tests
SSRF, model sideclient-controlled path, host or Host header steers the upstream requestconstant upstream URL; exact path match; Host dropped; redirect: 'error'; loadConfig pins https://api.anthropic.com and refuses unsafe Node TLS and proxy settingsGW2, GW17, GW-CFG, SEC1
Content-borne SSRF and exfiltrationurl image or document sources fetched by the providercontent-block allowlist (base64 images only)GW7b
SSRF, MCP sidetool args or registry steer the MCP targetendpoints only from the compiled registry; host in egressAllow; https only; pinned fetch, no redirects, no OAuth discoveryGW21, GW22, GW33, GW36, GV7
MCP server-to-client requestsupstream sends sampling/createMessage, elicitation/create, roots/listno client capabilities declared; any server request fails the session (server_request_denied)GW35
Tool metadata poisoning and rug-pullupstream description or inputSchema change or carry instructions; pattern ReDoSregistry description wrapped as untrusted; schema sha256 pin; pattern, patternProperties, uniqueItems refused; strict ajvGW38, GW39
Untagged result contentstructuredContent, image, resource bypass the text wrappertext-only results, the rest stripped and audited (content_stripped)GW37
Token replayleaked job token reused by another job or after the turnopaque gateway-minted token, hash-only storage, TTL tied to the turn, revoke on settle, bound to one ledger row, client and grants; stale row returns 401 on both pathsGW1, GW34, GW-CTL, OB4, SEC2
Token theft from logs or argvtoken in logs, audit, errors, argvredaction pattern for afj_…, no header logging, audit has no tokens; sandbox token only in a 0600 env fileGW15, OB5, SEC3
Header smugglinganthropic-beta enabling server tools, x-forwarded-*, cookieonly anthropic-version and allowlisted betas are forwardedGW17, SEC4
Request smuggling and desyncCL+TE, obs-fold, duplicate Content-Lengthstrict Node parser (never insecureHTTPParser), body re-serialized, one upstream fetch per requestGW17, SEC5
JSON parser differentialduplicate keys, __proto__canonical re-serialization of the validated tree; strict Zod; a __proto__ key is a disallowed field (403)GW18, SEC6
Response streamingstalls, huge lines, wrong content type, client abort leaking spendidle and total timers, 1 MiB SSE line cap, content-type allowlist, abort propagation, worst-case charge on missing usageGW9 to GW11, GW20
DoSbody bombs, YAML alias bombs, connection floods, registration floods, parallel streams, unauthenticated floods loading the DBbody cap, read timeouts, per-job and global concurrency, rate limits, GATEWAY_MAX_JOBS, maxAliasCount: 0, pre-auth per-source limit, token check before any DB queryGW19, GW20, OB7, GV1e, SEC8, SEC13
Spend bypassparallel calls, abort before usage, lying max_tokens, thinking budget, many small imagesatomic conditional debit of the worst case before the upstream call, max_tokens required and capped, budget_tokens below max_tokens, per-image termGW5, GW6, GW8b, GW9, SEC9
Control-plane exposure and grant mintingsandbox reaches registration and mints itself grantsseparate listener on one explicit IP, two route-scoped tokens, gateway-compiled grants (caller names policy ids only), control routes absent on the data port (404)GW-CTL, GW-CTL2, SEC10, SEC10b
Kill switch and DB outagegateway keeps spending when disabled or the DB is downper-request read, fail closedGW12, GW13, SEC11
Secret exposure to the runtimekey reaches the runtime env or filesystemgateway is the only holder; runtime gets only the job token; /health returns {status} onlyGW15, GV3, SEC12

Residual risks accepted in the plan: gateway compromise equals key compromise; prompt injection through tool results (tagging is advisory to the model, least privilege is the control); in-memory registrations lost on restart (fail closed).

Sandbox threats (P2.5 plan section 9)​

IdThreatControlResidual
T1Key theft from env, fs or /prockey only in the gateway container; sandbox env holds only the job tokennone listed
T2Job-token abusegateway grants (model, cap), worst-case debit on one row, TTL bound to the turn, revoke on terminalnone listed
T3Network exfiltration (TCP, UDP, DNS tunnelling, metadata IP, host bridge, IPv6)one --internal network per job with gateway_mode_ipv4=isolated, gateway as the only peer, --dns 127.0.0.1none listed
T4Exfiltration through the gatewaycontent-block and tool-type allowlists; no MCP grantsthe prompt itself goes to the provider (accepted)
T5Control-plane reachcontrol listener not on the job network; control tokens never in the sandboxnone listed
T6Container escape and privilegeuid 10001, --cap-drop ALL, no-new-privileges, read-only rootfs, default seccomp and AppArmor, no docker socket, no host mountskernel 0-days on a kernel shared with the gateway; needs a dedicated sandbox host or runsc before untrusted repos (G2-VPS)
T7Token sniffing and cross-job reachper-job network, no CAP_NET_RAW, one job per containertiming channels through shared gateway limits (accepted)
T8Resource exhaustionpids, memory, CPU, tmpfs limits; timeoutMs; gateway stream timersnone listed
T9Spawner as escape hatch (docker access is host root)argv arrays, no shell, image and flags only from config, assertSafeArgvworker is host-root-equivalent (OQ-1: rootless Docker on a dedicated host or a containers/create validating launcher)
T10Untrusted event stream (forged result)Zod and size caps; cost from the gateway only; success needs container exit 0none listed
T11Persistence across jobsread-only rootfs and store; per-job tmpfs volume; tmpfs HOMEnone listed
T12Git credential or pushno GitHub token in the sandbox; no egressnone listed
T13Version drift of the CLIallowlists frozen to FROZEN_FOR_SDK (0.3.322), guard test SB-FRZ1Console line-item comparison F2 UNVERIFIED
T14Host-side workspace extractionextractor never creates links or special files, refuses .. and absolute paths, caps size and entriesnone listed
T15Gateway flood and kill-switch stormpre-auth limiter, per-job limits; SandboxRuntime polls the kill switchnone listed
T16Capture sidecar and pcap handling (test harness)pcaps in 0700 temp dirs, deleted by traptest harness only
T17role: "system" messages from the sandboxsame strict block allowlist as user text; tool blocks in system messages refusedif the gateway ever injects operator system messages, this needs re-review

Factory threats (P3 plan section 9)​

IdThreatControlResidual
F1Prompt injection via repo content, task or contextsandbox without credentials, gateway-only egress, patch filter, secret scan, model-less no-network test run, human approval of the exact digest, secret-less fork CIa subtle malicious change in allowed source; the human reviewer is the control
F2Patch smuggling (symlinks, submodules, .gitattributes, renames into CI, .., .git/)parser, protected paths, git apply --check, post-apply index re-check, hardened git confignone listed
F3Secrets in diffskey-shaped and exact-minted-token scannone listed
F4GitHub token thefttokens only in factory worker memory; GIT_CONFIG_* env; redaction; push only to the forknone listed
F5CI secret theft via PRfork-only PRs, secret-less fork CI, maintainer approvalnone listed
F6Forged completion or statuscompletion = host extraction plus validated out file plus docker-observed exitnone listed
F7Approval forgery or replayapproval row authored by the authenticated API; digest, expiry, single consumption in Postgresnone listed
F8Host code executionhost runs only allowlisted git subcommands with hooks and filters disabled, and dockernone listed
F9Spendper-step row cap, gateway hard cap per row, iteration bound, daily caps, kill switchnone listed
F10Sandbox escapededicated sandbox host or runscrunc is refused unless FACTORY_ALLOW_RUNC=throwaway-repo-only
F11Spawnerargv contract (T9)OQ-1 before a VPS
F12Artifact disclosureartifacts scoped by job client; redactionnone listed
F13Reviewer manipulationreviewer verdict only gates the loop, never the PRnone listed
F14Maintainer workstation (.envrc, editor tasks, prepare hooks)protected-path defaults, parsed package.json checks, PR-body warningnone listed
F15App key or worker compromisetwo GitHub Apps (read-pr org-wide, push fork-only), hardened git env, per-repo tokens in memorypublisher separation deferred (OQ-P3-6)
F16Approval-to-push TOCTOUopenPr re-derives from the approved artifact and re-validatesnone listed

Details of F2, F6 and F7 are in Patch policy and Gates and approvals.

Deployment threats (fleet and network)​

ThreatControlStatus
Neighbour on the shared swarm ingress overlay reaches the control port once the data port is publishedGATEWAY_CONTROL_BIND_CIDR binds control to the private overlay address onlycoded, not released (ADR 0008); launch publishes no gateway port (ADR 0005)
Fleet exec host with stolen credentialsexec role refuses DATABASE_URL, ANTHROPIC_API_KEY, GATEWAY_CONTROL_*, GITHUB_APP_*; holds only payload keys and a gateway URLbuilt (FL-3)
Fleet host polls or fails any Temporal queuetailnet ACL only; Temporal 1.23 OSS cannot restrict by task queue (R-5)accepted residual
Tokens and prompts in plain HTTP on the tailnetWireGuard tunnel; GATEWAY_HTTP_ALLOWED_HOSTS must name each plain-http host exactlyaccepted (owner decision)
Gateway restart drops all live tokensturns retry and re-registeraccepted (ADR 0001 consequence)

Sources​

  • .omc/plans/p2g-governance-gateway.md section 11 (gateway threat model) and section 12 (failure modes)
  • .omc/plans/p25-sandbox-spike.md section 9 (T1 to T17)
  • .omc/plans/p3-software-factory.md section 9 (F1 to F16)
  • docs/p2-findings.md sections "P2.G S1 security fixes", "P2.G S3 security fixes", "P2.5 security fixes and P2.5-3", "P3-3 security conditions", "P3 security review (independent)", "Production deploy: answers from the fleet sessions"
  • docs/design-gateway-fleet-exposure.md, docs/deploy-worker-fleet.md, docs/deploy-sandbox.md, docs/deploy-factory.md
  • docs/sessions/2026-11-15-app03-deploy-and-smoke/adr/0005-gateway-publishes-no-port-at-launch.md, docs/sessions/2026-11-16-codecrucible-and-gateway-cidr/adr/0008-gateway-control-bind-cidr.md
  • apps/worker/src/exec-config.ts (EXEC_FORBIDDEN), apps/gateway/src/allowlists.ts (FROZEN_FOR_SDK), packages/db/src/schema.ts (gateway_audit)