Repository navigation
fix(agent): give the readiness probe its own TLS context, and make an unpinned cluster loud (#836, #832) - #840
Merged
bpalermo merged 2 commits intoSep 20, 2026
Conversation
… unpinned cluster loud (#836, #832) Two identity defects found while investigating #829, in the same files and the same subsystem (upstream TLS / server-identity pinning). #836 — the inboundready_<pod> probe shared the mesh clusters' upstream TLS builder. That probe dials each local pod's mesh inbound INSIDE that pod's netns every 5 s, so its TLS peer is always a local pod presenting that pod's SVID; in #829 a probe-sourced session ended up serving mesh clusters, which is how a local pod's certificate reached unrelated clusters' handshakes. The probe now builds its OWN UpstreamTlsContext (InboundReadyProbeTransportSocket) carrying its own MaxSessionKeys: 0, so the boundary holds if #834's global switch is later reversed for a good reason. The SAN pin and the empty SNI are unchanged — both are load-bearing. #832 — a cluster whose SAN pin cannot be rendered (no trust domain yet, or endpoints with no namespace metadata) ships a validation context with no match_typed_subject_alt_names, so the handshake proves only trust-domain membership: any mesh workload satisfies it. Emitting that rather than the unservable "spiffe:///ns/…" is the right call (#815/#819), but shipping it silently is not. Each snapshot now WARNs once naming the affected clusters with the reason, and counts them in aether.agent.identity.cluster_unpinned — seeded at zero, because a counter that is never incremented is not a series. Plus the config-shape gate: //test/envoy_validate asserts every upstream TLS context in a generated bootstrap carries a non-empty match_typed_subject_alt_names. `envoy --mode validate` ACCEPTS an unpinned context, so a passing validate says nothing about it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
deleted the
fix/836-832-probe-tls-boundary-and-unpinned-clusters
branch
September 20, 2026 11:28
bpalermo
added a commit
that referenced
this pull request
Sep 20, 2026
) (#850) proxy.DownstreamTransportSocket set RequireClientCertificate: true with a validation context carrying no SAN matchers at all, so the inbound handshake proved only trust-bundle membership — any certificate that bundle signs, including identities that are not workload SVIDs. The inbound HCM then stamps that certificate's URI SAN into XFCC with SANITIZE_SET (ingress.go), and RBAC/ext_authz decisions key on that value, so the property every XFCC-derived rule assumes was never actually established. The destination cannot pin a specific ServiceAccount — in a mesh any workload may legitimately call — but it can require the certificate to be STRUCTURALLY a workload SVID. Each mTLS inbound chain now carries a combined validation context with one match_typed_subject_alt_names entry: san_type URI, prefix "spiffe://<trust-domain>/ns/". Envoy builds StringSanMatcher(GEN_URI, matcher) for URI SANs (source/common/tls/cert_validator/san_matcher.cc), so the full StringMatcher surface applies; only DNS gets the RFC 6125 special case. The TCP floor gets the same pin and needs it most: it is the listener's DEFAULT chain and tcp_proxy forwards raw bytes to the application, so there is no XFCC and no HTTP-level authorization behind it at all. Empty trust domain emits NO matcher, never "spiffe:///ns/". A prefix built from an empty trust domain matches no certificate any CA in this mesh has issued, so it would fail every inbound handshake on that pod — #815/#819 with a node's blast radius. That branch is defence in depth rather than a live path: NewInboundListener already returns ErrNoTrustDomain first, so the reachable outcome is a skipped pod with a WARN naming it. No new counter for an unpinned inbound, deliberately, unlike #840's cluster_unpinned: that counter exists because the cluster path deliberately SHIPS the unpinned form as the lesser evil and did so silently. Here the lesser evil is refusing to build the listener, which is already loud. The gate is a build-time config-shape assertion instead — UnpinnedInboundChains over the generated bootstrap bytes — which also covers a future caller that bypasses the ErrNoTrustDomain guard, something a runtime counter could not. envoy --mode validate ACCEPTS an unpinned downstream context, the same fail-open direction #832 found upstream. Proved non-vacuous by forcing WorkloadSANPrefix to "": the assertion named every affected chain (inbound_test-pod/in_tcp_test-pod, /in_test-pod, /in_test-pod_8080) while all seven bootstraps still reported "configuration ... OK". The node identity satisfies the pin: the agent is an ordinary pod, so SPIRE's fallback ClusterSPIFFEID issues it spiffe://<td>/ns/aether-system/sa/aether-agent (#825). That matters because the inboundready_<pod> probe dials every local pod presenting it — a rejection there would demote endpoints, the rev222 failure mode. //test/envoy_validate's fixtures still spelled the node identity as spiffe://<td>/node/test-node, which the new pin would REJECT; they now use the production shape, and a proxy-package test asserts the probe's certificate satisfies the pin directly. Scope note: the prefix names the LOCAL trust domain, which makes it exactly as restrictive as the upstream pin already shipped (cache/mtls.go renders exact spiffe://<local-td>/ns/<ns>/sa/<svc> matchers). Cross-trust-domain traffic is therefore already impossible in the client direction, and proposal 019 states a shared trust domain as a precondition with SPIRE federation deferred. If federation is ever enabled both pins must widen together. This changes the inbound filter chains' bytes, so Envoy replaces and drains every mesh pod's inbound chains once on rollout (--drain-time-s, 10s here). Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr Co-authored-by: Claude Opus 5 <[email protected]>
bpalermo
added a commit
that referenced
this pull request
Sep 20, 2026
…nd put the source identity in the pool key (#842) Replaces the per-identity `transport_socket_matches` + `transport_socket_matcher` on every mesh cluster with ONE transport socket whose `custom_tls_certificate_selector` resolves the client certificate per connection, and drops `connection_pool_per_downstream_connection`. Both halves are the same mechanism — the source SPIFFE ID in a downstream-shared filter-state object — so they ship together. ## The filter state Mesh-originating chains now stamp a third object, under the name Envoy's `filter_state_override` upstream certificate mapper hardcodes (`envoy.tls.certificate_mappers.on_demand_secret`) and with the `envoy.hashable_string` factory. That factory is the whole point: `set_filter_state`'s default `envoy.string` builds a `Router::StringAccessorImpl`, which is not `Envoy::Hashable`, and `CommonUpstreamTransportSocketFactory::hashKey` folds a shared filter-state object into the upstream pool key only behind a `dynamic_cast` to `Hashable`. `aether.source.spiffe_id` keeps being stamped for one release: it is what a pre-#842 cluster's matcher reads, so a rollback stays hitless (the dual-key overlap #815 used), and it is the access log's `source_spiffe_id`. ## The cluster custom_tls_certificate_selector: envoy.tls.certificate_selectors.on_demand_secret config_source: ads (the agent's own stream) certificate_mapper: ...upstream_certificate_mappers.filter_state_override default_value: <node SVID> prefetch_secret_names: [<node SVID>] The mapper returns the filter-state string VERBATIM as the SDS secret name, which works only because aether's secret names are SPIFFE IDs. `default_value` is the node SVID — the same identity, for the same connections, that the removed matcher's `on_no_match` presented. Workload identities are deliberately NOT prefetched: listing them would put the node's identity set back into every cluster's bytes. Consequence beyond tidiness: a mesh cluster now has NO workload input at all. #815 release two made cluster bytes invariant under pod churn within a ServiceAccount; the first pod of a new ServiceAccount arriving and the last one leaving still rewrote every mesh cluster on the node, each re-warming for the full 15 s EDS initial_fetch_timeout and draining every upstream pool on the warming→active swap. Those are free now. `max_session_keys: 0` (from #834, for #829) becomes a precondition rather than just a defence: a client context supports a custom certificate selector only with session resumption off. ## What is deliberately unchanged - The `inboundready_<pod>` probe cluster keeps its own statically named certificate and its own `MaxSessionKeys: 0` (#836/#840). A health checker carries no filter state, so a selector there would take `default_value` on every probe — the same node SVID by a longer route — while breaking the #836 boundary that nothing the probe does may be observable by application traffic. - The edge keeps `EdgeUpstreamTransportSocket`: one identity, no source filter state, SDS straight from the SPIRE agent. A selector would add a handshake pause and buy nothing. - The server-identity SAN pin and the SDS-rotated trust bundle. Never per-source. - The proposal 019 waypoint split, which is about SNI, not certificates — but its matcher is now a constant over two fixed sockets (`local`, `waypoint`) instead of a two-level tree over the identity set. ## BREAKS A LIVE ALERT — cross-repo `envoy_cluster_match_count_total{aether_transport_socket_match=...}` does not exist for mesh clusters any more, because they have no transport-socket matches. `AetherClusterIdentityNoMatch` (k8s-talos-main, GitOps #109) therefore matches nothing and evaluates to a clean zero — a vacuous gate, not an error. It must be removed or repointed in the same window this ships. docs/runbook.md, "#842", proposes the replacement: the destination access log's `downstream_peer_uri_san` (already the authoritative check) plus a `-` `source_spiffe_id` on source-reporter lines, which is exactly the condition that makes the mapper fall back to `default_value`. ## Tests `//test/mtlspool` gained a real SDS server (certificate resolution now happens DURING the handshake, so file-backed certs no longer exercise it) and three distinct assertions against the pinned Envoy, plus the negative control: - 11/11 requests from each source verified as that source; - EXACTLY TWO upstream connections, one per identity — the observable that distinguishes #842 from the old flag, which would give 22; - each connection presented the originating pod's own certificate, never `default_value`; - negative control, `envoy.string` instead of `envoy.hashable_string` as the ONLY change: 11/11 of source-B's requests verified as source-A, on ONE shared connection. `//test/envoy_validate` gained a non-vacuity guard, after checking that an empty `default_value` really does make `envoy --mode validate` fail. It also established that the TypedExtensionConfig `name` is informational — a corrupted one validates fine — so the names are pinned in a unit test instead. 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
…nd put the source identity in the pool key (#842) Replaces the per-identity `transport_socket_matches` + `transport_socket_matcher` on every mesh cluster with ONE transport socket whose `custom_tls_certificate_selector` resolves the client certificate per connection, and drops `connection_pool_per_downstream_connection`. Both halves are the same mechanism — the source SPIFFE ID in a downstream-shared filter-state object — so they ship together. ## The filter state Mesh-originating chains now stamp a third object, under the name Envoy's `filter_state_override` upstream certificate mapper hardcodes (`envoy.tls.certificate_mappers.on_demand_secret`) and with the `envoy.hashable_string` factory. That factory is the whole point: `set_filter_state`'s default `envoy.string` builds a `Router::StringAccessorImpl`, which is not `Envoy::Hashable`, and `CommonUpstreamTransportSocketFactory::hashKey` folds a shared filter-state object into the upstream pool key only behind a `dynamic_cast` to `Hashable`. `aether.source.spiffe_id` keeps being stamped for one release: it is what a pre-#842 cluster's matcher reads, so a rollback stays hitless (the dual-key overlap #815 used), and it is the access log's `source_spiffe_id`. ## The cluster custom_tls_certificate_selector: envoy.tls.certificate_selectors.on_demand_secret config_source: ads (the agent's own stream) certificate_mapper: ...upstream_certificate_mappers.filter_state_override default_value: <node SVID> prefetch_secret_names: [<node SVID>] The mapper returns the filter-state string VERBATIM as the SDS secret name, which works only because aether's secret names are SPIFFE IDs. `default_value` is the node SVID — the same identity, for the same connections, that the removed matcher's `on_no_match` presented. Workload identities are deliberately NOT prefetched: listing them would put the node's identity set back into every cluster's bytes. Consequence beyond tidiness: a mesh cluster now has NO workload input at all. #815 release two made cluster bytes invariant under pod churn within a ServiceAccount; the first pod of a new ServiceAccount arriving and the last one leaving still rewrote every mesh cluster on the node, each re-warming for the full 15 s EDS initial_fetch_timeout and draining every upstream pool on the warming→active swap. Those are free now. `max_session_keys: 0` (from #834, for #829) becomes a precondition rather than just a defence: a client context supports a custom certificate selector only with session resumption off. ## What is deliberately unchanged - The `inboundready_<pod>` probe cluster keeps its own statically named certificate and its own `MaxSessionKeys: 0` (#836/#840). A health checker carries no filter state, so a selector there would take `default_value` on every probe — the same node SVID by a longer route — while breaking the #836 boundary that nothing the probe does may be observable by application traffic. - The edge keeps `EdgeUpstreamTransportSocket`: one identity, no source filter state, SDS straight from the SPIRE agent. A selector would add a handshake pause and buy nothing. - The server-identity SAN pin and the SDS-rotated trust bundle. Never per-source. - The proposal 019 waypoint split, which is about SNI, not certificates — but its matcher is now a constant over two fixed sockets (`local`, `waypoint`) instead of a two-level tree over the identity set. ## BREAKS A LIVE ALERT — cross-repo `envoy_cluster_match_count_total{aether_transport_socket_match=...}` does not exist for mesh clusters any more, because they have no transport-socket matches. `AetherClusterIdentityNoMatch` (k8s-talos-main, GitOps #109) therefore matches nothing and evaluates to a clean zero — a vacuous gate, not an error. It must be removed or repointed in the same window this ships. docs/runbook.md, "#842", proposes the replacement: the destination access log's `downstream_peer_uri_san` (already the authoritative check) plus a `-` `source_spiffe_id` on source-reporter lines, which is exactly the condition that makes the mapper fall back to `default_value`. ## Tests `//test/mtlspool` gained a real SDS server (certificate resolution now happens DURING the handshake, so file-backed certs no longer exercise it) and three distinct assertions against the pinned Envoy, plus the negative control: - 11/11 requests from each source verified as that source; - EXACTLY TWO upstream connections, one per identity — the observable that distinguishes #842 from the old flag, which would give 22; - each connection presented the originating pod's own certificate, never `default_value`; - negative control, `envoy.string` instead of `envoy.hashable_string` as the ONLY change: 11/11 of source-B's requests verified as source-A, on ONE shared connection. `//test/envoy_validate` gained a non-vacuity guard, after checking that an empty `default_value` really does make `envoy --mode validate` fail. It also established that the TypedExtensionConfig `name` is informational — a corrupted one validates fine — so the names are pinned in a unit test instead. 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
…nd put the source identity in the pool key (#842) Replaces the per-identity `transport_socket_matches` + `transport_socket_matcher` on every mesh cluster with ONE transport socket whose `custom_tls_certificate_selector` resolves the client certificate per connection, and drops `connection_pool_per_downstream_connection`. Both halves are the same mechanism — the source SPIFFE ID in a downstream-shared filter-state object — so they ship together. ## The filter state Mesh-originating chains now stamp a third object, under the name Envoy's `filter_state_override` upstream certificate mapper hardcodes (`envoy.tls.certificate_mappers.on_demand_secret`) and with the `envoy.hashable_string` factory. That factory is the whole point: `set_filter_state`'s default `envoy.string` builds a `Router::StringAccessorImpl`, which is not `Envoy::Hashable`, and `CommonUpstreamTransportSocketFactory::hashKey` folds a shared filter-state object into the upstream pool key only behind a `dynamic_cast` to `Hashable`. `aether.source.spiffe_id` keeps being stamped for one release: it is what a pre-#842 cluster's matcher reads, so a rollback stays hitless (the dual-key overlap #815 used), and it is the access log's `source_spiffe_id`. ## The cluster custom_tls_certificate_selector: envoy.tls.certificate_selectors.on_demand_secret config_source: ads (the agent's own stream) certificate_mapper: ...upstream_certificate_mappers.filter_state_override default_value: <node SVID> prefetch_secret_names: [<node SVID>] The mapper returns the filter-state string VERBATIM as the SDS secret name, which works only because aether's secret names are SPIFFE IDs. `default_value` is the node SVID — the same identity, for the same connections, that the removed matcher's `on_no_match` presented. Workload identities are deliberately NOT prefetched: listing them would put the node's identity set back into every cluster's bytes. Consequence beyond tidiness: a mesh cluster now has NO workload input at all. #815 release two made cluster bytes invariant under pod churn within a ServiceAccount; the first pod of a new ServiceAccount arriving and the last one leaving still rewrote every mesh cluster on the node, each re-warming for the full 15 s EDS initial_fetch_timeout and draining every upstream pool on the warming→active swap. Those are free now. `max_session_keys: 0` (from #834, for #829) becomes a precondition rather than just a defence: a client context supports a custom certificate selector only with session resumption off. ## What is deliberately unchanged - The `inboundready_<pod>` probe cluster keeps its own statically named certificate and its own `MaxSessionKeys: 0` (#836/#840). A health checker carries no filter state, so a selector there would take `default_value` on every probe — the same node SVID by a longer route — while breaking the #836 boundary that nothing the probe does may be observable by application traffic. - The edge keeps `EdgeUpstreamTransportSocket`: one identity, no source filter state, SDS straight from the SPIRE agent. A selector would add a handshake pause and buy nothing. - The server-identity SAN pin and the SDS-rotated trust bundle. Never per-source. - The proposal 019 waypoint split, which is about SNI, not certificates — but its matcher is now a constant over two fixed sockets (`local`, `waypoint`) instead of a two-level tree over the identity set. ## BREAKS A LIVE ALERT — cross-repo `envoy_cluster_match_count_total{aether_transport_socket_match=...}` does not exist for mesh clusters any more, because they have no transport-socket matches. `AetherClusterIdentityNoMatch` (k8s-talos-main, GitOps #109) therefore matches nothing and evaluates to a clean zero — a vacuous gate, not an error. It must be removed or repointed in the same window this ships. docs/runbook.md, "#842", proposes the replacement: the destination access log's `downstream_peer_uri_san` (already the authoritative check) plus a `-` `source_spiffe_id` on source-reporter lines, which is exactly the condition that makes the mapper fall back to `default_value`. ## Tests `//test/mtlspool` gained a real SDS server (certificate resolution now happens DURING the handshake, so file-backed certs no longer exercise it) and three distinct assertions against the pinned Envoy, plus the negative control: - 11/11 requests from each source verified as that source; - EXACTLY TWO upstream connections, one per identity — the observable that distinguishes #842 from the old flag, which would give 22; - each connection presented the originating pod's own certificate, never `default_value`; - negative control, `envoy.string` instead of `envoy.hashable_string` as the ONLY change: 11/11 of source-B's requests verified as source-A, on ONE shared connection. `//test/envoy_validate` gained a non-vacuity guard, after checking that an empty `default_value` really does make `envoy --mode validate` fail. It also established that the TypedExtensionConfig `name` is informational — a corrupted one validates fine — so the names are pinned in a unit test instead. 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
…nd put the source identity in the pool key (#842) Replaces the per-identity `transport_socket_matches` + `transport_socket_matcher` on every mesh cluster with ONE transport socket whose `custom_tls_certificate_selector` resolves the client certificate per connection, and drops `connection_pool_per_downstream_connection`. Both halves are the same mechanism — the source SPIFFE ID in a downstream-shared filter-state object — so they ship together. ## The filter state Mesh-originating chains now stamp a third object, under the name Envoy's `filter_state_override` upstream certificate mapper hardcodes (`envoy.tls.certificate_mappers.on_demand_secret`) and with the `envoy.hashable_string` factory. That factory is the whole point: `set_filter_state`'s default `envoy.string` builds a `Router::StringAccessorImpl`, which is not `Envoy::Hashable`, and `CommonUpstreamTransportSocketFactory::hashKey` folds a shared filter-state object into the upstream pool key only behind a `dynamic_cast` to `Hashable`. `aether.source.spiffe_id` keeps being stamped for one release: it is what a pre-#842 cluster's matcher reads, so a rollback stays hitless (the dual-key overlap #815 used), and it is the access log's `source_spiffe_id`. ## The cluster custom_tls_certificate_selector: envoy.tls.certificate_selectors.on_demand_secret config_source: ads (the agent's own stream) certificate_mapper: ...upstream_certificate_mappers.filter_state_override default_value: <node SVID> prefetch_secret_names: [<node SVID>] The mapper returns the filter-state string VERBATIM as the SDS secret name, which works only because aether's secret names are SPIFFE IDs. `default_value` is the node SVID — the same identity, for the same connections, that the removed matcher's `on_no_match` presented. Workload identities are deliberately NOT prefetched: listing them would put the node's identity set back into every cluster's bytes. Consequence beyond tidiness: a mesh cluster now has NO workload input at all. #815 release two made cluster bytes invariant under pod churn within a ServiceAccount; the first pod of a new ServiceAccount arriving and the last one leaving still rewrote every mesh cluster on the node, each re-warming for the full 15 s EDS initial_fetch_timeout and draining every upstream pool on the warming→active swap. Those are free now. `max_session_keys: 0` (from #834, for #829) becomes a precondition rather than just a defence: a client context supports a custom certificate selector only with session resumption off. ## What is deliberately unchanged - The `inboundready_<pod>` probe cluster keeps its own statically named certificate and its own `MaxSessionKeys: 0` (#836/#840). A health checker carries no filter state, so a selector there would take `default_value` on every probe — the same node SVID by a longer route — while breaking the #836 boundary that nothing the probe does may be observable by application traffic. - The edge keeps `EdgeUpstreamTransportSocket`: one identity, no source filter state, SDS straight from the SPIRE agent. A selector would add a handshake pause and buy nothing. - The server-identity SAN pin and the SDS-rotated trust bundle. Never per-source. - The proposal 019 waypoint split, which is about SNI, not certificates — but its matcher is now a constant over two fixed sockets (`local`, `waypoint`) instead of a two-level tree over the identity set. ## BREAKS A LIVE ALERT — cross-repo `envoy_cluster_match_count_total{aether_transport_socket_match=...}` does not exist for mesh clusters any more, because they have no transport-socket matches. `AetherClusterIdentityNoMatch` (k8s-talos-main, GitOps #109) therefore matches nothing and evaluates to a clean zero — a vacuous gate, not an error. It must be removed or repointed in the same window this ships. docs/runbook.md, "#842", proposes the replacement: the destination access log's `downstream_peer_uri_san` (already the authoritative check) plus a `-` `source_spiffe_id` on source-reporter lines, which is exactly the condition that makes the mapper fall back to `default_value`. ## Tests `//test/mtlspool` gained a real SDS server (certificate resolution now happens DURING the handshake, so file-backed certs no longer exercise it) and three distinct assertions against the pinned Envoy, plus the negative control: - 11/11 requests from each source verified as that source; - EXACTLY TWO upstream connections, one per identity — the observable that distinguishes #842 from the old flag, which would give 22; - each connection presented the originating pod's own certificate, never `default_value`; - negative control, `envoy.string` instead of `envoy.hashable_string` as the ONLY change: 11/11 of source-B's requests verified as source-A, on ONE shared connection. `//test/envoy_validate` gained a non-vacuity guard, after checking that an empty `default_value` really does make `envoy --mode validate` fail. It also established that the TypedExtensionConfig `name` is informational — a corrupted one validates fine — so the names are pinned in a unit test instead. 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
…nd put the source identity in the pool key (#842) (#863) Replaces the per-identity `transport_socket_matches` + `transport_socket_matcher` on every mesh cluster with ONE transport socket whose `custom_tls_certificate_selector` resolves the client certificate per connection, and drops `connection_pool_per_downstream_connection`. Both halves are the same mechanism — the source SPIFFE ID in a downstream-shared filter-state object — so they ship together. ## The filter state Mesh-originating chains now stamp a third object, under the name Envoy's `filter_state_override` upstream certificate mapper hardcodes (`envoy.tls.certificate_mappers.on_demand_secret`) and with the `envoy.hashable_string` factory. That factory is the whole point: `set_filter_state`'s default `envoy.string` builds a `Router::StringAccessorImpl`, which is not `Envoy::Hashable`, and `CommonUpstreamTransportSocketFactory::hashKey` folds a shared filter-state object into the upstream pool key only behind a `dynamic_cast` to `Hashable`. `aether.source.spiffe_id` keeps being stamped for one release: it is what a pre-#842 cluster's matcher reads, so a rollback stays hitless (the dual-key overlap #815 used), and it is the access log's `source_spiffe_id`. ## The cluster custom_tls_certificate_selector: envoy.tls.certificate_selectors.on_demand_secret config_source: ads (the agent's own stream) certificate_mapper: ...upstream_certificate_mappers.filter_state_override default_value: <node SVID> prefetch_secret_names: [<node SVID>] The mapper returns the filter-state string VERBATIM as the SDS secret name, which works only because aether's secret names are SPIFFE IDs. `default_value` is the node SVID — the same identity, for the same connections, that the removed matcher's `on_no_match` presented. Workload identities are deliberately NOT prefetched: listing them would put the node's identity set back into every cluster's bytes. Consequence beyond tidiness: a mesh cluster now has NO workload input at all. #815 release two made cluster bytes invariant under pod churn within a ServiceAccount; the first pod of a new ServiceAccount arriving and the last one leaving still rewrote every mesh cluster on the node, each re-warming for the full 15 s EDS initial_fetch_timeout and draining every upstream pool on the warming→active swap. Those are free now. `max_session_keys: 0` (from #834, for #829) becomes a precondition rather than just a defence: a client context supports a custom certificate selector only with session resumption off. ## What is deliberately unchanged - The `inboundready_<pod>` probe cluster keeps its own statically named certificate and its own `MaxSessionKeys: 0` (#836/#840). A health checker carries no filter state, so a selector there would take `default_value` on every probe — the same node SVID by a longer route — while breaking the #836 boundary that nothing the probe does may be observable by application traffic. - The edge keeps `EdgeUpstreamTransportSocket`: one identity, no source filter state, SDS straight from the SPIRE agent. A selector would add a handshake pause and buy nothing. - The server-identity SAN pin and the SDS-rotated trust bundle. Never per-source. - The proposal 019 waypoint split, which is about SNI, not certificates — but its matcher is now a constant over two fixed sockets (`local`, `waypoint`) instead of a two-level tree over the identity set. ## BREAKS A LIVE ALERT — cross-repo `envoy_cluster_match_count_total{aether_transport_socket_match=...}` does not exist for mesh clusters any more, because they have no transport-socket matches. `AetherClusterIdentityNoMatch` (k8s-talos-main, GitOps #109) therefore matches nothing and evaluates to a clean zero — a vacuous gate, not an error. It must be removed or repointed in the same window this ships. docs/runbook.md, "#842", proposes the replacement: the destination access log's `downstream_peer_uri_san` (already the authoritative check) plus a `-` `source_spiffe_id` on source-reporter lines, which is exactly the condition that makes the mapper fall back to `default_value`. ## Tests `//test/mtlspool` gained a real SDS server (certificate resolution now happens DURING the handshake, so file-backed certs no longer exercise it) and three distinct assertions against the pinned Envoy, plus the negative control: - 11/11 requests from each source verified as that source; - EXACTLY TWO upstream connections, one per identity — the observable that distinguishes #842 from the old flag, which would give 22; - each connection presented the originating pod's own certificate, never `default_value`; - negative control, `envoy.string` instead of `envoy.hashable_string` as the ONLY change: 11/11 of source-B's requests verified as source-A, on ONE shared connection. `//test/envoy_validate` gained a non-vacuity guard, after checking that an empty `default_value` really does make `envoy --mode validate` fail. It also established that the TypedExtensionConfig `name` is informational — a corrupted one validates fine — so the names are pinned in a unit test instead. 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.
Fixes #836. Fixes #832.
Both were found while investigating #829, both live in the upstream-TLS /
server-identity-pinning path, and both touch the same two files
(
agent/internal/xds/proxy/transportsocket.go,agent/internal/xds/cache/mtls.go)plus the same test harness — so they ship together rather than as two PRs that
would conflict with each other.
#836 — the readiness probe gets its own TLS context
inboundready_<pod>built its transport socket withUpstreamTransportSocket,the same helper every mesh cluster uses. That probe dials each local pod's mesh
inbound inside that pod's netns every 5 s, so its TLS peer is always a pod
on this node presenting that pod's SVID — the one certificate that must never
turn up in an unrelated cluster's handshake. In #829 it did: mesh clusters
resumed from a session the probe had created and were handed a local pod's
certificate, which is exactly why the leaked identity was always a source-node
neighbour.
The probe now builds its own
UpstreamTlsContext(
proxy.InboundReadyProbeTransportSocket) carrying its ownmax_session_keys: 0.Why #834 does not make this redundant. #834 set
max_session_keys: 0on theshared mesh builder, which removes the slot everywhere — correct, and it should
stay. But it is a global switch, and it is one someone may legitimately
reverse: upstream envoy#45982 scopes the upstream session cache by SNI, and once
that is in force for our config, resumption for mesh traffic becomes defensible
again. The moment that happens, the probe would silently be back inside the same
cache as application traffic. What this change adds is the boundary: the
probe's TLS state is not reachable by application traffic regardless of what the
mesh path does. The two changes have different lifetimes.
The SAN pin (
[]string{podSpiffeID}) and the empty SNI are unchanged — both areload-bearing and the reasons are restated at the new function.
#832 — an unpinned cluster is no longer silent
When the SAN pin cannot be rendered, the upstream validation context goes out
with no
match_typed_subject_alt_names, so the handshake proves onlytrust-domain membership: any mesh workload satisfies it. Emitting that rather
than
spiffe:///ns/…(unservable, four permanently-demoted endpoints on rev222,#815/#819) is the right call. Shipping it silently is not — it is the fail-open
direction, and the pin is what made #829 loud in the first place.
Each snapshot now:
count,trust_domainand areason, andaether.agent.identity.cluster_unpinned, seeded at zero atregistration — a counter that is never incremented is not a series, and "no
series" and "zero" are indistinguishable to a grading query. This repo has
been bitten by that repeatedly (talos-main rev200: neither Transient cross-service mTLS identity mis-binding during concurrent proxy-restart + service roll (failed closed) #638 series
existed).
The check reads
clusterEntry.sanURIs, the single cached render of the pin thatevery emission path consumes (the HTTP/edge mTLS cluster, and the TCP floor's
tcp:<svc>cluster), so it covers all of them without re-walking emitted protoson the snapshot hot path.
It reports two reasons, because the pin has two ways to come out empty:
trust domain not yet known— the A cluster published with an empty trust domain has no SAN pin at all, silently #832 window, meant to be one snapshot wideand until now unobserved.
service endpoints carry no namespace metadata— not a window at all; itlasts as long as the registry serves those endpoints.
One thing worth flagging for review: today an empty trust domain also makes
refreshEntryMTLSLockedreturn before injecting mTLS at all (andcaptureTCPClustersskips on the empty validation-context name), so in thatwindow the cluster goes out with no transport socket, not with an unpinned
one. The literal unpinned-
UpstreamTlsContextwire shape is reached via thesecond reason. Keying the report on the cached pin covers both without
depending on which guard fires first.
Runbook: new "The unpinned-cluster signal (#832)" subsection next to the two
#638 discriminators, with the PromQL and what each reason means.
Config-shape gate
//test/envoy_validatenow asserts that every upstream TLS context in eachgenerated bootstrap carries a non-empty
match_typed_subject_alt_names, overthe exact bytes handed to
envoy --mode validate. Nothing is allow-listed byname: a cluster is checked precisely when it has an
UpstreamTlsContext, so thepassthrough / app / health / xds / spire_agent / waypoint-ingress clusters (no
TLS) are out of scope automatically and a new mesh cluster is in scope the
moment it grows one. Both carriers are covered — the plain
transport_socketand each
transport_socket_matchesentry (the per-source mTLS shape, where thepin must be on every match including the node-identity
on_no_matchone).Test evidence
Non-vacuity, proved by mutation (each break applied, observed, reverted):
newServiceCluster→sanURIs = nil:node_bootstrap.json / node_cleartext / node_uds / capture / capture_route_target: upstream TLS contexts with no match_typed_subject_alt_names: [echo.mesh.local …]newPerSourceServiceCluster→InjectUpstreamMTLS(..., nil, ...):per-source-echo.mesh.local/spiffe://aether.internal/node/test-node+both source-identity matches — the matches branch is live too.
In both mutations
envoy --mode validatestill exited 0 on everybootstrap. That is the point of the gate: Envoy accepts an unpinned context,
so a passing validate says nothing about it.
reportUnpinnedClusterscall removed fromgenerateSnapshot:TestEmptyTrustDomainReportsUnpinnedClustersandTestUnpinnedClusterReportNamesTheOtherCauseboth fail("should have 1 item(s), but has 0").
MaxSessionKeysdropped fromInboundReadyProbeTransportSocket:TestInboundReadyProbeHasItsOwnTLSSessionStatefails on the"must be SET, not left to Envoy's default of 1" assertion.
New/extended tests:
TestEmptyTrustDomainReportsUnpinnedClusters(WARN text,level, named cluster, count, reason, counter, the seeded zero being a real
series, per-snapshot re-reporting, and recovery when the trust domain returns),
TestUnpinnedClusterReportNamesTheOtherCause,TestInboundReadyProbeHasItsOwnTLSSessionState, and the counter added toTestCacheMetrics_IdentityCountersSeededAtZero.Pre-existing failures, unrelated and confirmed on the base commit
c8f3d91://agent/internal/proxy/hotrestart:hotrestart_test(
TestAdminWatchdogFiresWhenAdminHangsAfterLive,TestWriteReadStateRoundTrip)fails identically without this change.
TestObservedUpstreamsStore_ShrinkRemovesTheEntry(30 ms TTL) flakes under
--config=raceon a loaded machine and passesrepeatedly on an idle one, on this branch.
No cluster was touched: this is code only.
Co-Authored-By: Claude Opus 5 [email protected]
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr