Repository navigation
test(agent): demonstrate #831 against a real Envoy — the leak is real, aether is not exposed - #841
Merged
Merged
Conversation
…, aether is not exposed (#831) Issue #831 is the highest-severity open item and was derived from source reading, never demonstrated. This turns it into a fact, and the fact is that the chain breaks at the link the issue did not examine. CONFIRMED, in Envoy: the source SPIFFE ID reaches the cluster through set_filter_state's default FactoryKey "envoy.string", which builds a Router::StringAccessorImpl. That type is not Envoy::Hashable, and CommonUpstreamTransportSocketFactory::hashKey folds a downstream shared filter-state object into the upstream pool hash only for Hashable objects. The identity that picks the client certificate contributes zero bytes to the pool key. //test/mtlspool reproduces the consequence on the pinned proxy: with pools shared across downstream connections, 11/11 requests from the second ServiceAccount are verified by the destination as the FIRST one, all multiplexed onto a single upstream HTTP/2 connection. REFUTED, for aether: every mesh cluster the node proxy builds already sets connection_pool_per_downstream_connection (proxy.NewServiceCluster / NewTCPServiceCluster via SnapshotCache.perDownstreamConnectionPool). That mixes the downstream connection id into the hash in both the HTTP and TCP pool paths (cluster_manager_impl.cc), so each source pod gets its own pool. Same harness, same scenario, flag on: each source is verified as itself on its own upstream connection. The edge passes false, correctly — one identity cannot leak into itself. So the flag is security configuration, not a throughput knob, and nothing said so where someone tuning pooling would look. Three changes make that durable: - accesslog.go gains source_spiffe_id, the identity the control plane stamped for the hop. Joined to the destination line's downstream_peer_uri_san (#824) on x_request_id the two must agree; a disagreement is a matcher miss or a pooling leak, both previously invisible. :PLAIN is mandatory — the formatter defaults to TYPED and renders "-" for a StringAccessorImpl. The pinned Envoy parses the field in //test/envoy_validate, which already runs the access-log config through a real config loader. - //test/mtlspool runs the real proxy with two ServiceAccounts on one node and asserts the destination verifies the right certificate on EVERY request, not just the first — the shape nothing in the tree exercised, and exactly the one that hides a pool-key omission. It carries its negative control: the same scenario with the flag off must leak, so the green result cannot be a test that is unable to fail. - TestNodeProxyPerSourceClustersPoolPerDownstreamConnection fails the build if any cluster carrying a per-source transport_socket_matcher loses the flag. Verified red by flipping perDownstreamConnectionPool(). SourceIdentityFilterStateKey and BuildSourceFilterStates are exported so the out-of-tree harness stamps what production stamps rather than re-spelling the protos; a drifted key would let the test pass by matching nothing. //test/envoybin is the pinned-Envoy locator, factored out of the envoy_validate test so a second runtime gate can use it. No production behaviour changes beyond the added access-log attribute. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Sep 20, 2026
bpalermo
added a commit
that referenced
this pull request
Sep 20, 2026
proxy/README.md points at //test/envoy_validate:envoy_bin as the one-command way to re-confirm what envoy_server_version reports. #841 factors that target out, so say the label may move rather than leave a reference that silently goes stale. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
added a commit
that referenced
this pull request
Sep 20, 2026
…kill -TERM stop the soak churn driver (#835) (#845) * fix(build): stamp OCI provenance on every published image, and record what envoy_server_version really is (#837) You could not tell which Envoy a running `aether-proxy` contained, from the process or from the image. Two symptoms, one gap, and the first one is now answered rather than guessed at. ## envoy_server_version reports the AETHER commit, not Envoy's Established outright, not inferred — and not from a running pod. `//test/envoy_validate:envoy_bin` is the Envoy binary extracted from the *published* aether-proxy image at the digest the chart pins, so it can be asked directly: envoy version: cff8beb/1.40.0-dev/Clean/RELEASE/BoringSSL `cff8beb87eb685a44e00cf70c1a534695039da1b` is an **aether** commit — it is that image's own `tag:` in `charts/aether/values.yaml`. The Envoy component of the string is bare `1.40.0-dev`, with no Envoy revision in it at all. The gauge for that image is therefore `0xcff8be`. The `0x2FA24A` = 3121738 in the issue decodes the same way: aether commit `2fa24a8` ("test: drop duplicate integration targets … (#772) (#788)"). It is simply an older image than the chart's current pin. The chain that produces it: * `proxy/.bazelrc` sets `--workspace_status_command="bash bazel/get_workspace_status"`, and that script runs `git rev-parse HEAD`. `proxy/` is a nested workspace inside the aether repo, so BUILD_SCM_REVISION is the aether commit. Envoy is a bzlmod dep; nothing asks its git anything. * `envoy_cc_binary` defaults to `stamp = 1` — cc_binary's "stamp even under `--nostamp`" — so `//source/common/version:version_linkstamp` compiles that real sha in although no build here passes `--stamp`. Verified against a minimal cc_binary + linkstamp: `--nostamp` yields the redacted BUILD_SCM_REVISION `"0"`, and `stamp = 1` yields the workspace-status value. * `server.cc` does `atoull(revision().substr(0, 6), 16)`. So the gauge is 24 bits of the aether commit. Useful, but it will never match `13144f` and was never going to. `proxy/README.md` now says so, with both the derivation and the one-command way to re-confirm it locally, so nobody re-derives this. ## Provenance on the artifact Verified against the published index rather than assumed: every image we publish has `Labels: null`, and the only annotation on `aether-proxy` is `org.opencontainers.image.source` **inherited from distroless/cc**, pointing at GoogleContainerTools/distroless — a confident wrong answer, worse than absent. The rules_img images carry only `org.opencontainers.image.base.*`. Both arches were decoded this time (#837 asked): amd64 and arm64 are identical in every provenance respect — same absent labels, same zero `created`, same single inherited annotation. Only layer digests and `architecture` differ, so the original arm64-only analysis was fully representative. Now, on all nine images (agent, mesh-dns, proxy-supervisor, cni-install, registrar, controller, prober, udsecho, and the proxy): * `org.opencontainers.image.source` — this repo, **overriding** the inherited distroless value (rules_oci merges with `.annotations += {...}`, ours wins); * `org.opencontainers.image.revision` — the aether commit; and on `aether-proxy` alone, the fact recoverable no other way: * `dev.aethermesh.envoy.module-version`, `.revision`, `.bazel-registry`. The registry commit is in there because the envoy bazel-registry keeps one version directory per module and deletes the previous one, so the module version alone does not resolve. ## Determinism did not regress — measured, not assumed Zero timestamps stay: `created` is still unset and history entries are still `bazel bu…`. `revision` is a fixed string, not a clock. * rules_img: `stamp = "force"` on image_manifest/image_index, so the label is correct in *every* configuration — plain `bazel build` included, where "auto" would have baked the literal `{{.STABLE_GIT_COMMIT}}` in. The ExpandTemplate action takes stable-status.txt as an input; volatile-status (BUILD_TIMESTAMP) is constant-metadata to Bazel and invalidates nothing. Proof: `bazel shutdown` then rebuild ⇒ **4556 action-cache hits, 0 actions re-executed, byte-identical index digest** (`sha256:ea16c042…`). The new STABLE_GIT_COMMIT key is stable on purpose: a volatile one would let a cached config blob re-publish the *previous* commit's sha, which is the failure mode this issue is about. * proxy: the metadata genrule is tagged `no-cache` for the same reason — BUILD_SCM_REVISION is volatile there. It is two `sed`s, and its output is byte-identical at a given commit, so `:image`/`:push` still cache-hit. Between commits only the tiny config/manifest actions re-run. No layer, no compile, no link. Prerequisite for #830's next Envoy pin bump, which is exactly the shape of change where "which Envoy is actually running?" must be answerable from the artifact. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * fix(soak): make kill -TERM stop the churn driver instead of firing the next roll (#835) `trap restore_shrink EXIT INT TERM` bundled the safety net with the stop signals, and `restore_shrink` *returns* rather than exiting. So on TERM bash ran the handler, the handler returned, the in-flight `sleep` inside `waituntil` had already been interrupted, and control fell straight through to the next `roll`. The signal sent to stop the driver made it fire early — an unscheduled `ROLLED aether-test/deployment/svc-1` at 23:10:32Z on 2026-09-19, with the driver still running afterwards. That reads in the log as "the tool ignored my signal", which sends you debugging the wrong thing; the tool did the opposite, and the two need different debugging. Split the traps, keeping EXIT as the idempotent safety net: trap restore_shrink EXIT trap 'restore_shrink; exit 130' INT trap 'restore_shrink; exit 143' TERM Reproduced and verified, with `kubectl` stubbed and no cluster involved: * pre-fix, TERM ⇒ driver STILL RUNNING, 1 unscheduled `ROLLED …/svc-1` — exactly the 2026-09-19 observation; * post-fix, TERM ⇒ exit 143, 0 rolls. The idempotency claim was checked rather than taken on trust: a full-schedule dry run (`sleep` stubbed, so all 452 minutes run in seconds) still logs 31 ROLLED and makes exactly **two** `kubectl scale` calls for the SHRINK — down to 0 and back to the replica count it read first. The EXIT trap firing again after `shrink()`'s own `restore_shrink` is a no-op, because `restore_shrink` clears SHRINK_PREV before it scales. `e2e/soak/README.md` gains a "Stopping the churn driver" section for the whole family, since these are cases where the safety action causes the harm: * stop it with `kill -9 <pid>`. Even with the traps fixed, a TERM to the driver's pid alone leaves its `sleep` child running and bash defers the handler until that `sleep` returns — measured: still parked twelve minutes later. Only a TERM that also reaches the child stops it promptly; * never `pkill -f "soak/churn.sh"`: the pattern appears in the command line of the shell issuing it, so it kills your own session too. `pgrep -cf` has the same flaw in the harmless direction — it reads one driver too high. Anchor on the absolute script path; * before launching, check for an existing driver by absolute path and refuse to start a second. Two share `/tmp/soak-churn.log` and interleave into ~62 rolls, which does not fail a run, it silently invalidates it; * at grade time count ROLLED in `/tmp/soak-churn.log` only — older `/tmp/soak-churn-*.log` files match a naive glob and inflate the tally; * never patch `churn.sh` while a soak is running: bash reads scripts incrementally by byte offset, so editing an executing script can corrupt its control flow. Verified no driver was running before this edit. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr * docs(proxy): note that the pinned-Envoy target may move under #841 proxy/README.md points at //test/envoy_validate:envoy_bin as the one-command way to re-confirm what envoy_server_version reports. #841 factors that target out, so say the label may move rather than leave a reference that silently goes stale. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr --------- Co-authored-by: Claude Opus 5 <[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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Verdict: the mechanism is CONFIRMED, the exposure is REFUTED
#831 was derived from source reading. It is now demonstrated, against the pinned
aether-proxyEnvoy, in both directions.Confirmed, in Envoy. Every link the issue names is real. The source SPIFFE ID
is stamped with
set_filter_state's defaultFactoryKey: "envoy.string"→Router::StringAccessorImpl, which is notEnvoy::Hashable, andCommonUpstreamTransportSocketFactory::hashKey(
source/common/network/transport_socket_options_impl.cc:47-53) folds a downstreamshared filter-state object into the upstream pool hash only behind a successful
dynamic_cast<const Hashable*>. The identity that selects the client certificatecontributes zero bytes to the pool key. Under h2 the consequence is exactly as
severe as the issue's follow-up comment says.
Refuted, for aether. The chain breaks at the link the issue did not examine:
"Pools are keyed by cluster + host and are shared across source identities on the
node proxy." They are not. Every mesh cluster the node proxy builds sets
connection_pool_per_downstream_connection(proxy.NewServiceCluster/NewTCPServiceCluster, viaSnapshotCache.perDownstreamConnectionPool()=!c.edge), and Envoy mixes the downstream connection id into the hash in bothpool paths —
cluster_manager_impl.cc:2189(HTTP) and:2317(TCP),ConnectionImplBase::hashKey→addIdToHashKey(hash, id()). One pool perdownstream connection, and a downstream connection is one pod, so there is nothing
to share. The edge passes
false, correctly: one identity cannot leak into itself.docs/runbook.mdalready carried this as a derived note. This PR upgrades it toa demonstrated one, and closes the gap that made #831 plausible in the first place:
nothing said the flag was load-bearing security configuration where someone
tuning connection pooling would look.
The evidence, both ways
The harness (
//test/mtlspool) runs the real pinned proxy with two sourceworkloads on different ServiceAccounts on one node, both calling the same
upstream, and measures the URI SAN the destination actually verifies — the same
value the inbound listener stamps into XFCC (
SANITIZE_SET+set_current_client_cert_details.uri).--concurrency 1is load-bearing: poolsare per worker thread.
Negative control —
connection_pool_per_downstream_connectionremoved. This isprecisely the configuration #831 assumes aether has. It is the run that proves the
assertions can fail:
11/11 — not a race with a window. Every request from
source-bis verified assource-a, all multiplexed onto one upstream HTTP/2 connection. Before the harnesscaptured the peer certificate at handshake time it reported
-for every request(Go's bundled h2 server leaves
http.Request.TLSnil on go1.27); that first runwas red for the wrong reason and is noted in the code so nobody re-lands it.
Production configuration — the flag as aether sets it:
Each source verified as itself, on its own upstream connection, on every request.
The node identity gets its own certificate in the harness so a matcher miss
(#686/#825) cannot be mistaken for a pooling leak.
What is in the PR
1.
source_spiffe_idin the access log (accesslog.go). The identity thecontrol plane claimed for the hop, beside
source_netns. Its value is the pair:join it to the destination line's
downstream_peer_uri_san(#824) onx_request_idand the two must be equal. A disagreement is either a matcher miss(node/agent SVID at the destination) or a pooling leak — both invisible until now.
:PLAINis mandatory; the formatter defaults to TYPED andStringAccessorImplhasno
serializeAsProto, so the TYPED form renders-on every line, silently. It iscovered in
//test/envoy_validate, which already runs the access-log configthrough a real Envoy config loader, so the pinned build has parsed the operator.
2.
//test/mtlspool— the runtime gate described above, carrying its ownnegative control. A failure of the control does not mean aether broke; it means
the harness lost its discriminating power and the green assertion stopped proving
anything. That reading is in the test's doc comment.
3.
TestNodeProxyPerSourceClustersPoolPerDownstreamConnection(
agent/internal/xds/cache/) — the cheap guard. Any cluster carrying a per-sourcetransport_socket_matcherwithout the flag fails the build. Verified red byflipping
perDownstreamConnectionPool()tofalse: three clusters, with thereason in the failure message.
4. Runbook. The existing "Why a wrong cert cannot leak across sources through
pooling" note now states the demonstration, names the test, and says plainly that
the flag is security configuration.
proxy.SourceIdentityFilterStateKeyandproxy.BuildSourceFilterStatesareexported so the out-of-tree harness stamps what production stamps rather than
re-spelling the protos — a drifted key would let the test pass by matching nothing.
//test/envoybinis the pinned-Envoy locator factored out of theenvoy_validatetest so a second runtime gate can reuse it.
No production behaviour changes beyond the added access-log attribute. No new
module dependencies.
What I could not establish
demonstration is a single-worker Envoy on loopback; the production node proxy runs
many workers, which only makes a shared pool less likely to be shared, never more.
NewUDPServiceClustercarriesno flag and no client certificate — UDP rides the mesh in plaintext by design, so
there is no identity to leak, but nothing here says anything about it.
Hashablefix was not attempted, per the task. It remains theright long-term shape: a hashable string filter-state factory (or
hashable: trueon
set_filter_state) would let the mesh dropconnection_pool_per_downstream_connectionand recover cross-source upstreammultiplexing, which is real throughput currently being paid for correctness. Worth
its own issue with that framing — the flag is a mitigation, not the end state.
DownstreamTransportSocket(transportsocket.go:35-49) pins no client SANs, soany trust-domain member satisfies it. A
spiffe://<td>/ns/*/sa/*prefix matcherwould reject a non-workload certificate and make the XFCC value structurally
trustworthy. That is independent of pooling and I did not touch it.
Closes #831.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
Co-Authored-By: Claude Opus 5 [email protected]
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr