Skip to content

feat(gateway): The Gateway reaches protected sites through an operator's egress proxy - #55

Merged
sodre merged 10 commits into
mainfrom
e2/49-egress-proxy
Nov 24, 2026
Merged

sodre merged 10 commits into
mainfrom
e2/49-egress-proxy

Conversation

@sodre

@sodre sodre commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Closes #50
Closes #51
Closes #52

Summary

An operator whose network gives the Gateway no direct route can now name an egress proxy once, as egress_proxy in the Gateway configuration, and every protected site is reached through it, while a rule with "egress": "direct" keeps its direct route. When the proxied leg fails, the Workload's 502 says whether the egress proxy refused, could not reach the site or could not be used, and the Gateway never connects directly instead.

Where the route is chosen, in connect_request (crates/countersign-gateway/src/runtime/mod.rs):

connect_request
  destination policy, Broker admission, both leases       # unchanged
  PeerTrust::load(rule)                                   # unchanged
  egress_proxy_for(rule)
    Some(proxy) → egress::tunnel(proxy, origin, denied)   # new: resolve the proxy, CONNECT site:port, read its answer
    None        → resolve_target + TcpStream::connect     # today's direct route
  site certificate check, grant worker, relay             # unchanged
  • Configuration (runtime/config.rs): egress_proxy is an http URL with a host and a written port. https, credentials, port 0 and private_networks on a proxied rule each fail loading by name, in env and serve alike. env also runs the destination checks serve runs, so a launcher meets a rule serve would refuse, such as a wildcard rule with private_networks, before the Gateway starts. ADR 0003 is now accepted.
  • The proxied leg (runtime/egress.rs): the Gateway resolves only the egress proxy, on every connection, and drops answers inside denied_networks. It sends CONNECT <site>:<port>. It reads the answer one byte at a time and gives up as soon as the bytes cannot be HTTP. A 4xx is proxy_denied, a 5xx upstream_failure, and anything else proxy_unavailable.
  • The runtime test gains a test-only CONNECT proxy. Every negative case checks that the site saw no connection.
  • The Compose demo gains an opt-in variant, compose_demo.py --squid, with a real Squid pinned by digest; the default walkthrough is unchanged. docs/develop.md says how to run it.
  • Beyond the tickets, from review: the operator guide's Squid example pins a private site with a deny on every address outside its prefix. Squid's dst matches when any one of a name's addresses is in its list, and on the pinned Squid 6.14 the plain pin let a name through with one address outside it, then dialled that address. The demo's squid.conf carries the same deny.

Extras for the owner

  • env accepts configurations that serve refuses at its destination checks. A wildcard rule with private_networks (refused as "private egress requires an exact host and prefix rule"), and anything else Config::policy refuses, passes env and stops serve. This predates the change; every refusal this pull request adds is in both commands. An operator can send a Gateway's destinations through an egress proxy #50's criterion "env and serve refuse the same configurations" and the spec's story 15, "so that my launcher finds the mistake before the Gateway starts", read plainly, cover it.
  • No test covers a proxied leg that runs into the 120-second deadline. An egress proxy that accepts the connection and never answers gets proxy_unavailable when the Workload's 120-second deadline passes. The code maps it through the same catch-all as the tested unreachable, closed and non-HTTP cases, but the deadline is fixed and CI runs the runtime test under timeout 120. No source settles it.

Evidence

Criterion Ticked Shown by
#50: The Gateway configuration accepts an optional top-level egress_proxy, an http URL with a host and a port yes egress_configuration: an http egress proxy loads
#50: Loading fails on an https egress proxy URL and on one with credentials, and each error names the cause yes egress_configuration: https, credentials and a wrong shape are refused by name
#50: A destination rule accepts an optional egress whose only value is "direct", and any other value fails loading yes egress_configuration: egress takes only "direct"
#50: Loading fails when a rule has private_networks and goes through the egress proxy, and the error names the rule and both fixes yes egress_configuration: private_networks on a proxied rule is refused
#50: env and serve refuse the same configurations yes egress_configuration's refused(), which runs every refusal through both commands and asserts the same one line from each
#50: env runs the destination checks serve runs, so a wildcard rule with private_networks fails both with the same error yes egress_configuration: env and serve refuse a wildcard rule with private_networks alike
#50: A configuration without egress_proxy loads and behaves as before, and "egress": "direct" changes nothing yes The direct passes of runtime.py, unchanged and passing, the shared one with "egress": "direct" on its rule
#50: With egress_proxy set, the Workload reads the site through the test-only proxy, in sidecar and shared mode, and the site saw the approved certificate yes Proxied pass: the Workload reads the site through the egress proxy
#50: The proxy's recorded request names the site's hostname and port, where the Gateway cannot resolve that name yes Proxied pass: the Workload reads the site through the egress proxy
#50: One Gateway serves a proxied destination and a direct one with private_networks yes Proxied pass: proxied and direct destinations in one Gateway
#50: A retired grant cuts a proxied connection as it cuts a direct one yes Proxied pass: cutoff on the proxied route
#50: With proxy environment variables set and no egress_proxy, a destination is still reached directly yes Direct pass: proxy environment variables are ignored
#50: Startup logs the egress proxy's host and port and the rule IDs that leave their address policy to it yes Proxied pass: the startup line names the egress proxy and its destinations
#50: The runtime test runs these cases wherever it runs today, under both worker sandboxes yes runtime.py and scripts/filter-sandbox-container.sh, on d84d66d
#50: ADR 0003 is accepted and the glossary defines egress proxy yes The documentation grep run
#50: The configuration reference describes egress_proxy and egress yes The documentation grep run
#50: The operator guide has a section on reaching sites through an egress proxy: where resolution and address policy happen on each route, and what the ACLs must block yes The documentation grep run
#50: The architecture page's trust boundaries name the egress proxy, and the design record's resolution paragraph names both routes yes The documentation grep run
#51: A 4xx CONNECT refusal gives 502 proxy_denied, and the site saw no connection yes fails_through_egress: a refusal is proxy_denied
#51: A 5xx answer gives 502 upstream_failure yes fails_through_egress: a 5xx is upstream_failure
#51: Nothing listening at the proxy's address gives 502 proxy_unavailable, and the site saw nothing although the Gateway could reach it yes Unusable pass: nothing listens at the egress proxy
#51: The proxy closing the connection or answering with something not HTTP gives 502 proxy_unavailable yes fails_through_egress: closed or not HTTP is proxy_unavailable; kept-open answers fail at once
#51: The proxy's address inside denied_networks gives 502 proxy_unavailable, and neither proxy nor site saw a connection yes Unusable pass: the egress proxy's address is denied
#51: Through an allowed tunnel to a site certified for another hostname, the request fails and no signature is requested yes Proxied pass: wrong hostname gets no signature
#51: Each response carries Countersign-Request-ID and none carries the proxy's body yes fails_through_egress: a refusal is proxy_denied (every negative case asserts both)
#51: The Gateway logs each failure with its request ID and error value yes fails_through_egress: a refusal is proxy_denied (every negative case waits for Gateway CONNECT <id> <value>)
#51: The runtime test runs these cases wherever it runs today yes runtime.py and scripts/filter-sandbox-container.sh, on d84d66d
#51: The troubleshooting table covers proxy_denied and proxy_unavailable, and upstream_failure on a proxied route yes The documentation grep run
#52: The demo launcher has an opt-in Squid variant, and the default walkthrough is unchanged yes compose_demo.py --squid --verify; the default --verify and docker compose config runs
#52: In the variant the Gateway shares a network with the Broker and Squid, and the site is on a network only Squid shares yes --verify: the Gateway has no direct route to the site
#52: Squid runs from an image pinned by digest, allows CONNECT only to the site's hostname and port, and does no TLS interception yes --verify: Squid logged the tunnel to the site; the approved certificate reached the site
#52: From one --verify run, Squid logs a successful CONNECT, the site's fingerprint equals the approved one, and the Workload read the response yes compose_demo.py --squid --verify on d84d66d
#52: With the grant live and Squid's ACL swapped to refuse the site, the request fails with proxy_denied, and Squid logs the refusal yes --verify: the ACL swap gives proxy_denied; Squid logs the refusal
#52: With the grant live, the ACL restored and the site stopped, the request fails with upstream_failure yes --verify: a stopped site gives upstream_failure
#52: With the grant live and Squid stopped, the request fails with proxy_unavailable yes --verify: a stopped Squid gives proxy_unavailable
#52: The operator guide's example Squid ACLs are taken from the configuration that passed yes The guide's rules on the pinned Squid; the demo's squid.conf pins the site to every address
#52: The developer guide says how to run the variant and names the Squid version yes The documentation grep run
#52: The output of a passing --verify run of the variant is recorded on this ticket yes The comment on #52 with the run on 5d76a8b
Test Red Green
egress_configuration: an http egress proxy loads Before the field existed: AssertionError: http://proxy.test:3128 ok
egress_configuration: https, credentials and a wrong shape are refused by name serve accepted https and kept running: TimeoutExpired ... timed out after 10 seconds ok
egress_configuration: an empty port is refused TimeoutExpired: serve started on port 80 for http://proxy.test: ok
egress_configuration: port 0 is refused (review) subprocess.TimeoutExpired: Command '[... 'serve', '.../egress.json']' timed out after 10 seconds for http://proxy.test:0 ok
egress_configuration: egress takes only "direct" AssertionError (unknown field egress) ok
egress_configuration: private_networks on a proxied rule is refused serve started: TimeoutExpired ok
egress_configuration: env and serve refuse a wildcard rule with private_networks alike (widening) Against the Gateway before d84d66d: env returned 0 and printed its four export lines, failing assert result.returncode != 0 and not result.stdout ok: one line from each, the same, naming "private egress requires an exact host and prefix rule"
egress_configuration: no startup line when the destination checks fail (review) AssertionError: ... Gateway egress proxy proxy.test:3128 carries the address policy of destinations: site then Error: ... "private egress requires an exact host and prefix rule" ok
Proxied pass: the Workload reads the site through the egress proxy Before the proxied leg existed: ('alice', b'curl: (22) The requested URL returned error: 502\n') ok: sidecar/shared Gateway mTLS through the egress proxy passed, the proxy recorded exactly CONNECT site.test:<port> HTTP/1.1, and getent ahosts site.test exits 2 under the Gateway's environment
Proxied pass: cutoff on the proxied route Gateway broken on purpose, a leaked copy of the socket: AssertionError: upstream leg survived cutoff ok
Proxied pass: proxied and direct destinations in one Gateway Route choice broken on purpose, always the proxy: ('alice', b'curl: (22) ... 502\n') ok
Direct pass: proxy environment variables are ignored Gateway broken on purpose, reading HTTPS_PROXY: AssertionError: The Gateway took the egress proxy from its environment ok
Proxied pass: the startup line names the egress proxy and its destinations AssertionError: ['Gateway worker sandbox "namespaces": ...'] ok
fails_through_egress: a refusal is proxy_denied Before the error values existed: countersign-error: upstream_failure ok
fails_through_egress: closed or not HTTP is proxy_unavailable upstream_failure ok
fails_through_egress: a 5xx is upstream_failure proxy_unavailable, from the catch-all ok
fails_through_egress: kept-open answers fail at once (review): banner, stub, lf Against the old reading loop, each alone: TimeoutError: timed out (the Workload's 8-second read) ok: proxy_unavailable, proxy_unavailable, proxy_denied
Unusable pass: nothing listens at the egress proxy Passed on arrival; with a direct fallback added on purpose: ('site.test:…', 'The site saw a connection', b'HTTP/1.1 200 OK…') ok
Unusable pass: the egress proxy's address is denied Passed on arrival; with the filter on the proxy's addresses removed: 'The site saw a connection', and with that check skipped, AssertionError: The egress proxy saw a connection ok
Proxied pass: wrong hostname gets no signature Passed on arrival; with the site's certificate covering wrong.test: AssertionError: (0, b'd8bc83…'), and with that check skipped, A site with the wrong certificate got a signature ok
--verify: Squid logged the tunnel to the site Gateway still direct: RuntimeError: Timed out waiting for Squid's access log line for the Workload's CONNECT ok
--verify: the Gateway has no direct route to the site Site still on the backend: The Gateway can resolve site.test without Squid; pointed at broker:9443 on purpose: The Gateway can connect to the site at 172.31.0.2 without Squid ok
--verify: the startup line names Squid egress_proxy left out: Timed out waiting for the Gateway's egress proxy startup line ok
--verify: the ACL swap gives proxy_denied; Squid logs the refusal No swap: The Workload's request succeeded where it should fail with proxy_denied; port 9445 expected on purpose: Squid did not log one refusal… ok
--verify: the Gateway logs the same request ID …_wrong expected on purpose: Timed out waiting for the Gateway's log line… ok
--verify: a stopped site gives upstream_failure Site not stopped: …should fail with upstream_failure; HIER_NONE/- expected on purpose for Squid's 503 ok
--verify: a stopped Squid gives proxy_unavailable Squid not stopped: countersign-error: upstream_failure ok
The demo's squid.conf pins the site to every address (review) The demo's rendered squid.conf before the change, site.test answering 192.0.2.10 and 198.51.100.7: TCP_TUNNEL/503 0 CONNECT site.test:9444 - HIER_DIRECT/198.51.100.7 ok: TCP_DENIED/403 ... HIER_NONE/- in either order; 192.0.2.10 alone still tunnels (HIER_DIRECT/192.0.2.10)
The guide's rules on the pinned Squid (review) A copy with one line broken on purpose: FATAL: Bungled /check/broken.conf line 4: acl tls_port prot 443. The plain pin, billing answering one address inside and one outside: allowed, Squid dialled HIER_DIRECT/198.51.100.7 ok: squid -k parse exit 0; TCP_DENIED/403 for the mixed answer in either order, HIER_DIRECT/10.30.0.5 for the inside one; the block ACLs and deny rules equal squid.conf's line for line

Runs on the integration branch's tip, d84d66d, on Linux arm64:

  • cargo fmt --all -- --check: clean. cargo clippy --workspace --all-targets --locked -- -D warnings: clean. cargo test --workspace --locked: 19 suites, 43 passed, 0 failed, 1 ignored.
  • python3 crates/countersign-gateway/tests/runtime.py target/debug/countersign-gateway: exit 0 in 26 s (CI allows 120 s), printing sidecar Gateway mTLS passed, shared Gateway mTLS passed, sidecar Gateway mTLS through the egress proxy passed, sidecar Gateway without a usable egress proxy failed closed, the same two for shared, and filter-killed grant worker fenced.
  • scripts/filter-sandbox-container.sh: exit 0 in 33 s: the containment test, the same runtime-test lines under the filter sandbox, both named startup failures (refused to start for each mode), and the close_range unit (1 passed).
  • mkdocs build --strict: clean. python3 -m unittest discover -s scripts -p 'test_git_hooks.py': 12 tests, OK
  • dbus-run-session -- xvfb-run -a .venv/bin/python examples/demo-integrator/compose_demo.py --squid --verify --app <Companion>, with Squid 6.14 from the pinned image: exit 0 on d84d66d, in 63 s with the Gateway image rebuilt from it, and on 5d76a8b, whose check lines are posted on A maintainer can qualify the Gateway against a real Squid in the Compose demo #52. The default walkthrough's --verify passed on 17525c6. The default docker compose config was identical before and after (196 lines), and examples/demo-integrator/compose.yaml is unchanged from origin/main.
  • The documentation grep run, at 5d76a8b, printed status: accepted for ADR 0003 and the glossary's **Egress proxy**. It also printed the configuration reference's egress_proxy and egress rows, and the operator guide's "Reach sites through an egress proxy" section with its "Who resolves the site's name" and "Who checks the site's addresses" rows and its ACL list. It found the troubleshooting row's proxy_denied, proxy_unavailable and "On a route through the egress proxy, the proxy answered 5xx because it could not reach the site". It found the architecture page's "Egress proxy" trust-boundary row and the design record's "A destination takes one of two routes". It found the developer guide's "Qualify the Gateway against a real Squid" section, which names Squid 6.14. d84d66d changes only the reference's env row in the documentation.

Not run: pnpm lint and pnpm test on this tip, since no JavaScript changed after 17525c6, where they passed (the demo Integrator's tests: 8 passed). The x86-64 runtime test and the CI filter-sandbox jobs run on this push. Repeating the run on Fargate 1.4.0 is the #46 reporter's, out of the spec's scope.

Merge Danger

Door: two-way. A revert removes egress_proxy and egress; a Gateway configuration that sets either would then fail to load (unknown field), so revert only after taking them out.

Blast Radius: the Gateway's route to a protected site, for operators who set egress_proxy.

Nothing deploys on the merge: the countersign-gateway crate and the ghcr.io/zeroae/countersign-gateway image ship at the next version tag. No flag: the change is an opt-in configuration field whose absence keeps today's behaviour. Live step at the merge, for whoever merges: comment on #46, pointing the reporter at the documented Compose configuration (docs/develop.md, "Qualify the Gateway against a real Squid", and the operator guide's "Reach sites through an egress proxy"), so they can repeat it on Fargate.

Reviews

Correctness, Standards, Spec and Security, four rounds: 23 findings, each with its outcome; rounds 2, 3 and 4 found 1, 0 and 5

Correctness, round 1 (at high, on 719bffc against origin/main)

  1. The guide's private-site pin is weaker than private_networks: Squid's dst matches any one address. Fixed: the example adds a deny on every address outside the prefix, measured on the pinned Squid.
  2. The proxied leg has no time limit of its own. Pushed back: the spec's Implementation Decisions say "The per-connection deadline covers the whole leg"; a proxy that accepts and never answers has not answered, which is story 32's condition.
  3. A deadline that runs out on a proxied route reads proxy_unavailable. Pushed back: the spec's failure table maps an egress proxy that "timed out" to proxy_unavailable.
  4. egress_proxy accepts port 0. Fixed: refused at load.
  5. A bare-LF answer blocks until the deadline. Fixed: a line ends at LF with or without CR, and a non-2xx status line returns at once.
  6. The troubleshooting row misses upstream_failure from a rule's roots or revocation files failing to load. Fixed: the row names them, for either route.
  7. The startup line prints before the destinations are checked. Fixed: it follows config.policy().
  8. The proxy's answer is read one byte per call. Pushed back: about 40 one-byte reads once per CONNECT, before a TLS handshake; reading a byte at a time is what leaves every tunnel byte to the tunnel.
  9. EgressProxy::parse repeats the URL-origin checks. Pushed back: the shared check answers "expected a URL origin", while the spec requires egress_proxy's errors to name the cause; the overlap is five boolean checks.
  10. A local egress sits beside the module egress::. Pushed back: the egress leg predates this change and pairs with ingress; the module is always called by path.

Standards, round 1 (smells only; no written rule broken)

  1. Possible Duplicated Code with resolve_target's denied filter. Pushed back: three lines; the two lookups differ (the 64-answer cap, permitted, one pinned address against trying each), and ADR 0003 keeps the two routes' policies apart.
  2. Possible Primitive Obsession: the raw and the parsed egress proxy side by side. Pushed back: parsing in Config::load keeps the error in its own words, beside the private_networks check that needs the parsed proxy.
  3. Possible Speculative Generality: Egress::Default cannot be written. Pushed back: the enum names a rule's route; every unknown value, default included, fails loading, as tested.
  4. Possible Repeated Switches: two tables give upstream_failure. Pushed back: one maps a status the Gateway chose, the other the egress proxy's answer (ADR 0003's table), each in one place.
  5. A second error-exit convention in run. Pushed back: main prints run's other errors in their existing form, which the startup-failure checks read; only the load error needed its own words, as An operator can send a Gateway's destinations through an egress proxy #50 asks.

Spec, round 1

  1. A non-HTTP answer with the connection kept open waits for the deadline (A Workload learns why a proxied connection failed, and the Gateway never connects directly #51; Reach protected sites through an operator's egress proxy #49 story 32). Fixed: bytes that cannot begin HTTP/1. fail at once with proxy_unavailable.

Security, round 1 (the path list could not be read, so every changed path was judged as a control)

  1. LOW: the guide's Squid pin lets a name with one address outside the prefix reach that address, never with a signature. Fixed: as finding 1.

Spec, round 2 (fix round at low, on 47cdf6a against 719bffc; Correctness, Standards and Security found nothing)

  1. The guide's new deny was not in the configuration the Compose variant qualified (A maintainer can qualify the Gateway against a real Squid in the Compose demo #52, "taken from the configuration that passed"). Fixed: the demo's squid.conf denies the site's name on every address but the site's, and the variant's --verify passed again on 5d76a8b.

Round 3 (fix round at low, on 5d76a8b against 47cdf6a): Correctness, Standards, Spec and Security found nothing.

Correctness, round 4 (the widening of #50, at medium, on d84d66d against 5d76a8b, run at the owner's word after the three-round pause; Standards, Spec and Security found nothing, and Spec judged the added criterion MET)

  1. env's destination errors print in main's Debug form, not in their own words. Pushed back: the criterion asks for the same error from both commands, and serve has printed destination-check errors in this form since before this pull request, as main prints run's other errors (finding 15).
  2. An unknown command with a bad rule reports the rule, not the usage error. Pushed back: Config::load's errors already came before the command check; the destination checks join them.
  3. The checks could live inside Config::load, for every caller. Pushed back: run is the one caller of Config::load and of Config::policy, and serve needs the policy it builds.
  4. serve now runs the destination checks before the sandbox probe. Pushed back: load errors already came before the probe, a configuration error before an environment one, and the reference's serve row stays true.
  5. The explicit check that serve prints no startup line was dropped. Pushed back: refuses() asserts one line, and that line names the destination error, so the startup line cannot be there; a separate assertion could not fail while refuses() stands.

Tracking

Epic: E2 Reach protected sites through an operator's egress proxy
Spec: #49 Reach protected sites through an operator's egress proxy
Ticket: #50 An operator can send a Gateway's destinations through an egress proxy
Ticket: #51 A Workload learns why a proxied connection failed, and the Gateway never connects directly
Ticket: #52 A maintainer can qualify the Gateway against a real Squid in the Compose demo
Flag: none

🤖 Generated with Claude Code

sodre and others added 9 commits November 22, 2026 02:26
…an egress proxy

An optional top-level `egress_proxy` (an http URL with a host and a port)
sends every destination through the operator's HTTP proxy, unless its rule
says `"egress": "direct"`. On a proxied route the supervisor resolves only
the proxy's host, on every connection and outside `denied_networks`, sends
a plain-text CONNECT with the site's canonical name and port, and hands the
tunnel to the egress relay where the direct socket went. It resolves
nothing for the site and never tries a proxied destination directly. Until
the failure values land, any failure of the proxied leg is today's 502
`upstream_failure`.

Loading refuses an https proxy URL, one with credentials, any other
`egress` value, and `private_networks` on a proxied rule, naming the rule
and both fixes. `env` and `serve` refuse the same configurations, and print
the cause in its own words. Startup logs the egress proxy and the rules
that leave their address policy to it.

The runtime test gains a test-only CONNECT proxy that records each request
line. Through it, in sidecar and shared mode, the Workload reads the site
with the approved certificate while the Gateway cannot resolve the site's
name; one Gateway serves a proxied and a direct rule with
`private_networks`; lease lapse and retirement cut a proxied connection;
and proxy environment variables without `egress_proxy` change nothing.

ADR 0003 is accepted. The configuration reference, operator guide,
architecture page and design record describe both routes.

Ticket: #50

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the Gateway never connects directly

When the proxied leg fails, the Workload's CONNECT returns 502 with
`Countersign-Request-ID` and a `Countersign-Error` that says why:
`proxy_denied` for a 4xx answer from the egress proxy, `upstream_failure`
for a 5xx answer, as a direct route reports a site it cannot reach, and
`proxy_unavailable` when the proxy cannot be reached, resolves only inside
`denied_networks`, runs out the deadline, closes unanswered or answers with
something that is not HTTP. The proxy's own response body is never passed
on, and the Gateway logs each failure with its request ID and error value.

The runtime test's egress proxy learns to refuse with an error page of its
own, to close unanswered, to answer with something that is not HTTP, to
answer 503 when it cannot reach the site, and to tunnel a name it allows to
a site whose certificate is for another name. In sidecar and shared mode
the Workload reads each error value and no body. Two more Gateways per mode
have no usable egress proxy, one with nothing listening at its address and
one with its address inside `denied_networks`, while they can resolve and
reach the site themselves. The site and the test proxy record every
connection they accept, before any handshake, and every negative case
asserts the site saw none, and for `denied_networks` that the proxy saw
none either. Through the tunnel to the wrong certificate the request fails
and the test grant authority, which now records each signature it is asked
for, is asked for none.

The troubleshooting table covers a 502 and its three values, and the
operator guide's egress proxy section names them.

Ticket: #51

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in the Compose demo

`compose_demo.py --squid` layers `compose.squid.yaml` over the default
`compose.yaml`, which stays as it was. Squid runs from
`ubuntu/squid:6.6-24.04_edge`, pinned by digest, as the demo's user with a
read-only root and no capabilities. The Gateway shares the backend network
with the Broker and Squid; the site moves to a network only Squid shares,
in the network of a placeholder container, so stopping the site leaves its
name and address behind. The Gateway's configuration names
`http://squid:3128` as its egress proxy and its rule has no
`private_networks`. `squid.conf` allows CONNECT only to site.test:9444 on
the site's address, blocks metadata, link-local and loopback addresses, and
does no TLS interception.

With `--verify` the launcher checks that the Gateway logged the egress
proxy and can neither resolve the site's name nor reach its address. From
the approved request it correlates Squid's TCP_TUNNEL/200 line for the
CONNECT to the site's address, the fingerprint the site returned and the
approval, and the job page. Then, reusing that grant, it swaps Squid's
rule to refuse the site and reconfigures it (502 proxy_denied, Squid logs
TCP_DENIED/403 with no connection to the site), restores it and stops the
site (502 upstream_failure, Squid logs TCP_TUNNEL/503), and stops Squid
(502 proxy_unavailable). Each failure carries a request ID the Gateway
logs with the same error value.

The operator guide's egress proxy section gains example Squid ACLs taken
from that configuration and the answers Squid 6.14 gives. The developer
guide says how to run the variant and names the Squid version it was
qualified against.

Ticket: #52

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iting for the deadline

Review of spec #49, round 1:

- The proxy's answer is checked as it arrives. Bytes that cannot be an
  HTTP answer fail at once with proxy_unavailable, and a non-2xx status
  line returns at once, even when the proxy keeps the connection open.
  Lines may end in a bare LF (RFC 9112, 2.2).
- egress_proxy refuses port 0 at load.
- The egress proxy startup line comes after the destinations pass their
  checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ery address, as private_networks does

Review of spec #49, round 1: Squid's dst ACL matches when any one of a
name's addresses is in its list, measured on the pinned Squid 6.14, so
the example adds a deny on every address outside the prefix. The
troubleshooting row says upstream_failure can also mean the rule's roots
or revocation files did not load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…addresses is another

Review of spec #49, round 2: the operator guide's every-address pin was
not in the configuration the Compose variant qualified. The demo's
squid.conf now denies the site's name on every address but the site's,
as the guide's example does for a private site.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`env` now runs the destination checks before writing its exports, so a
launcher meets a bad rule, such as a wildcard rule with
`private_networks`, before the Gateway starts (#50, widened; #49 story 15).
`serve` runs them before probing the sandbox, so both print the same one
line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sodre
sodre marked this pull request as ready for review November 23, 2026 18:57
@sodre
sodre merged commit d5b15ba into main Nov 24, 2026
38 checks passed
sodre added a commit that referenced this pull request Nov 25, 2026
Closes #64

## Summary

Countersign 0.2.2 brings the Gateway's egress proxy (#55): an operator
can send the Gateway's upstream connections through an HTTP CONNECT
proxy, rule by rule. It also fixes a grant worker killed when glibc's
malloc opened a file (#63). Neither changes an existing setup:
`egress_proxy` is opt-in, and the fix needs no setting.

Every version source moves from 0.2.1 to 0.2.2, as in #45:

```diff
 Cargo.toml                       workspace version, and the `=` pins on countersign-pki and countersign-protocol
 Cargo.lock                       the five workspace crates only
 packages/widget/package.json
 packages/companion/package.json  the version publish_desktop.py checks against the tag
 recipe/recipe.yaml
-0.2.1
+0.2.2
```

It is a patch release, as 0.2.1 was for its features: every addition is
opt-in. After the merge, the squash commit on `main` is tagged `v0.2.2`,
which starts the registry, distribution and documentation workflows. All
of v0.2.1's tag workflows passed, so no publisher needs setting up
first.

## Evidence

| Criterion | Ticked | Shown by |
|---|---|---|
| Every version source is at 0.2.2 | yes | `python3
scripts/registry_release.py check --tag v0.2.2` |
| `registry_release.py check` passes and `cargo metadata --locked`
accepts the lockfile | yes | `python3 scripts/registry_release.py check
--tag v0.2.2`; `cargo metadata --locked` |
| The squash commit on `main` is tagged `v0.2.2`, and the tag's
workflows pass | no | Not run: the tag follows the merge |

On dae7a8c: `python3 scripts/registry_release.py check --tag v0.2.2`,
exit 0; `cargo metadata --locked --format-version 1`, exit 0.
`pnpm-lock.yaml` holds no workspace versions, so it does not change;
CI's `pnpm install --frozen-lockfile` checks that.

Not run: the tag's workflows, which start when the tag is pushed after
the merge.

## Merge Danger

**Door:** two-way for the merge, which only changes version strings. The
tag after it is one-way: crates.io and npm keep 0.2.2 once uploaded.

**Blast Radius:** every published package.

The merge ships nothing. The tag publishes the five crates,
`@zeroae/countersign-widget`, the npm desktop packages, the desktop
installers, and the `countersign-gateway` and `countersign-broker`
images tagged `v0.2.2`.

## Reviews

<details>
<summary>No review ran: the change is version strings only, as in
#45</summary>

</details>

## Tracking

Epic: none
Spec: none
Ticket: #64 Countersign 0.2.2 is released
Flag: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
sodre added a commit that referenced this pull request Nov 25, 2026
…rator's egress proxy is in git (#66)

Closes #49

## Summary

The text of the spec "Reach protected sites through an operator's egress
proxy" is in the repository at
`docs/specs/E2-49-reach-protected-sites-through-an-operator-s-egress-proxy.md`,
as the issue held it when the spec closed. Nothing changes for anyone
using the product.

```text
docs/specs/
└── E2-49-reach-protected-sites-through-an-operator-s-egress-proxy.md   # accepted, exported 2026-11-24
```

Before this closing, each of the spec's 53 user stories was mapped to
the test, static check or live run that proves it (the table under
Evidence). On `d5b15ba`, the squash of #55, seven stories (8, 11, 17,
21, 37, 38 and 42) held but were only partly tested: a Gateway broken on
purpose still passed every test. #61 added their cases, building #60, a
sub-issue of this spec that is now done. Story 52's Fargate step stays
out of scope, as the spec's Out of Scope says.

#61's body named "the pull request that closes #49", and GitHub read
that as a closing keyword: #49 closed when #61 merged. It was reopened
so that this pull request closes it, as `docs/agents/issue-tracker.md`
("Closing a spec") asks.

The verification also found #62: on x86-64, a grant worker was killed
when glibc's malloc opened a file, which failed #61's `curl` job. #63
fixed it, and both are in Countersign 0.2.2 (`v0.2.2`). #62 has no
milestone, so it never held this spec open.

## Evidence

| Criterion | Ticked | Shown by |
|---|---|---|
| Every sub-issue of #49 is closed | yes | `export-spec.py 49` |
| No issue but the spec is open in E2 | yes | `export-spec.py 49` |
| The spec has no release flag | yes | The spec's Further Notes:
"**Flag: none.**" |
| The file's text after its header is the issue's body | yes | The
comparison below |
| Every user story is proven by a test, a static check or a live run |
yes | The user-story table below |

No test or guard is new here: the seven cases #61 added were each shown
red there against a Gateway broken on purpose, and green against the
real one.

`python3 .claude/plugins/foresight/scripts/export-spec.py 49`, run on
59f95a9 after #61 and #65 merged: `wrote … as accepted: every sub-issue
is closed and only specs are open in E2 Reach protected sites through an
operator's egress proxy, so the pull request that adds this file closes
#49`. The sub-issues are #50, #51, #52, #53 and #60, all closed. The
text it wrote after the header is the same as the committed file's; only
its export day differed, so the committed file, exported 2026-11-24,
stands. A comparison of the file's text after its header with `gh issue
view 49 --json body`, CRLF read as LF: 20104 bytes in each, the same.

Not run: nothing.

<details>
<summary>The 53 user stories of #49: 39 Test, 12 Static, 10 Live run
(eight stories have two verdicts), 0 Partial, 0 Gap</summary>

Checked on `main` at 59f95a9, the squash of #65 (Countersign 0.2.2),
which holds #55's egress proxy and #61's cases for the stories marked
(#61).

- **The runtime test** is `crates/countersign-gateway/tests/runtime.py`.
Line numbers below are at 59f95a9. On 59f95a9, CI's *Sidecar mTLS* run
[45638935969](https://github.com/zeroae/countersign/actions/runs/45638935969)
passed it in all four jobs (`gateway-arm64`, `curl`, and
`gateway-filter-sandbox` on x86-64 and arm64). Each job printed
`sidecar/shared Gateway mTLS passed`, `sidecar/shared Gateway mTLS
through the egress proxy passed` and `sidecar/shared Gateway without a
usable egress proxy failed closed`, and `gateway-arm64` ran the silent
egress proxy's step under both worker sandboxes.
- **The Compose run** is the `compose_demo.py --squid --verify` output
posted on #52, from 5d76a8b with Squid 6.14. #55's body records a pass
on d84d66d too, but that run's output was not posted.
- **Documents:** a Static row whose proof is a document was checked by
reading that document on `main`. CI's `mkdocs build --strict` checks
only its links, not its words.

| # | Story (shortened) | Verdict | What proves it | Notes |
|---|---|---|---|---|
| 1 | Set `egress_proxy` once and every site goes through it | Test |
Proxied pass. `egress.take() == through_egress` (734). Every failing
rule's CONNECT is recorded by the test proxy (760–783). | One
`egress_proxy` line; every rule but `direct` goes through it. |
| 2 | Every destination uses the egress proxy by default | Test | Same
pass. The rules `site` and `refused` … `wrong` have no `egress` field
(516) and reach the proxy (734, 760–783). | |
| 3 | `"egress": "direct"` on one rule; one Gateway serves both routes |
Test | `res = request(user, to=direct)` returns the fingerprint, then
`assert egress.take() == [], 'A direct destination went through the
egress proxy'` (735–738). | #55's red run: route choice broken to always
use the proxy → 502. |
| 4 | No egress proxy: configuration and behaviour unchanged | Test |
Direct passes `sidecar/shared Gateway mTLS passed`. Their assertions are
unchanged from before #55; the diff only refactors the grant fixture.
The shared pass adds `"egress": "direct"` (535–538). | |
| 5 | The Gateway sends the site's name to the egress proxy | Test |
`assert egress.take() == [f'CONNECT {host} HTTP/1.1'] * len(users)`
(731–734), with `host = 'site.test:<port>'`. | |
| 6 | No resolution on a proxied route, for a network with no external
DNS | Test | `assert resolved.returncode == 2, ('The Gateway could
resolve the site itself', resolved)` (571–575) runs under the Gateway's
own NSS environment, and the proxied pass then succeeds. | Proves the
Gateway cannot resolve `site.test` and works anyway. It does not prove
the Gateway never tries a lookup, which the story does not need. |
| 7 | A private site through the proxy, with a rule that has no
`private_networks` | Test; Live run | Runtime: the `site` rule loses
`private_networks` (512) and the site is at the host's interface
address. Compose: the site is at 172.31.0.2 and the rule has no
`private_networks` (#52 run, `docs/develop.md`). | Whether the runtime
test's address is private depends on the host. The Compose run's address
always is. |
| 8 | A wildcard rule works through the egress proxy | Test (#61) | A
proxied rule `*.wild.test:<port>` without `private_networks`:
`reads_site(user, wild)` for each user, then `assert egress.take() ==
[f'CONNECT {wild} HTTP/1.1'] * len(users)` (740–742). | #61's red runs:
a wildcard rule refused on a proxied route at request time (403) and at
load (the Gateway exits). |
| 9 | Startup refused when a proxied rule has `private_networks` | Test
| `egress_configuration`: `error = refused('http://proxy.test:3128',
**base)` (438). `refuses()` asserts a non-zero exit and no stdout from
both `env` and `serve` (403–412). | #55's red run: `serve` started
(`TimeoutExpired`). |
| 10 | That error names the rule and both fixes | Test | `assert
re.search(r'\bsite\b', error) and 'private_networks' in error` and
`assert 'remove' in error and '"egress": "direct"' in error` (439–440).
| |
| 11 | Adding `egress_proxy`: every undecided private rule stops startup
| Test (#61) | `egress_configuration`: `[rule, second]`, the private
rule second. `refuses()` from `env` and `serve`, then `assert
re.search(r'\bsecond\b', error) and 'private_networks' in error`
(441–446). | #61's red run: the check limited to the first rule let
`serve` start. |
| 12 | An `https` egress proxy URL refused at startup | Test | `error =
refused('https://proxy.test:3128')`, then `assert 'egress_proxy' in
error and 'https' in error` (418–419). | |
| 13 | An egress proxy URL with credentials refused at startup | Test |
`assert 'egress_proxy' in error and 'credentials' in error and 'secret'
not in error` for `user:secret@` and `user@` (420–422). | The error also
does not echo the secret. |
| 14 | An unknown `egress` value fails loading | Test | `refused(...,
egress=value)` for `'proxy', 'default', 'Direct', 'none', '', None,
True, ['direct']`, with and without an egress proxy (447–449). | |
| 15 | `env` refuses what `serve` refuses | Test | `refuses()`: `assert
results[0].stderr == results[1].stderr` across `env` and `serve` (409).
Every refusal above goes through it, and so does the
wildcard-with-`private_networks` rule (430–433). | |
| 16 | Startup logs which destinations leave address policy to the proxy
| Test | `wait_for_log(rf'Gateway egress proxy localhost:<port> carries
the address policy of destinations: ' + ', '.join(['site', *failing,
'wild', 'ungranted']))`, a full match that leaves out `direct`
(620–622). | |
| 17 | The egress proxy's name resolved on every connection | Test (#61)
| `egress_proxy` is `http://proxy.test:<port>`, resolved only through
the Gateway's hosts file. The name moves to a second egress proxy on
127.0.0.2: `assert moved.take() == [f'CONNECT {host} HTTP/1.1'], 'The
Gateway did not follow the egress proxy'`. Moved back: `'The Gateway did
not follow the egress proxy back'` (748–758). | #61's red run: resolving
once and caching fails at `The Gateway did not follow the egress proxy`.
|
| 18 | The egress proxy allowed on a private address | Test; Live run |
The test proxy listens on 127.0.0.1, the address the Gateway's hosts
file gives `proxy.test`, inside the special-use blocks, and is reached
with no `private_networks` (511, 549). In Compose, Squid is on the
private backend network, where Squid logs the Gateway as 192.168.32.5. |
|
| 19 | `denied_networks` still applied to the proxy's address | Test |
Unusable pass with `denied_networks: ['127.0.0.0/8', '::1/128']` (930):
`proxy_unavailable`, then `assert not egress.accepted_since(seen), 'The
egress proxy saw a connection'` (682–685). | #55's red run: with the
filter removed, the egress proxy saw a connection. |
| 20 | A refusal by the proxy reported as `proxy_denied` | Test; Live
run | `fails_through_egress(failing['refused'], 'proxy_denied')` asserts
`headers.get('countersign-error') == error` (656, 760). In Compose:
`TCP_DENIED/403` → `proxy_denied`. | |
| 21 | An unreachable or silent proxy reported as `proxy_unavailable` |
Test (#61) | Unreachable: unusable pass. Closed, not HTTP, kept open:
`closed`, `garbled`, `banner`, `stub`. Silent: `runtime.py
--silent-egress-proxy`, `fails_through_egress(failing['silent'],
'proxy_unavailable', timeout=130)` (675–680). It runs in `e2e.yml`'s
`gateway-arm64` step "Fail a CONNECT through a silent egress proxy at
the Gateway's deadline", under both worker sandboxes. | Takes the
120-second deadline. #61's red run: with the deadline mapped to
`upstream_failure`, the case fails. |
| 22 | The proxy's "cannot reach the site" (5xx) reported as
`upstream_failure` | Test; Live run |
`fails_through_egress(failing['unreachable'], 'upstream_failure')`
(773). In Compose, Squid's `TCP_TUNNEL/503` with the site stopped →
`upstream_failure`. | |
| 23 | Each failure carries `Countersign-Request-ID` | Test |
`fails_through_egress`: `assert request_id, (to, answer)`, then
`wait_for_log(rf'Gateway CONNECT {request_id} {error}')` (657–661). The
Compose run matches each ID to the Gateway's log line. | |
| 24 | The operator guide says how to set the egress proxy | Static |
`docs/operate.md`, "Reach sites through an egress proxy": the example
configuration and its fields. | |
| 25 | The guide says where resolution and address policy happen on each
route | Static | The same section's table, with rows "Who resolves the
site's name" and "Who checks the site's addresses". | |
| 26 | Example Squid ACLs, blocking metadata, link-local and loopback |
Static | The same section's `squid` block: `to_metadata`,
`to_link_local`, `to_loopback`, each denied before any allow. | `squid
-k parse` on these rules was a one-off run in #55's review, recorded in
its body. The demo's `squid.conf` has the same rules, so the Compose run
exercises them. |
| 27 | The guide shows how to pin a private site to its prefixes |
Static | The same block: `billing_prefixes` and `billing_outside`, with
`http_access deny billing billing_outside`, and the paragraph on how
`dst` matches. | The test with mixed answers was a one-off run in #55's
review on Squid 6.14. |
| 28 | The configuration reference describes `egress_proxy` and `egress`
| Static | `docs/reference/config.md`: the `egress_proxy` row (Gateway
fields) and the `egress` row (destination fields). | |
| 29 | The troubleshooting table covers the two new error values |
Static | `docs/operate.md`, troubleshooting row "CONNECT returns 502":
`proxy_denied`, `proxy_unavailable`, and `upstream_failure` on a proxied
route. | |
| 30 | The egress proxy works in shared mode as in a sidecar | Test |
`for shared in (False,True)` runs the proxied and unusable passes in
both modes (922–931). CI prints `shared Gateway mTLS through the egress
proxy passed`. | |
| 31 | Workload client configuration unchanged on both routes | Test |
One `request()` (same `--proxy`, `--proxy-cacert`, `--cacert`) reads
`site.test` (proxied) and `direct.test` (direct) in one pass (623–628,
725–738). | |
| 32 | A proxied failure ends with a status and an error value, never a
hang, once the proxy has answered | Test | `banner`, `stub` and `lf`
answer and keep the connection open. Each must give its 502 inside
`connect`'s 8-second socket timeout (768–771). | #55's red run: against
the old read loop, each one timed out. |
| 33 | The proxy's own error page kept from the job | Test | `assert
body == b'' and b'egress proxy' not in answer` (660), on every negative
case. The test proxy sends `ERROR_PAGE` with each 403 and 503 (250–251,
289, 303). | |
| 34 | Prompt, grant and cutoff work the same on a proxied route | Test;
Live run | Grant: the site returns the approved certificate's
fingerprint (727–730). Cutoff: the lease cutoff runs in the proxied pass
(805–827). Prompt: in the Compose run, the Companion approval reaches
the site through Squid. | The runtime test's grant authority stands in
for the prompt, so only the Compose run covers the prompt itself. |
| 35 | Revoking a grant cuts a proxied connection as a direct one | Test
| Shared proxied pass: `broker.retired['bob'].set()`, then `assert
site.cutoff.wait(1)` (831–840), before the proxied pass returns
(841–843). | |
| 36 | Never a fallback from the egress proxy to a direct connection |
Test | `assert not site.accepted_since(seen), (to, 'The site saw a
connection', answer)` in every `fails_through_egress` case (651). The
unusable pass gives the Gateway a working direct route and checks that
it went unused (549–550, 573). | #55's red run: a direct fallback added
on purpose was caught. A silent proxy is story 21's case, which #61
added. |
| 37 | Site certificate checked against the hostname and the rule's
roots before any signature | Test (#61) | `for name in ('wrong',
'untrusted')`: the request fails, `egress.take()` records the allowed
tunnel, and `assert failing[name] not in broker.signatures` (778–782).
`untrusted`'s `roots` is another CA. | #61's red run: with trust loaded
from another rule's roots, the request succeeded. |
| 38 | A site still needs its destination rule at the Gateway and the
Broker | Test (#61) | `refused_before_egress(unlisted)` (a grant, no
rule) and `refused_before_egress(ungranted)` (a rule, no grant). Each
asserts `HTTP/1.1 403`, then `'The egress proxy saw a connection'` and
`'The site saw a connection'` are both false (667–673, 745–747). | #61's
red runs: the rule check bypassed gives 200; a tunnel opened on a
refused admission is seen by the egress proxy. |
| 39 | The egress proxy carries only encrypted bytes | Test; Live run |
The test proxy pumps raw bytes to a TLS site that requires a client
certificate (`site_tls.verify_mode=ssl.CERT_REQUIRED`), and the grant
authority asserts `body['tls'] == 'tls13'` on each signature (218). A
clear-text byte after the CONNECT head would break that handshake. In
Compose: Squid has no `ssl-bump`, logs `TCP_TUNNEL/200`, and the site
saw the approved fingerprint. | |
| 40 | Grant worker and worker sandbox unchanged | Static; Test | #55's
diff touches no file under `runtime/worker.rs` or `worker_sandbox.rs`.
The proxied leg is in the supervisor (`egress::tunnel` from
`connect_request`). The proxied passes run under both sandboxes in CI
(`gateway-filter-sandbox`). | #63 later changed `worker_sandbox.rs` for
a glibc malloc read (#62), which the egress proxy did not cause: the
same kill could come on a direct route. |
| 41 | ADR 0003 says which checks move to the proxy and which stay |
Static | `docs/adr/0003-…md`, `status: accepted`. Decisions 3 (move), 4
(stay) and 6 (the proxy's own address). | |
| 42 | The Gateway ignores proxy environment variables on this leg |
Test (#61) | `ignored` pass, as before. In the proxied passes, the six
variables name a dead address beside `egress_proxy` (563–569), and every
proxied request still succeeds. | #61's red run: `egress::tunnel`
preferring `HTTPS_PROXY` fails the first proxied request with 502. |
| 43 | The design record's resolution paragraph names both routes |
Static | `docs/specs/2026-11-17-countersign-design.md`: "A destination
takes one of two routes. On a direct route … On a route through the
operator's egress proxy (ADR 0003) …". | |
| 44 | The runtime test sends a request through a test-only CONNECT
proxy on every pull request | Static | `.github/workflows/e2e.yml` (`on:
[push, pull_request]`), step `timeout 120 python
crates/countersign-gateway/tests/runtime.py …` and
`scripts/filter-sandbox-container.sh`. The proxied passes always run
(`main`, 922–931). | |
| 45 | That test proves the site saw nothing when the proxy refused or
was unreachable | Test | As story 36: line 651 for `refused`, `closed`,
`garbled`, `banner`, `stub`, `lf` and `unreachable`, and both unusable
passes. | |
| 46 | That test proves the proxy got the site's name, not an address |
Test | As stories 5 and 6 (575, 734). | |
| 47 | That test runs one Gateway with a proxied and a direct
destination | Test | As story 3 (735–738). | |
| 48 | That test rejects a wrong-hostname certificate through an allowed
tunnel | Test | `wrong` (778–782). `assert egress.take() == [f'CONNECT
{failing["wrong"]} HTTP/1.1'], 'The egress proxy refused the tunnel'`
proves that the tunnel was allowed. | #55's red run: with the site
certified for `wrong.test`, a signature was made. |
| 49 | A Compose variant with a real Squid to run before a release |
Live run | `compose_demo.py --squid --verify`, the run posted on #52
(5d76a8b, Squid 6.14, exit 0). `docs/develop.md`, "Qualify the Gateway
against a real Squid". | |
| 50 | That variant correlates Squid's log, the site's certificate and
the Workload's read from one run | Live run | #52 run: `Squid tunneled
the Workload's CONNECT: … TCP_TUNNEL/200 … CONNECT site.test:9444 …
HIER_DIRECT/172.31.0.2`, `Compose mTLS accepted selected SHA-256
5d01b2…` and `Job page matched the fingerprint the site received with
the approval`. The checks are `Squid.logged` and `verify` in
`compose_demo.py`. | The posted run is on 5d76a8b. Between it and
d84d66d, `compose_demo.py` did not change on the default path. |
| 51 | The glossary defines egress proxy | Static | `GLOSSARY.md`:
**Egress proxy**, _Avoid_: upstream proxy, outbound proxy, Squid. |
Landed with #53. |
| 52 | #46's reporter has a documented, passing Compose configuration |
Live run | The #52 run, plus `docs/develop.md` and
`examples/demo-integrator/{compose.squid.yaml,squid.conf}`. | Repeating
it on Fargate is out of scope: "Repeating the run on Fargate 1.4.0 with
the filter sandbox. The reporter does that from the documented Compose
configuration; Countersign's part ends at Compose for now." #52's live
step (a comment on #46) is a separate matter. |
| 53 | The demo walkthrough is unchanged unless the Squid variant is
asked for | Static; Live run | `examples/demo-integrator/compose.yaml`
is unchanged by #55, and `--squid` is an opt-in `store_true` flag. #55's
body: the default `--verify` passed on 17525c6, and the default `docker
compose config` was identical before and after. | After 17525c6,
`compose_demo.py` changed only inside `Squid.configure`. |

**Summary:** 53 stories, each proved: by test, statically, by the live
run, or by a mix of these. No story is excluded whole. Only story 52's
Fargate step is out of scope. Stories 8, 11, 17, 21, 37, 38 and 42 were
Partial or Gaps on d5b15ba, the squash of #55; #61 added their cases,
each red once against a Gateway broken on purpose.

</details>

## Merge Danger

**Door:** two-way. A revert removes the file, and #49 is reopened by
hand.

**Blast Radius:** none.

The merge ships no image, release or infrastructure, and no flag. The
handbook excludes `docs/specs/` (`mkdocs.yml`, `exclude_docs`).

## Reviews

<details>
<summary>No review ran: the file is the issue's text, checked byte for
byte</summary>

</details>

## Tracking

Epic: E2 Reach protected sites through an operator's egress proxy
Spec: #49 Reach protected sites through an operator's egress proxy
Ticket: none
Flag: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
sodre added a commit that referenced this pull request Nov 25, 2026
…argate behind Squid (#67)

Closes #46

## Summary

The tested platforms page now lists the egress proxy as qualified on ECS
Fargate 1.4.0 x86-64 behind Squid 6.14, on release v0.2.2. It also says
which cases were checked in the Compose demo only, and that egress
proxies other than Squid 6.14 are unqualified.

```diff
 docs/reference/support.md
   ## End-to-end and deployment evidence
+  | ECS Fargate 1.4.0 x86-64, behind Squid 6.14 | v0.2.2: a sidecar Gateway under "filter" reached an mTLS site only through Squid … |
   ## Gateway hosts and the worker sandbox
   | ECS Fargate 1.4.0 | x86-64 | Qualified | … · End to end again on release v0.2.2, as a sidecar behind an egress proxy … |
   … remain unqualified: … external protected sites,
+  egress proxies other than Squid 6.14,
   and an end-to-end run of the filter sandbox on Fargate arm64
```

#46 asked for a Compose qualification, documentation, and a repeat on
Fargate. Spec #49 and its pull request #55 built the Gateway's egress
proxy, the Compose qualification and the operator guide. The Fargate
repeat was the one step left: the reporter ran it on v0.2.2 and posted
it on #46. This pull request records that run and closes the issue.

## Evidence

#46 has no checkboxes (`tick-criteria.py 46`: "#46 has no acceptance
criteria"), so the rows are its numbered "Requested validation".

| Criterion | Ticked | Shown by |
|---|---|---|
| 1. A repeatable Compose test: the site reachable only through Squid,
Squid allowing `CONNECT` to the test hostname and port, with no TLS
interception | yes | `compose_demo.py --squid --verify` |
| 2. From one approved run, correlate Squid's successful `CONNECT`, the
approved certificate at the site and the flag at the Workload | yes |
`compose_demo.py --squid --verify` |
| 3. A refusal at Squid and an unavailable Squid each fail with no
direct retry; a site certified for the wrong hostname is still refused |
yes | `compose_demo.py --squid --verify`; `runtime.py`, "Proxied pass:
wrong hostname gets no signature" |
| 4. The operator guide says how to set the Gateway's outbound proxy,
and where name resolution and address policy happen | yes | #55's
documentation check |
| 4. The passing configuration repeated on Fargate 1.4.0 with
`worker_sandbox: "filter"`, the flag checked in chat | yes | The
reporter's run on v0.2.2 |
| The tested platforms page records the Fargate run | yes | `mkdocs
build --strict` |

No test is new here. #55 added the tests above, each shown red there.

- **`compose_demo.py --squid --verify`**, with Squid 6.14 from the
pinned image ([its run on
#52](#52 (comment))):
- Squid logged `TCP_TUNNEL/200` for `CONNECT site.test:9444`, the site
returned the fingerprint approved in the Companion, and the Workload
read the response.
- With the grant still live, Squid refusing the site gave
`proxy_denied`, and Squid stopped gave `proxy_unavailable`. Squid logged
`TCP_DENIED/403` with `HIER_NONE` and nothing, so neither reached the
site.
- **`runtime.py`, proxied pass, in #55:** a site certified for
`wrong.test` failed with no signature asked of the grant authority. It
was red when that check was skipped: `A site with the wrong certificate
got a signature`.
- **#55's documentation check** found `docs/operate.md`'s section "Reach
sites through an egress proxy", with its rows "Who resolves the site's
name" and "Who checks the site's addresses", and the `egress_proxy` row
of `docs/reference/config.md`.
- **[The reporter's
run](#46 (comment),
on Fargate 1.4.0 x86-64 with release v0.2.2 and Squid 6.14:
- The image's digest,
`sha256:e56403fd9129c777590cd4b01b2fd8f61b8ba2e9ca616be9ce190b88439357ab`,
is the `linux/amd64` manifest of
`ghcr.io/zeroae/countersign-gateway:v0.2.2` (`docker buildx imagetools
inspect`).
- The Gateway logged `Gateway worker sandbox "filter": non-dumpable,
Landlock ABI v2, seccomp allow-list`.
- A direct probe to the site timed out, and Squid logged
`TCP_TUNNEL/200`.
- The site saw the approved certificate's fingerprint, and the chat
reply's hash matched the site's flag.
- **`mkdocs build --strict`**, on this branch: clean. In the built page,
the new row renders, and its links to
`#reach-sites-through-an-egress-proxy` and
`#end-to-end-and-deployment-evidence` land on headings that exist.

Not run: nothing.

## Merge Danger

**Door:** two-way. A revert removes the row and the clause.

**Blast Radius:** the tested platforms page.

The merge publishes the documentation site. It ships no image, release
or infrastructure, and no flag.

## Reviews

<details>
<summary>No review ran: the change is one documentation row and a
clause, recording a run quoted on #46</summary>

</details>

## Tracking

Epic: none
Spec: none
Ticket: #46 Validate Gateway sidecar mTLS through a mandatory Squid
CONNECT proxy
Flag: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@sodre
sodre deleted the e2/49-egress-proxy branch November 25, 2026 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant