Skip to content

restrict container network egress to what the pipeline actually needs, not just github.com and the Anthropic API

Id: TD-PPagop-26082429 · Status: resolved · Filed: 2026-08-24 · Resolved: 2026-08-24 · Ref: #760 · Review: reviews/project-review-2026-08-23 R-01 F-SEC-01

Severity: Critical

Split out of TD-PPagop-26082407 (part 3 of its 3-part suggested fix) — restricting container network egress, currently unbounded, per reviews/project-review-2026-08-23/04-improvement-prompts.md’s prompt for R-01 (“restrict container network egress to github.com (and its API subdomains) and the Anthropic API — nothing else”). Landing this alongside the prompt-framing change in TD-PPagop-26082407’s PR (#752) was judged too risky without the investigation below; that PR lands the prompt-framing part only.

Two findings from that investigation that whoever picks this up needs, neither obvious from the tech-debt record’s own one-line suggested fix:

  1. The two-domain allowlist the suggested fix names would break real, already-relied-upon pipeline behaviour. scripts/preview-deploy.sh (prompts/implementer.md step 4a, prompts/reviewer.md‘s equivalent step) fetches api.vercel.com and each pull request’s own dynamic *.vercel.app preview URL — a hard requirement for poetic-fiddle, which deploys every PR to Vercel. Separately, prompts/implementer.md and prompts/project-reviewer.md both name npm install/npm ci as an ordinary long-running command a stage waits out — the target repos’ own build/test tooling runs live, inside the stage, against whatever registry their package.json/lockfile names (registry.npmjs.org at minimum for a Next.js app; verify what each of the three target repos’ own toolchains actually needs — poetic-fiddle almost certainly, poetic and agent-ops themselves may differ). An allowlist of exactly github.com and the Anthropic API, taken literally, would silently break the Vercel preview check and any npm install/npm ci a stage runs — not a loud failure a node operator would immediately connect to the firewall change, but every affected stage quietly degrading (preview check reports “could not check”, or a dependency install hangs/fails) days or nodes apart. Enumerate the actual set — Vercel’s API and preview domains, whichever package registries each of the three repos’ own build/test/lint tooling reaches, anything else a gh/git/claude invocation needs beyond github.com itself (e.g. *.githubusercontent.com for raw content, api.github.com) — against all three target repos’ real toolchains before choosing a final allowlist, not just this repository’s own.

  2. The image runs fully non-root with no NET_ADMIN, so iptables/nft inside entrypoint.sh is not available under the current privilege model, and neither package is even installed. deploy/docker/Dockerfile sets USER agent before ENTRYPOINT, with no gosu/su-exec step to run any part of the container as root; deploy/docker/compose.yaml grants cap_add: [NET_ADMIN, NET_RAW] only to the tailscale sidecar, never to scheduler/dashboard/dashboard-local. A firewall rule inside entrypoint.sh, as the tech-debt record’s own suggested fix names as one option, would need either installing iptables/nftables and granting NET_ADMIN to every service that runs a claude stage (a capability expansion of its own, worth weighing against what it buys), or an entrypoint restructure to run privileged setup as root before dropping to agent (gosu/su-exec, changing how every service starts). A Compose-only alternative that needs neither: put scheduler/dashboard/ dashboard-local on an internal: true network with no route to the internet, and add a forward-proxy sidecar (the same network_mode: service:<sidecar> pattern this file already uses for tailscale/ dashboard) holding the only route out, running e.g. tinyproxy/ squid with a domain ACL — enforced by the network topology itself rather than by a mechanism running inside the image whose compromise is exactly what this record exists to contain. Whichever mechanism is chosen, verify it against a real docker compose up (this repository’s own test suite runs outside a container per its header comment, per scripts/run-tests.sh, and cannot exercise this) — a misconfigured allowlist fails a node silently, node-by-node, with no test in this repository positioned to catch it before a human notices a cycle stopped producing PRs.

Suggested fix: enumerate the real domain set per finding 1 against all three target repositories’ actual build/lint/test tooling (read each repo’s own CI workflows for what they install/fetch, since that is the same surface an unattended stage exercises locally); then implement via the Compose-only internal-network-plus-egress-proxy design per finding 2 (no image privilege change needed) unless investigation finds a reason to prefer the NET_ADMIN-in-image alternative. Verify against a real docker compose up on at least one node before considering this closed — a static config review is not enough for a control whose failure mode is silent.

Noticed while working PR #752.

Landed as finding 2’s Compose-only design: the scheduler moved onto an internal: true network (no gateway — enforcement by topology, outside the fenced container), with an egress-proxy service — squid on the same agent-ops image — holding the only route out, permitting CONNECT-to-443 on deploy/docker/egress-allowlist.txt plus a node’s own EGRESS_EXTRA_ALLOW. Finding 1 drove the allowlist’s enumeration, which then went further than either of us: codeload.github.com (the tarball gatherers’ redirect target), .githubusercontent.com (poetic-fiddle’s release-tarball root dependency and ghcr blob redirects), fonts.googleapis.com/fonts.gstatic.com (next/font/google fetches at build time), ghcr.io (lib/image-drift.sh runs in the scheduler, not just watchtower). Claude Code’s optional traffic is disabled in the scheduler’s environment rather than allowlisted. test/egress-fence.test.sh pins the shape, the image build parses the squid config, and scripts/doctor.sh’s Egress section probes the live fence’s three failure shapes per node — the real-docker compose up verification this record demanded ran on the operator workstation before landing (see the PR). Residuals — the forge as an allowlisted exfiltration channel, DNS resolution reaching the host resolver — are accepted and recorded under D24, not pretended away.