You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: refuse a pull unless the Docker daemon goes through the egress proxy (ADR 0023) - #370
Second part of ADR 0023 (#368), for #351: the agent checks that the Docker daemon goes through the egress proxy before each pull. It is independent of #369 (the proxy itself). The installer that runs the proxy and points the daemon at it is the third part.
Do not tag a release between this PR and the installer PR: an agent from this PR refuses pulls on a server whose Docker has no egress proxy, which is every server installed so far.
What changed
docker.Client.Proxies: reads HttpProxy, HttpsProxy and NoProxy from GET /info. These are the settings the daemon applies once daemon.json and its environment are combined.
actions: before a pull, unless the image is already on the server, egressGuarded requires both proxies to be exactly http://127.0.0.1:7480 (actions.EgressProxy) and NO_PROXY to be empty.
Otherwise the pull is refused with the cause egress_unguarded, and the fixed text "the server's Docker does not go through its egress proxy".
A daemon that does not answer refuses the pull too, with action failed.
WithoutEgressCheck(), an option of DockerHandlers and Registry, skips the check. Only an agent started with --dev uses it, and it logs a warning.
Control plane: the reason egress_unguarded in ACTION_REASONS, AGENT_ERRORS and STEP_CAUSES. The deployment's failure says the server refused to pull because its Docker does not go through the egress proxy, and to run the server installer again.
Web: the short label "egress proxy missing", and the French texts.
docs/SPEC.md 3.4: a row in the table of causes. OpenAPI and the API client are regenerated (a new enum value).
How it was tested
Go:
the pull is refused, with no call to PullImage, for: no proxy, another proxy, HTTPS only, HTTP only, NO_PROXY=*, a NO_PROXY naming the registry, another port, localhost instead of the IP, and a user in the proxy URL;
a daemon whose settings cannot be read refuses the pull;
the exact settings let the pull run;
an image already on the server needs no check;
WithoutEgressCheck pulls without a proxy;
Client.Proxies reads the fields of /info and fails on a daemon error.
go test -race ./agent/..., go vet and golangci-lint pass.
TypeScript: reason mapping (agent-action.spec.ts), the failure sentence (pipeline.spec.ts), the label and the French texts (agent-action-rows.spec.ts). api:lint, api:typecheck, api:test, web:lint and web:test pass.
Security considerations
The check reads what the daemon applies, so a proxy setting in daemon.json or in another drop-in, set after the installation, stops pulls instead of bypassing the proxy. It does not cover pulls made outside the agent, such as docker compose pull: those rely on the installer's check and on the loopback guard (ADR 0023).
Summary by CodeRabbit
New Features
Image pulls now proceed only when Docker’s HTTP and HTTPS proxies match the configured egress proxy and no bypass list is set. Images already available locally can still be used without this check.
Development mode allows image pulls without the proxy check.
Deployment and agent-action status now identify missing egress proxy configuration, with French translations added.
Documentation
Updated the operation-journal reference with the new pull-failure reason.
…proxy (ADR 0023)
For #351. Before each pull, the agent reads the daemon's proxy settings (GET /info) and refuses with the cause egress_unguarded unless both proxies are the egress service and NO_PROXY is empty. --dev skips the check. The control plane names the cause and tells the operator to run the server installer again.
Signed-off-by: samuel mbabhazi <[email protected]>
Reviewing files that changed from the base of the PR and between 7a19ce9 and 648b80f.
Files ignored due to path filters: 2
apps/api/openapi.json is excluded by !apps/api/openapi.json
packages/api-client/src/gen/openapi.ts is excluded by !**/gen/**, !packages/api-client/src/gen/**
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Before pulling a missing image, the agent checks that Docker’s HTTP and HTTPS proxies match the configured egress proxy and that No is empty. Development mode can disable this check. Guard failures map to a new action reason and deployment message.
The Docker client reads proxy settings from /info. Before pulling a missing image, the handler checks those settings and rejects the pull if they do not match the required proxy or if reading them fails. Existing images skip the check.
The registry forwards handler options. In development mode, the gateway passes WithoutEgressCheck() so image pulls do not require the proxy.
Map guard failures to action and deployment messages agent/internal/actions/dispatcher.go, apps/api/src/modules/fleet/domain/agent-action.ts, apps/api/src/modules/fleet/domain/agent-action.spec.ts, apps/api/src/modules/deployments/domain/pipeline.ts, apps/api/src/modules/deployments/domain/pipeline.spec.ts, apps/web/src/app/delivery/agent-action-rows.ts, apps/web/src/app/delivery/agent-action-rows.spec.ts, apps/web/src/app/ui/fr.ts, docs/SPEC.md
The dispatcher emits a fixed error for the new cause. The API maps it to egress_unguarded and a deployment message. The web app adds a reason label and French translations; the specification documents the mapping.
shipkeepdev/shipkeep#16 — The pull action is within the issue’s scope, and this change adds a pre-pull refusal condition and documents it in the specification.
Possibly related PRs
shipkeepdev/shipkeep#368 — The ADR specifies Docker’s egress-proxy settings that this PR checks.
shipkeepdev/shipkeep#330 — This PR extends the cause-code mapping and reporting flow introduced there.
Suggested labels:track:control-plane, track:web
Merge Risk: Low · previous review 7a19c
Missing-image pulls now require Docker to go through the egress proxy, with a development-mode opt-out, and refusals are reported consistently across the agent, API and web app. The change looks sound. Until the paired installer change ships, servers installed so far will have their image pulls refused, so the two changes must be released together or in the stated order.
Security architecture risk: Moderate · up to 7a19c
Requiring the egress proxy strengthens protection, but this revision cannot be rolled out independently of the installer update. Releasing it first would block deployments and recovery operations that need uncached images on servers without the new configuration.
Retained concerns
Medium · reliability · inferred: Production activation requires a coordinated installer transition. This head unconditionally refuses uncached pulls on non-development nodes without the required proxy settings, while the PR defers provisioning to another installer change. Its recovery message recommends rerunning the installer, but the current installation contract refuses existing installations. An intermediate release would therefore block new-image deployments and uncached recovery images. The documented prohibition on releasing between these changes contains this risk only while that sequencing is respected.
Security review details
Security Blast Radius
inferred — The enforcement and activation failure scope is a node's Docker daemon: all non-development missing-image actions using these handlers share the precondition, regardless of application. The intended security boundary is registry-controlled network behavior reaching the server's network. Fleet-wide rollout impact depends on which nodes receive this version before provisioning.
Trust Boundaries and Controls
observed — The bypass is selected through local startup authority: --dev selects development defaults, Dev is excluded from YAML and preserved from the startup base configuration, and gateway construction enables WithoutEgressCheck only for that setting while logging a warning. The inspected action handler does not accept a request-level bypass.
Resilience and Maintainability Implications
observed — Failure containment is stronger than the rollout hazard alone suggests: cached images bypass network work, the pull precedes container creation and startup, and deployment failure detection stops progression before routing changes. The new refusal therefore does not itself require stopping existing workloads.
Hardening Proposals
proposed — Preserve the fail-closed production default and make publication contingent on the matching installer providing provisioning and repair for existing nodes. Treat development mode as a local exemption, not as a production migration or recovery mechanism.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: the agent now refuses image pulls unless the Docker daemon's proxy settings match the egress proxy. The title also cites ADR 0023, which the PR objectives describe. Th…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: the agent now refuses image pulls unless the Docker daemon's proxy settings match the egress proxy. The title also cites ADR 0023, which the PR objectives describe. The title is specific and matches the changeset.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
…guard (ADR 0023) (#371)
Third part of ADR 0023, for #351: the server installer puts the Docker
daemon behind the egress proxy (#369) and adds the loopback guard. The
agent's pre-pull check is #370. Merge after #369 and #370: this PR runs
`shipkeep-agent egress`, which #369 adds.
## What changed
`deploy/install.sh`:
- **Checks before anything is installed:**
- port 7480 is free;
- `daemon.json` sets no proxy (`proxies`, `http-proxy`, `https-proxy`,
`no-proxy`), since Docker would apply it instead of the drop-in;
- nftables is there, or gets installed;
- systemd reports a `docker.service` cgroup;
- the guard passes `nft --check`.
- **The guard** (`egress_guard`, written to `/etc/shipkeep-egress.nft`,
root, 0644) is one table, `inet shipkeep_egress`:
- it matches new connections from the cgroup of `docker.service`, at the
depth systemd reports (level 2 on a host);
- it lets through `127.0.0.1:7480` (the proxy) and each loopback name
server of `/etc/resolv.conf` on port 53, matched on the connection's
original destination;
- it rejects the rest of `127.0.0.0/8` and `::1`.
- **`shipkeep-egress.service`:** a new `shipkeep-egress` account and a
root-owned copy of the agent binary in
`/usr/local/libexec/shipkeep-egress`, with no capabilities,
`ProtectSystem=strict` and restricted address families.
- **A drop-in for `docker.service`:**
- it sets `HTTP(S)_PROXY` (upper and lower case) to the proxy, with an
empty `NO_PROXY`;
- it starts after the proxy;
- it loads the guard in `ExecStartPre`, inside the new cgroup and before
`dockerd` starts.
- **A drop-in for `nftables.service`:** it loads the guard again after a
restart that flushes the ruleset.
- **After the files are written:** the installer starts the proxy and
waits until it listens, restarts Docker, then checks that the table is
loaded and that `GET /info` reports exactly the proxy and no exception.
Only then does it start the agent.
- The existing-installation checks now cover the new files and the new
account.
`deploy/install_test.sh` covers these, with malicious inputs:
- loopback name servers: a comment, leading zeros, a public server,
`127.0.0.256`, `127.0.0.1; drop`, extra words, `::2`, `$(id)`;
- the guard's rules for a host cgroup and a nested one;
- 11 refused cgroups: empty, relative, another service, a quote, `;
drop`, a newline, `$(id)`, a space;
- `daemon.json` with each proxy key;
- `/info` answers: none, empty, `NoProxy=*`, another proxy, port 74800.
Docs: SPEC 8 and 16, THREAT_MODEL (a new I5 row), INSTALL (what the
installer adds, the drift message, not flushing the ruleset, servers
installed earlier), `deploy/README.md` (acceptance and starting over).
In ADR 0023, implementation details the lab settled:
- the guard file sits outside the agent's writable directory;
- the cgroup depth comes from what systemd reports;
- the DNS exception matches the original destination;
- the proxy runs from a root-owned binary;
- the installer waits for the proxy.
## How it was tested
- `bash deploy/install_test.sh` passes.
- On the test server (`shipkeep-node16`: Ubuntu 24.04, Docker 29.10 in a
privileged container with systemd, enrolled in the test control plane):
- **Setup:** I sourced this `install.sh` and ran its `prepare_egress`
and `install_egress` with an agent built from #369 and #370.
- **First run, two bugs:** the proxy could not execute a binary under
the agent's private directory, and the installer did not notice, because
Docker reports its proxy settings whether or not anything listens. Hence
the root-owned copy, and the wait for the listener.
- **DNS:** the DNS exception first matched port 53 after NAT. Docker's
embedded resolver in that container is a DNAT from `127.0.0.11:53`, so
DNS failed from Docker's cgroup until the exception matched the original
destination.
- **Pulls:**
- a pull from Docker Hub went through the proxy (`registry-1.docker.io`,
`auth.docker.io`, `production.cloudfront.docker.com`);
- the four lab registries (blob redirect and token service, to loopback
and to a private address) were refused at the proxy (`not_public`), and
the loopback and private probes received nothing;
- a deployment from the control plane (`nginx:1.27-alpine`) succeeded,
with the agent's check passing.
- **The guard, probed from Docker's cgroup** (a probe process moved into
it):
- the loopback service is refused, while the proxy and DNS are
reachable;
- the same service answers outside the cgroup;
- this held after two later Docker restarts, each with a new cgroup.
- **Restart limit:** three restarts within a minute hit Docker's systemd
start limit. That limit is systemd's, unrelated to this change.
- **Drift:** a second drop-in setting `NO_PROXY=*` made the next
deployment fail at the pull, with no tunnel opened and no image pulled.
That control plane predates #370, so it showed "Step pull compensated"
instead of the new sentence. Restoring the setting restored the pulls.
- **Not run:** the full installer from a fresh server, since this needs
a release image that carries #369. That is part of the next real-server
acceptance.
## Security considerations
This is the enforcement point of ADR 0023: what a registry answers can
no longer make a server's Docker reach a private address, or a loopback
service of the server. The installer restarts Docker once. A server
installed before this change has neither the proxy nor the guard, and an
agent from #370 refuses to pull there until the server is installed
again; INSTALL says so.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **New Features**
* Docker image pulls now use a local egress proxy that permits
connections only to checked public HTTPS addresses. A network guard
blocks other Docker connections to loopback addresses, except
connections to the proxy and loopback DNS.
* Before pulls, the agent verifies Docker uses the required proxy
settings with no `No Proxy` exceptions, and refuses pulls if they do not
meet requirements. Installation configures the egress service and
restarts Docker, which also restarts existing containers.
* **Documentation**
* Installation guidance now covers proxy requirements, supported
registries, troubleshooting, restoring the network guard, and
identifying egress-related pull failures.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: samuel mbabhazi <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second part of ADR 0023 (#368), for #351: the agent checks that the Docker daemon goes through the egress proxy before each pull. It is independent of #369 (the proxy itself). The installer that runs the proxy and points the daemon at it is the third part.
Do not tag a release between this PR and the installer PR: an agent from this PR refuses pulls on a server whose Docker has no egress proxy, which is every server installed so far.
What changed
docker.Client.Proxies: readsHttpProxy,HttpsProxyandNoProxyfromGET /info. These are the settings the daemon applies oncedaemon.jsonand its environment are combined.actions: before a pull, unless the image is already on the server,egressGuardedrequires both proxies to be exactlyhttp://127.0.0.1:7480(actions.EgressProxy) andNO_PROXYto be empty.egress_unguarded, and the fixed text "the server's Docker does not go through its egress proxy".action failed.WithoutEgressCheck(), an option ofDockerHandlersandRegistry, skips the check. Only an agent started with--devuses it, and it logs a warning.egress_unguardedinACTION_REASONS,AGENT_ERRORSandSTEP_CAUSES. The deployment's failure says the server refused to pull because its Docker does not go through the egress proxy, and to run the server installer again.docs/SPEC.md3.4: a row in the table of causes. OpenAPI and the API client are regenerated (a new enum value).How it was tested
PullImage, for: no proxy, another proxy, HTTPS only, HTTP only,NO_PROXY=*, aNO_PROXYnaming the registry, another port,localhostinstead of the IP, and a user in the proxy URL;WithoutEgressCheckpulls without a proxy;Client.Proxiesreads the fields of/infoand fails on a daemon error.go test -race ./agent/...,go vetandgolangci-lintpass.agent-action.spec.ts), the failure sentence (pipeline.spec.ts), the label and the French texts (agent-action-rows.spec.ts).api:lint,api:typecheck,api:test,web:lintandweb:testpass.Security considerations
The check reads what the daemon applies, so a proxy setting in
daemon.jsonor in another drop-in, set after the installation, stops pulls instead of bypassing the proxy. It does not cover pulls made outside the agent, such asdocker compose pull: those rely on the installer's check and on the loopback guard (ADR 0023).Summary by CodeRabbit