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
| Asset | Where it lives | Why it matters |
|---|---|---|
Model provider key (ANTHROPIC_API_KEY) | gateway process env only | spend 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 _FILE | minting job tokens = spending under any ledger row |
Job tokens (afj_ + 43 chars) | gateway memory (sha256 only); runtime env for one turn | model calls charged to one ledger row |
| Subject tokens and exchanged tokens (OBO) | gateway memory (SubjectTokenCache), zeroed on delete | user-scoped access to MCP servers |
Ledger, audit, settings (gateway_audit, settings.agents_disabled) | Postgres | the spend control, the kill switch, the evidence trail |
Temporal payload keys (TEMPORAL_PAYLOAD_KEYS) | api, workers, fleet exec hosts | prompts and transcripts cross Temporal encrypted |
| GitHub App private keys (read-pr, push) | factory worker memory, from _FILE mounts | repository write access (push is fork-only) |
Database credential (DATABASE_URL) | api, core worker, gateway; never on a fleet exec host | everything above that is in Postgres |
| Target repository content and patches | sandbox volume, host extraction dir | supply-chain integrity of what reaches a PR |
Actors
Gateway threats (P2.G plan section 11)
| Threat | Vector | Control (built) | Tests |
|---|---|---|---|
| SSRF, model side | client-controlled path, host or Host header steers the upstream request | constant upstream URL; exact path match; Host dropped; redirect: 'error'; loadConfig pins https://api.anthropic.com and refuses unsafe Node TLS and proxy settings | GW2, GW17, GW-CFG, SEC1 |
| Content-borne SSRF and exfiltration | url image or document sources fetched by the provider | content-block allowlist (base64 images only) | GW7b |
| SSRF, MCP side | tool args or registry steer the MCP target | endpoints only from the compiled registry; host in egressAllow; https only; pinned fetch, no redirects, no OAuth discovery | GW21, GW22, GW33, GW36, GV7 |
| MCP server-to-client requests | upstream sends sampling/createMessage, elicitation/create, roots/list | no client capabilities declared; any server request fails the session (server_request_denied) | GW35 |
| Tool metadata poisoning and rug-pull | upstream description or inputSchema change or carry instructions; pattern ReDoS | registry description wrapped as untrusted; schema sha256 pin; pattern, patternProperties, uniqueItems refused; strict ajv | GW38, GW39 |
| Untagged result content | structuredContent, image, resource bypass the text wrapper | text-only results, the rest stripped and audited (content_stripped) | GW37 |
| Token replay | leaked job token reused by another job or after the turn | opaque 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 paths | GW1, GW34, GW-CTL, OB4, SEC2 |
| Token theft from logs or argv | token in logs, audit, errors, argv | redaction pattern for afj_…, no header logging, audit has no tokens; sandbox token only in a 0600 env file | GW15, OB5, SEC3 |
| Header smuggling | anthropic-beta enabling server tools, x-forwarded-*, cookie | only anthropic-version and allowlisted betas are forwarded | GW17, SEC4 |
| Request smuggling and desync | CL+TE, obs-fold, duplicate Content-Length | strict Node parser (never insecureHTTPParser), body re-serialized, one upstream fetch per request | GW17, SEC5 |
| JSON parser differential | duplicate keys, __proto__ | canonical re-serialization of the validated tree; strict Zod; a __proto__ key is a disallowed field (403) | GW18, SEC6 |
| Response streaming | stalls, huge lines, wrong content type, client abort leaking spend | idle and total timers, 1 MiB SSE line cap, content-type allowlist, abort propagation, worst-case charge on missing usage | GW9 to GW11, GW20 |
| DoS | body bombs, YAML alias bombs, connection floods, registration floods, parallel streams, unauthenticated floods loading the DB | body 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 query | GW19, GW20, OB7, GV1e, SEC8, SEC13 |
| Spend bypass | parallel calls, abort before usage, lying max_tokens, thinking budget, many small images | atomic conditional debit of the worst case before the upstream call, max_tokens required and capped, budget_tokens below max_tokens, per-image term | GW5, GW6, GW8b, GW9, SEC9 |
| Control-plane exposure and grant minting | sandbox reaches registration and mints itself grants | separate 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 outage | gateway keeps spending when disabled or the DB is down | per-request read, fail closed | GW12, GW13, SEC11 |
| Secret exposure to the runtime | key reaches the runtime env or filesystem | gateway is the only holder; runtime gets only the job token; /health returns {status} only | GW15, 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)
| Id | Threat | Control | Residual |
|---|---|---|---|
| T1 | Key theft from env, fs or /proc | key only in the gateway container; sandbox env holds only the job token | none listed |
| T2 | Job-token abuse | gateway grants (model, cap), worst-case debit on one row, TTL bound to the turn, revoke on terminal | none listed |
| T3 | Network 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.1 | none listed |
| T4 | Exfiltration through the gateway | content-block and tool-type allowlists; no MCP grants | the prompt itself goes to the provider (accepted) |
| T5 | Control-plane reach | control listener not on the job network; control tokens never in the sandbox | none listed |
| T6 | Container escape and privilege | uid 10001, --cap-drop ALL, no-new-privileges, read-only rootfs, default seccomp and AppArmor, no docker socket, no host mounts | kernel 0-days on a kernel shared with the gateway; needs a dedicated sandbox host or runsc before untrusted repos (G2-VPS) |
| T7 | Token sniffing and cross-job reach | per-job network, no CAP_NET_RAW, one job per container | timing channels through shared gateway limits (accepted) |
| T8 | Resource exhaustion | pids, memory, CPU, tmpfs limits; timeoutMs; gateway stream timers | none listed |
| T9 | Spawner as escape hatch (docker access is host root) | argv arrays, no shell, image and flags only from config, assertSafeArgv | worker is host-root-equivalent (OQ-1: rootless Docker on a dedicated host or a containers/create validating launcher) |
| T10 | Untrusted event stream (forged result) | Zod and size caps; cost from the gateway only; success needs container exit 0 | none listed |
| T11 | Persistence across jobs | read-only rootfs and store; per-job tmpfs volume; tmpfs HOME | none listed |
| T12 | Git credential or push | no GitHub token in the sandbox; no egress | none listed |
| T13 | Version drift of the CLI | allowlists frozen to FROZEN_FOR_SDK (0.3.322), guard test SB-FRZ1 | Console line-item comparison F2 UNVERIFIED |
| T14 | Host-side workspace extraction | extractor never creates links or special files, refuses .. and absolute paths, caps size and entries | none listed |
| T15 | Gateway flood and kill-switch storm | pre-auth limiter, per-job limits; SandboxRuntime polls the kill switch | none listed |
| T16 | Capture sidecar and pcap handling (test harness) | pcaps in 0700 temp dirs, deleted by trap | test harness only |
| T17 | role: "system" messages from the sandbox | same strict block allowlist as user text; tool blocks in system messages refused | if the gateway ever injects operator system messages, this needs re-review |
Factory threats (P3 plan section 9)
| Id | Threat | Control | Residual |
|---|---|---|---|
| F1 | Prompt injection via repo content, task or context | sandbox without credentials, gateway-only egress, patch filter, secret scan, model-less no-network test run, human approval of the exact digest, secret-less fork CI | a subtle malicious change in allowed source; the human reviewer is the control |
| F2 | Patch smuggling (symlinks, submodules, .gitattributes, renames into CI, .., .git/) | parser, protected paths, git apply --check, post-apply index re-check, hardened git config | none listed |
| F3 | Secrets in diffs | key-shaped and exact-minted-token scan | none listed |
| F4 | GitHub token theft | tokens only in factory worker memory; GIT_CONFIG_* env; redaction; push only to the fork | none listed |
| F5 | CI secret theft via PR | fork-only PRs, secret-less fork CI, maintainer approval | none listed |
| F6 | Forged completion or status | completion = host extraction plus validated out file plus docker-observed exit | none listed |
| F7 | Approval forgery or replay | approval row authored by the authenticated API; digest, expiry, single consumption in Postgres | none listed |
| F8 | Host code execution | host runs only allowlisted git subcommands with hooks and filters disabled, and docker | none listed |
| F9 | Spend | per-step row cap, gateway hard cap per row, iteration bound, daily caps, kill switch | none listed |
| F10 | Sandbox escape | dedicated sandbox host or runsc | runc is refused unless FACTORY_ALLOW_RUNC=throwaway-repo-only |
| F11 | Spawner | argv contract (T9) | OQ-1 before a VPS |
| F12 | Artifact disclosure | artifacts scoped by job client; redaction | none listed |
| F13 | Reviewer manipulation | reviewer verdict only gates the loop, never the PR | none listed |
| F14 | Maintainer workstation (.envrc, editor tasks, prepare hooks) | protected-path defaults, parsed package.json checks, PR-body warning | none listed |
| F15 | App key or worker compromise | two GitHub Apps (read-pr org-wide, push fork-only), hardened git env, per-repo tokens in memory | publisher separation deferred (OQ-P3-6) |
| F16 | Approval-to-push TOCTOU | openPr re-derives from the approved artifact and re-validates | none listed |
Details of F2, F6 and F7 are in Patch policy and Gates and approvals.
Deployment threats (fleet and network)
| Threat | Control | Status |
|---|---|---|
| Neighbour on the shared swarm ingress overlay reaches the control port once the data port is published | GATEWAY_CONTROL_BIND_CIDR binds control to the private overlay address only | coded, not released (ADR 0008); launch publishes no gateway port (ADR 0005) |
| Fleet exec host with stolen credentials | exec role refuses DATABASE_URL, ANTHROPIC_API_KEY, GATEWAY_CONTROL_*, GITHUB_APP_*; holds only payload keys and a gateway URL | built (FL-3) |
| Fleet host polls or fails any Temporal queue | tailnet ACL only; Temporal 1.23 OSS cannot restrict by task queue (R-5) | accepted residual |
| Tokens and prompts in plain HTTP on the tailnet | WireGuard tunnel; GATEWAY_HTTP_ALLOWED_HOSTS must name each plain-http host exactly | accepted (owner decision) |
| Gateway restart drops all live tokens | turns retry and re-register | accepted (ADR 0001 consequence) |
Sources
.omc/plans/p2g-governance-gateway.mdsection 11 (gateway threat model) and section 12 (failure modes).omc/plans/p25-sandbox-spike.mdsection 9 (T1 to T17).omc/plans/p3-software-factory.mdsection 9 (F1 to F16)docs/p2-findings.mdsections "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.mddocs/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.mdapps/worker/src/exec-config.ts(EXEC_FORBIDDEN),apps/gateway/src/allowlists.ts(FROZEN_FOR_SDK),packages/db/src/schema.ts(gateway_audit)