Repository navigation
fix(capture): stop use_original_dst handing diverted connections to whichever pod bound 0.0.0.0:18008 last (#1007) - #1030
Merged
Conversation
…hichever pod bound 0.0.0.0:18008 last (#1007) The capture listener set use_original_dst: true. In Envoy that field adds two things: a second copy of the original_dst listener filter (listener_impl.cc buildOriginalDstListenerFilter), and the restored-destination HANDOFF (active_tcp_socket.cc): a connection whose restored local address matches another listener is handed to "the listener bound to that address", found by the address string alone (connection_handler_impl.cc, no netns). Every pod's inbound listener binds 0.0.0.0:18008 in its own netns, so a diverted connection to <endpoint>:18008 ran through the most recently added pod's inbound chains, which presented that pod's SVID and failed the client's SAN check. Nothing in mesh capture needs the handoff: every decision is a filter-chain match on the restored destination, or the ORIGINAL_DST passthrough, and original_dst_cluster.cc only needs localAddressRestored(), which the explicit original_dst LISTENER FILTER (kept, first in the list) sets. The field goes to false; the comments that claimed it was needed are corrected. Tests: capture_test and the //test/envoy_validate capture fixture assert the field is false (the fixture still validates against the pinned proxy); both went red with the field flipped back to true. Must merge only after #1022's talos proof: with this alone, a socket leaked into a pod netns would succeed silently and hide that defect. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo
marked this pull request as ready for review
September 28, 2026 02:46
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.
What was wrong
The capture listener set
use_original_dst: true. In Envoy, that listener field adds two things:original_dstlistener filter (listener_impl.ccbuildOriginalDstListenerFilter). aether already configures that filter explicitly, first in the list.active_tcp_socket.cc:240-267). When a connection's restored local address matches another listener, Envoy hands the connection to "the listener bound to that address" viagetBalancedHandlerByAddress. The lookup is keyed by the address string alone (connection_handler_impl.cc:122, wildcard fallback:425-433), and the string carries no netns.Every pod's inbound listener binds
0.0.0.0:18008inside its own netns, so each new pod overwrites the previous entry. Any connection a capture listener accepted with original destination*:18008therefore ran through the inbound filter chains of whichever pod was added last. That listener presented its own SVID and failed the client's SAN check. This is the "always the newest pod on the node" landing from #1007.The change
UseOriginalDst: falseon the capture listener (agent/internal/xds/proxy/capture.go).original_dstlistener filter stays, first in the list. It is the thing that setslocalAddressRestored(). It is also all the ORIGINAL_DST passthrough needs:original_dst_cluster.cc:51reads the downstream local address onlyif (connection->connectionInfoProvider().localAddressRestored()). Every capture filter chain matches on that restored destination too.localAddressRestored(). The comment onbuildCaptureTCPPortFilterChain, the listener-filter comment and thecaptureport_testdoc all said "already sets use_original_dst". All of them now point at the filter.Tests
capture_test.go(TestGenerateCaptureListener): asserts the field is set explicitly and isfalse, and still asserts thatoriginal_dstis the first listener filter.//test/envoy_validatecapture fixture (TestCaptureTCPListenerIsTransparentAndKeepsOriginalDst): the fixture still passesenvoy --mode validateagainst the chart-pinned aether-proxy with the field off. It asserts the field isfalsenext totransparentand next tooriginal_dstbeing first.true, both fail:false,//agent/internal/xds/proxy:proxy_testand//test/envoy_validate:envoy_validate_testpass. Lint (--config=lint --@aspect_rules_lint//lint:fail_on_violation) and//:formatare clean.e2e (kind)
I ran
L4_SKIP_BUILD=1 ./e2e/l4routes.sh(up + verify) on kind, with images built from this branch. It exits 0 with every assertion passing:The live
config_dumpfrom the kind cluster's proxy shows everycapture_<pod>listener withuse_original_dst: falseandenvoy.filters.listener.original_dstas the first filter, so the green run really exercised the new config. The cluster was torn down afterwards.Rollout note
This changes the definition of every per-pod capture listener, so the rollout is a full listener replace plus drain per pod. No
charts/change is needed.Closes #1007
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr