Appearance
0042. Run pods reach the internet through an egress proxy ​
Status: Accepted (2026-10-27), the design of #124: a run pod's network is deny by default, and an HTTPS-only proxy of our own, adam-egress, is the one way out. Built in two changes: the proxy (bin/adam-egress, in the coder image, #134) and this one (the chart, the policies, the template's variables, the checks, the docs). Amends ADR 0019 (decision 7's network policy, OD-K6 and the consequence about the policy) and builds on ADR 0041 (what a run pod holds and sees). What is verified and what is not is marked in Facts, and how they are known; the choices the issue left open are at the end.
Context ​
ADR 0019 gave a run pod a NetworkPolicy that let it reach the whole internet except the private ranges (OD-K6, "the internet except the private ranges and the CIDRs named"), so that a build could fetch from anywhere. A run pod now holds more than a build needs: the repository it works on (ADR 0041 narrowed it to the run's own), and the model key as a variable that every command of the run can read (OD-K5). A command that a prompt or a dependency's install script made hostile can send all of it to any public host, and fetch anything from one. The coder is to be offered to every user.
A NetworkPolicy names addresses and ports, not hosts: the part of the Kubernetes API that names a host is a plugin's own (CiliumNetworkPolicy's FQDN rules, a Calico enterprise feature), so a chart that needs to work behind any plugin cannot use it. What a run needs from the internet is small and known: package registries and git hosts, all over HTTPS. Run pods are not root, so apt is out, and plain HTTP buys nothing.
Decision ​
A run pod's egress is deny by default. Its
NetworkPolicy(coder-run-podsfor the releasecoder) allows DNS (as before), the egress proxy's pods on TCP 3128, andrunPods.networkPolicy.extraEgress(an in-cluster target the proxy cannot serve, such as a model gateway), and nothing else. The rule that opened0.0.0.0/0is gone. There is no value that brings it back:runPods.networkPolicy.enabled, which would have rendered no policy at all, is refused when it isfalse(the render fails and says what to use instead).extraEgressstays, for what a deployment must add.The one way out is a proxy of our own,
adam-egress(bin/adam-egress): it acceptsCONNECT host:443to the hosts on an allow-list and nothing else, resolves the name itself, connects only to public IPv4 addresses, and splices the bytes. No TLS interception, no credential, no plain HTTP; one log line per decision (allowed or refused, the host, the port, the reason) and never a path, a query or a header. It is a few hundred lines with the resolver and the forbidden ranges injectable, so every rule has a unit test, including a name that resolves to a private address (DNS rebinding). Squid would need a third-party image pinned by tag and digest and a non-root setup; Smokescreen has no published image. The proxy runs the coder's image, so there is no new image to pin.The chart deploys it with the run pods (
runPods.egressProxy, rendered wheneverrunPods.enabledis, on the roles that run workers): a Deployment ofimage.repository:image.tagwith the commandtini -- adam-egress(two replicas, a rolling update that never takes the last one, a preStop sleep and a grace period that cover the 25 s the proxy drains its tunnels), aClusterIPService on 3128, aPodDisruptionBudgetwhen there is more than one replica, a ServiceAccount of its own with no token, and a ConfigMap with the allow-list (a checksum annotation: the file is read at startup only, so a change is a rollout). The pods run as uid 10001, non-root, with a read-only root file system, no privilege escalation, every capability dropped, the runtime's default seccomp profile and no token. An allow-list that would be empty is refused at render, asadam-egresswould exit 78; so is an entry that is not a host name (a wildcard, a URL, a port, an IP address) or is a bare suffix (.com).The run pod's environment names the proxy. The template (
coder.runPodTemplate) setsHTTPS_PROXY,https_proxy,HTTP_PROXYandhttp_proxytohttp://<name>.<namespace>.svc:3128, where<name>is the proxy's Service (coder-egressfor the releasecoder: the chart's full name and-egress) andNO_PROXYandno_proxytolocalhost,127.0.0.1(plusrunPods.egressProxy.extraNoProxy, the hosts of anextraEgresstarget, which the tools must not send to the proxy). The commands of a run areexec'd into the container, so they inherit the container's environment;runPods.extraEnvmay not set these names. A tool that ignores the variables gets no connection at all, because the policy denies a direct one: the failure is closed, and it is loud (a timeout) rather than a leak.The proxy's own policy (named like the proxy): ingress only from the run pods (the same selector as theirs) on 3128; egress to DNS and to
0.0.0.0/0on TCP 443 only (runPods.egressProxy.ports), exceptnetworkPolicy.blockedCIDRsandclusterCIDRs. Those ranges moved: they used to be the run pods' exception to the internet rule, and are now the proxy's (the same list is itsEGRESS_DENY_CIDRS). The ranges are kept twice on purpose: the proxy refuses an address in them (and in the built-in private, loopback, link-local, shared, multicast, documentation and reserved ranges), and its policy would drop the connection, so a bug in one does not open the cluster.IPv6 is denied. No policy has an IPv6 rule (
render-check.shasserts it on all three policies, and the kind job on the applied ones), so a plugin that applies the policies to IPv6 drops it, and the proxy drops every IPv6 address it resolves and connects over IPv4 only. A name that has only IPv6 addresses is refused (no public address). The proof available is the absence of a rule: kind is IPv4 only, so a run pod's IPv6 egress cannot be tried there.The default allow-list (
runPods.egressProxy.allow) holds the package registries and git hosts, exact names:Ecosystem Hosts npm registry.npmjs.orgPyPI pypi.org,files.pythonhosted.orgcrates.io crates.io,index.crates.io,static.crates.ioGo modules proxy.golang.org,sum.golang.orgGitHub github.com,codeload.github.com,objects.githubusercontent.com,release-assets.githubusercontent.comDart pub.devstorage.googleapis.comis not on it: pub.dev serves its package archives itself (see the facts), and that host serves every bucket of Google Cloud Storage, which is a place to put data as much as to fetch it. No entry is a suffix.A deployment extends the list with
runPods.egressProxy.extraAllow(added toallow, lower-cased, once each), which survives a change of the defaults;allowitself can be replaced.example.comis that host,.example.comevery subdomain of it and not the apex. A model gateway outside the cluster that run pods still call (the model-key ticket, #119) goes on the list. One inside the cluster is anextraEgressrule and its host inextraNoProxy. A mirror or registry that speaks plain HTTP is not served by the proxy: it is anextraEgressrule too.
What is not covered ​
- Domain fronting. A client can name an allowed host in the
CONNECTand send another name in the TLS handshake, to the CDN behind it. Seeing the difference needs TLS interception, which this does not do. - What an allowed host accepts. The allow-list limits where a run can send bytes, not what. An upload to an allowed registry or to
github.comneeds a credential, which a run pod does not hold; but a hostile prompt can bring its own (the attacker's npm token, a GitHub token of an account of the attacker's) and publish the repository there. This policy removes the open internet; it does not make an exfiltration impossible, and it is no substitute for not putting a credential or a secret in a run. - DNS. The resolver is allowed (a name has to be resolved), and a name can carry data to a server that the attacker runs.
- The coder's own egress, and that of agent folders. Only run pods are changed. The coder pod reaches the model gateway, GitHub and the MCP servers, and its chart's
NetworkPolicyis still ingress only. - A suffix entry is as wide as the domain.
.github.iowould allow every site on it. The defaults hold none, and the chart refuses a bare suffix; an entry of a deployment is its own risk. - No authentication on the proxy. Whoever can reach the port is a client; the proxy's policy says who that is (the pods that carry the run pods' labels, which the coder makes; whoever else may create pods in the namespace could label one the same way, and that is the RBAC's to stop).
- Pods made before an upgrade have no proxy variables (and no way out, under the new policy) until the idle sweep or the end of their run replaces them, at most
runPods.idleSecs(900) after their last command. - A cluster whose plugin does not enforce
NetworkPolicygets the proxy and no deny: the policies are inert.
Facts, and how they are known ​
- kindnet, kind's network plugin on
kindest/node:v1.35.8, enforcesNetworkPolicy: the platform'srun-pods-e2erequires the refusal and passed, verified 2026-10-27 (run 40435825771). The node image is pinned in therun-podsjob by tag and digest, asoperator.ymlpins it (the preinstalledkindruns it there, verified 2026-10-27: the kind jobs of run 40465377293 passed). - The slot checks of ADR 0041 in a real run pod (a slot's directory cannot be renamed, removed or exchanged, and git works) passed in the
run-podsjob, verified 2026-10-27 (run 40456829784, job 122032008830). - pub.dev serves its archives itself: verified 2026-10-27 by
curl, thearchive_urlof a package in the API answer ishttps://pub.dev/api/archives/..., and a request for it answered 200 with no redirect (sostorage.googleapis.comis not needed). - A GitHub release asset redirects to
release-assets.githubusercontent.com: verified 2026-10-27 bycurlon a release ofcli/cli(302 to that host).objects.githubusercontent.comserved them before and stays on the list. - The node's access to its own pods is not blocked by a
NetworkPolicy, so the kubelet's probes of the proxy need no rule: verified 2026-10-27 in the Kubernetes documentation ("traffic to and from the node where a Pod is running is always allowed", and an isolated pod accepts connections "from the pod's node and those allowed by theingresslist"). - What the chart renders, in
deploy/coder/tests/render-check.sh: the three policies (the run pods' has noipBlock, the proxy's egress is 443 and the ranges), the template's six variables,extraAllowin the ConfigMap, the refusals, and nothing of the proxy withrunPods.enabled: false(the render is the golden, byte for byte). The new checks were broken on purpose (about sixty changes to the templates and the values, each of the guarantees above) and each change failed the check built for it. - In the cluster, the
run-podsjob (deploy/coder/tests/kind-run-pods.sh) is what proves the rest, and it is unverified until CI has run it: a direct connection from a run pod to a public address, to the API server (by its Service name, which DNS resolves, and by its address) and to another pod is refused after a control that the proxy's own pod reaches the public address and that a pod no policy selects reaches the other pod; the proxy's pod reaches no public address on 80 and no pod;curlandnpm viewthrough the proxy succeed;https://example.com/is answered 403 and the log hasdecision=refusefor it and no byte of aProxy-Authorizationheader or a query sent to the proxy. The script fails when a policy is not enforced, unlessADAM_TEST_CNI_MAY_IGNORE_POLICIES=1says the cluster is known not to, and it retries a refusal for up to 60 s because kindnet programs a policy a moment after it sees a pod. - Unverified: that git, cargo, pip and go read the variables (curl and npm are tried by the job; the others are documented to); that the owner's cluster enforces
NetworkPolicy, and its pod and service CIDRs (clusterCIDRs).
Alternatives rejected ​
- Squid, Smokescreen: see decision 2.
- A plugin's FQDN policy: not portable (see Context).
- A transparent proxy or TLS interception: a CA in every run pod and a man in the middle of every credential-less fetch, to answer domain fronting, which this ADR leaves open.
- A proxy in each run pod (a sidecar): a process in the pod that the commands share, which they could signal or replace, and an allow-list to roll out with every pod.
- Opening 443 to the internet (
0.0.0.0/0on 443, no proxy): it is the old rule with one port off, and any host. - An open-egress switch for a deployment that wants it: none.
extraEgressandextraAlloware the ways to add, and each is a named target.
Decisions for the owner to confirm ​
runPods.networkPolicy.enabledis gone andfalseis refused, because the switch would be the open-egress escape hatch the design excludes. A deployment on a plugin that has noNetworkPolicysupport is unaffected (the policy is inert there).release-assets.githubusercontent.comis on the default list, beside the design's hosts, because a release asset of github.com now redirects to it (a tool that downloads a binary from a release would otherwise fail). Remove it fromallowif release downloads are not wanted.runPods.egressProxy.extraNoProxyis new: without it anextraEgressrule for an in-cluster target would be useless, since the tools would send the request to the proxy, which refuses a name that is not on its list.- Two replicas,
32Miand25mrequested and256Mias the limit by default, and no anti-affinity: a node that holds both is a node drain away from a brief outage, which thePodDisruptionBudgetprevents for voluntary disruptions only. - The chart's version is not bumped (0.4.0): the render with run pods off is the golden, byte for byte, and no value of a deployment that has run pods off changes meaning.
Consequences ​
- A run's builds fetch through a proxy: a tool that ignores
HTTPS_PROXYfails at connect, and plainhttp://fails with403and a message that says to use HTTPS. A deployment that needs a host adds it toextraAllowand rolls the proxy. - The proxy is one more Deployment per release with run pods, from the coder's image, and a new failure mode: with it down, no run fetches anything (the run goes on and its command fails). Two replicas and the budget are the answer.
- The operator's run-pod objects (the platform's parity goldens at an adam-rs revision) follow this as a platform change after this one.
tools/adam-operator-parityprojects the pods of the cases (which have run pods off), so its goldens did not move. - The ranges
blockedCIDRsandclusterCIDRsmean what they say again: where nothing may connect. - ADR 0019's OD-K6 is resolved the other way: "allow only named hosts" is the default, and its stated cost (builds that fetch from anywhere break) is accepted.
Amended ​
- 2026-10-27, with the change that built this: ADR 0019 (decision 7, OD-K6 and the consequence about the policy) and ADR 0041 point here.