Repository navigation
fix(proxy): use transport_socket_filter_state extension in upstream matcher - #301
Merged
Merged
Conversation
…atcher
The cluster transport_socket_matcher was wired with the wrong Envoy
extension name: "envoy.matching.inputs.filter_state" (the generic
network/HTTP FilterStateInput) instead of
"envoy.matching.inputs.transport_socket_filter_state" (the
transport-socket-scoped FilterStateInput).
These are two distinct registered extensions backed by different proto
types and different MatchingData contexts:
- envoy.matching.inputs.filter_state reads from StreamInfo::filterState()
on the connection. It is registered for NetworkMatchingData /
HttpMatchingData contexts (filter chain selection, route matching).
- envoy.matching.inputs.transport_socket_filter_state reads from
TransportSocketOptions::downstreamSharedFilterStateObjects() — the
filter state objects propagated from the downstream connection via
SharedWithUpstream. It is registered for TransportSocketMatchingData,
which is what a cluster transport_socket_matcher evaluates against.
Using the generic name in a transport_socket_matcher causes Envoy to
resolve the factory for the wrong MatchingData type. The input returns
nullopt (no value found), the exact-match map never fires, and evaluation
falls to OnNoMatch for every upstream connection. Per-source certificate
selection is silently broken: all egress presents the node identity
regardless of the originating pod.
For HTTP (HCM) upstream clusters, OnNoMatch uses the node identity socket
which does connect — so traffic flows, but the certificate is always the
node cert rather than the pod's. For TCP floor clusters (tcp_proxy
upstream), the node identity cert's SAN does not match the service's
expected SPIFFE IDs (different namespace), so the TLS handshake fails at
the destination. Because the connection resets during or immediately after
TLS, the stat counter (cluster.<svc>.upstream_cx_total) stays at 0.
Fix: change filterStateInputName to the correct transport-socket extension
name. The proto TypedConfig already uses the correct type
(envoy/extensions/matching/common_inputs/transport_socket/v3/FilterStateInput)
— only the Name field in the TypedExtensionConfig needed correction. The
tcp_proxy filter propagates SharedWithUpstream filter state through
TransportSocketOptions via the identical path as HCM (confirmed in Envoy
source: tcp_proxy.cc Filter::establishUpstreamConnection() calls
TransportSocketOptionsUtility::fromFilterState, which collects
objectsSharedWithUpstreamConnection(); the transport socket matcher
then reconstructs the filter state from those options and evaluates).
Add regression tests at the extension-name level in both the proxy unit
tests and the cache integration tests, with comments explaining the
distinction and the failure mode.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S
This was referenced Jun 24, 2026
Closed
bpalermo
added a commit
that referenced
this pull request
Jun 24, 2026
…sport path (#304) The bespoke "aether-tcp" ALPN forced a duplicated TCP-specific transport-socket stack (UpstreamTCPTransportSocket, the :tcp matches/OnNoMatch) parallel to the proven HTTP one — and all three earlier floor fixes (#298/#299/#301) lived in that copy, yet the upstream mTLS still never connected (upstream_cx_total=0). Collapse the demux onto the standard h2 ALPN instead: - Egress: UpstreamTCPTransportSocket now advertises NO ALPN (HTTP keeps "h2"); it otherwise reuses the same per-source matcher/matches machinery that already works. - Inbound :15008: the no-SNI HCM chain matches application_protocols:["h2"]; per-port HCM chains keep their port SNI; the TCP floor becomes the listener's DEFAULT chain (no match). Envoy precedence (server_names > application_protocols > default) routes h2+SNI → per-port, h2 → default-HCM, no-ALPN mTLS → the floor — no bespoke token. - Removed the AetherTCPALPN constant. This deletes the duplicated TCP transport stack that harbored the per-source-cert selection bug, so the floor rides the validated HTTP per-source mTLS path. Validate on talos: echo-tcp.aether.internal:18081 (HTTP over the mTLS TCP floor) -> 200. Claude-Session: https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S Co-authored-by: Claude Opus 4.8 <[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.
Root cause
The cluster
transport_socket_matcherwas wired with the wrong Envoy extension name.Wrong:
"envoy.matching.inputs.filter_state"— the generic network/HTTPFilterStateInput(envoy/extensions/matching/common_inputs/network/v3)Correct:
"envoy.matching.inputs.transport_socket_filter_state"— the transport-socket-scopedFilterStateInput(envoy/extensions/matching/common_inputs/transport_socket/v3)These are two distinct registered extensions with different
MatchingDatacontexts:filter_statereads fromStreamInfo::filterState()directly. It is registered forNetworkMatchingData/HttpMatchingData(filter chain selection, route matching).transport_socket_filter_statereads fromTransportSocketOptions::downstreamSharedFilterStateObjects()— the filter state objects propagated from the downstream connection viaSharedWithUpstream: ONCE. It is registered forTransportSocketMatchingData, which is what a clustertransport_socket_matcherevaluates against.Using the generic name in a
transport_socket_matchercauses Envoy to resolve the input factory against the wrongMatchingDatatype. The input returnsnulloptsilently, the exact-match map never fires, and evaluation falls toOnNoMatchfor every upstream connection. Per-source certificate selection was silently broken on every cluster in the mesh.Blast radius
HTTP (HCM) clusters:
OnNoMatchselects the node identity socket, which does connect. Traffic flows, but every pod's egress presents the node cert (not the pod's SVID). The SAN of the node identity is within the trust domain, so SAN pinning is loose enough that connections succeed — but the per-source identity claim is wrong.TCP floor clusters (tcp_proxy):
OnNoMatchalso selects the node identity socket. The node identity (spiffe://aether.internal/ns/aether-system/sa/aether-agent) does not match the service's expected SPIFFE IDs (which are scoped to the service's own namespace, e.g.,aether-test). The TLS handshake fails at the destination SAN check. Because the connection resets immediately after TLS,cluster.<svc>.upstream_cx_totalstays at 0 — the symptom reported.Why tcp_proxy and HCM behave differently for the TCP floor
Confirmed in Envoy source (
tcp_proxy.ccFilter::establishUpstreamConnection):tcp_proxypropagatesSharedWithUpstream: ONCEfilter state throughTransportSocketOptionsvia the identical code path as HCM (TransportSocketOptionsUtility::fromFilterState→objectsSharedWithUpstreamConnection()). The two-fix assumption (previous PRs #298/#299) that the extension name or match names were wrong was correct for those bugs, but the root cause ofupstream_cx_total = 0was this extension name mismatch — also present on the HCM path but masked by the loose SAN check.Fix
One-line change:
filterStateInputName = "envoy.matching.inputs.transport_socket_filter_state".The
TypedConfigproto was already using the correct type (transport_socket.v3.FilterStateInput) — only theNamefield in theTypedExtensionConfigneeded correction.Tests
TestUpstreamTransportSocketMatcherExtensionName: explicit regression test asserting the extension name is the transport-socket variant and is not the generic one.TestUpstreamTransportSocketMatcher: updated comment + assertion message to document the distinction.TestServiceClusterMTLSInjected: asserts the HTTP cluster's matcher also uses the correct extension name.TestLoadClustersFromRegistry_TCPCluster: asserts the TCP floor cluster's matcher uses the correct extension name and provides a causal explanation in the failure message.Confidence
High. The extension name mismatch is the only code-level difference between what the code emits and what Envoy expects for
TransportSocketMatchingData. Thetcp_proxypropagation path is verified in source. After this fix, per-source SVID selection will work for both HCM and tcp_proxy upstreams for the first time.🤖 Generated with Claude Code
https://claude.ai/code/session_01N7oY7W8oDXrqDzFgoZh25S