Skip to content

soak: ssl_fail_verify_san ticks on the L4 TLS clusters (tcp-echo, mixed-svc) outside any roll, on every build since at least 2026-09-23 #1007

Closed

Description

@bpalermo

Finding

envoy_cluster_ssl_fail_verify_san_total ticks on the L4 TLS clusters of the soak's tcp-echo and mixed-svc services, including inside windows with no roll of any kind. It is present on every recent build and predates QUIC and TPROXY:

window tcp-echo mixed-svc
2026-09-23 (3 days before rev239) 136 44
rev239 8 h soak (2026-09-26, no QUIC) 13 8
rev242 8 h soak (2026-09-27, QUIC on svc-1/2) ticks, incl. the 12:30–14:00Z no-roll window ticks

The HTTP services (svc-1..5) do not tick outside proxy rolls, so this is not the #829 session-resumption class (fixed in #834, verified zero on rev227) and not #638's roll-adjacent burst. The runbook's "Attributing an ssl_fail_verify_san event" section covers only those two shapes.

What is different about these two services

Both carry a TLSRoute / TCP-floor leg (proposal 037 multiprotocol): the client dials a TLS port, the capture listener SNI-routes it, and the upstream cluster is the mesh mTLS cluster for that service. The SAN check that fails is the client-side check on the outbound mTLS hop, so either (a) the destination's inbound chain for the L4 port presents a different SVID than the URI SAN the source pins, or (b) the source pins the wrong SAN for L4 clusters (the pin is derived from the Service's ServiceAccount; mixed-svc carries two ports on one SA, tcp-echo predates 037 — see e2e/soak/README.md on its doubled tcp_ chain name).

Ask

  • Attribute: match one tick to the destination pod via the runbook's XFCC / access-log join and read the presented vs expected SAN.
  • If the L4 SAN pin is wrong, fix it in the L4 cluster builder; if a TLS-passthrough client's own handshake is being mis-counted on the mTLS cluster stat, document it as a non-error.
  • Either way, add the L4 clusters to the soak's verify_san gate (today the gate is read on the HTTP clusters and this class is graded "pre-existing" by hand).

Low severity: the affected requests are the soak's own L4 echo probes, and the counts are tens per 8 h. Related: #829, #638, #911 (037 TLSRoute shadowing).

Activity

  1. added
    bug
    on Sep 27, 2026
  2. bpalermo commented on Sep 27, 2026

    @bpalermo
    OwnerAuthor

    Attribution: none of the three candidates. The L4 connection is handed off to the wrong pod's inbound listener

    Summary. The pin is correct. There is no client-side TLS on these legs. The probe is not involved. What happens is this: a node proxy's outbound L4 connection to tcp-echo or mixed-svc occasionally ends up on the inbound :18008 listener of an unrelated local pod. That pod is always the most recently added mesh pod on the node. It presents its own SVID, and the client-side SAN check correctly rejects it. Two defects combine to produce this. One is in Envoy and one is in aether's capture-listener config. Details below.

    1. Which clusters tick, and how often

    increase(envoy_cluster_ssl_fail_verify_san_total[8h]) > 0

    window series (node / aether_cluster)
    2026-09-27 09:55–17:55Z w02 tcp-echo 3, w03 tcp-echo 2, w04 tcp-echo 4, w05 tcp-echo 9, w04 mixed-svc 3, w05 mixed-svc 2
    2026-09-26 13:16–21:16Z w03 tcp-echo 2, w04 tcp-echo 10, w05 tcp-echo 4, w03 mixed-svc 1, w04 mixed-svc 3, w05 mixed-svc 1
    • The exact cluster name cannot be read from the stats. Every L4 cluster uses the service key as its alt_stat_name: the tcp: floor, the primary-port alias and the per-port clusters (agent/internal/xds/cache/capture.go:413,1429,1440 pass e.serviceName). So tcp:tcp-echo…, tcp:tcp-echo…:9000 and the rest all report as aether_cluster="aether-test/tcp-echo". For mixed-svc, the tcp:…:9000 cluster also shares aether-test/mixed-svc with the HTTP cluster. The access logs rule the HTTP side out: across the whole 09-27 window, zero access-log lines carry CERTIFICATE_VERIFY_FAILED, and the only non-- upstream_transport_failure_reason is 3× delayed_connect_error: Connection refused. So the ticks are on the L4 clusters.
    • Not inboundready_. That cluster has AltStatName: "", so its stats are per-pod under its own name. It also sends ALPN h2 to 127.0.0.1:18008, which lands on the HCM chain, not the TCP floor.
    • Cadence is bursty, not periodic. At 1 m resolution the ticks are single minutes: 10:58, 13:01, 13:06, 13:33, 13:41, 14:19, 14:46, 14:53, 16:37, 17:16, 17:40, 17:52, 17:53. There is no probe or dialer cadence. Each burst covers every L4 leg dialled from that node during a window of a few seconds.

    2. One fully attributed event: 2026-09-27 16:37Z, main-worker-04

    hop evidence
    client ticks w04 aether-test/tcp-echo +1 and aether-test/mixed-svc +1 in the 16:37 minute (and again +1/+1 at 17:16)
    source mp-dialer-5bfs6 (w04). Between its 16:35:57 and 16:37:58 AETHER_METRIC lines, port_fail 17→18, mesh_fail 12→13 and prim_fail 12→13: exactly one failure on each of the three legs (mixed:9000, tcp-echo:18082, tcp-echo:9000)
    where it terminated svc-1-5c98654575-qm57c (w04, 10.244.0.239, SA svc-1). envoy_tcp_in_tcp_svc_1_5c98654575_qm57c_downstream_cx_total first appears at 16:37 with 3. That is the inbound TCP floor default chain of an HTTP-only pod, where nothing should ever arrive. envoy_listener_inbound_ssl_connection_error_total{aether_pod="svc-1-5c98654575-qm57c"} = 3 at the same minute (the server sees the client abort after its SAN check). At 17:16 both counters go to 5, matching the +1/+1 ticks.
    why that pod qm57c (created 15:55:25Z) was the newest mesh pod on w04 until 17:26:56Z. After that the newest was svc-5-…-fbvfn, and the 17:40 w04 tick lands on fbvfn (in_tcp_…fbvfn → 1). On w03 the newest after 17:26:56 was svc-5-…-f8w4k, and the 17:52/17:53 w03 ticks land on f8w4k (1 → 2).
    SAN pinned spiffe://aether.internal/ns/aether-test/sa/tcp-echo (and …/sa/mixed-svc). Presented spiffe://aether.internal/ns/aether-test/sa/svc-1, because qm57c's floor chain serves the pod's own SVID (buildInboundTCPFloorFilterChain, ingress.go:240). This is inferred from the chain rather than read from a log: the L4 path has no access log and Envoy logs the SAN list only at debug.

    The same landing appears for every tick in the window, always on a pod of the same node as the ticking client: w02 10:58 → svc-4-…-6xv2l; w05 13:01 → svc-3-…-mfjvw; w04 13:06 → svc-5-…-vqsmr; w05 13:33/13:41 → uds-cr-echo-…-hbk4p; w05 14:46/14:53 → svc-1-…-kk2z4. Other long-lived pods also pick up stray floor connections: prober-kd5jw, udp-dialer-qtm2p, k6-soak-loader-rv96j. The only thing these pods share is that each was the node's newest inbound listener at the time.

    3. Cause

    (a) aether turns on Envoy's restored-destination handoff, and that handoff ignores the network namespace. The capture listener sets UseOriginalDst: true (agent/internal/xds/proxy/capture.go:226). In Envoy that setting hands every connection with a restored destination to "the listener bound to that address" (active_tcp_socket.cc:240-267, getBalancedHandlerByAddress). The lookup key is address->asStringView(), which is "0.0.0.0:18008" with no netns (connection_handler_impl.cc:122, insert_or_assign; wildcard fallback at :425-433). Every per-pod inbound listener binds 0.0.0.0:18008 in its own netns (ingress.go:114-116), so each one overwrites the last. As a result, any connection a capture listener accepts with original destination *:18008 is run through the filter chains of whichever pod's inbound listener was added last. The socket stays in its original netns. That explains the "newest pod" landing exactly.

    The explicit original_dst listener filter (capture.go:252) is what sets localAddressRestored(), and it is also what the ORIGINAL_DST passthrough needs. The comment at capture.go:221 assumes the use_original_dst field is needed for that. It is not: the field adds the handoff (and a second copy of the same filter, listener_impl.cc:1047).

    (b) Envoy leaks a worker thread's network namespace, which is how a node-proxy socket reaches a capture listener in the first place. The node proxy runs in the host netns, so its tcp: upstream should never pass through a pod's capture. Network::Utility::execInNetworkNamespace (utility.h:383 at the pinned 726d7ac) records the netns to return to by opening /proc/self/ns/net. For a multi-threaded process that path resolves to the main thread's namespace, not the calling thread's; the per-thread path is /proc/thread-self/ns/net.

    • The main thread enters pod netnses briefly and constantly: the health_<pod> and inboundready_<pod> health-check connects every 5 s per local pod, plus listener socket creation.
    • A worker that calls execInNetworkNamespace (every app_<pod> connection) during one of those windows restores itself into that pod's netns and stays there until its next call.
    • While it is stuck, every host-intended upstream socket that worker creates is created in the pod netns.
    • Under redirect-all, the pod's divert then TPROXYs that socket's SYN to the pod's capture listener. The original destination is <endpoint>:18008, so step (a) hands it to the newest inbound listener.

    This rate fits what we see. The per-call collision probability is roughly the fraction of time the main thread spends in a pod netns (~1e-4). The call rate is a few app_<pod> connects per second per node. That gives about one burst per hour per node, and each burst lasts until the worker's next netns call (seconds), which is what the dialer's "one failure on every leg" shows.

    HTTP clusters do not visibly tick because h2 upstream connections are pooled and long-lived, so a new one is rarely created during a stuck window. The L4 legs open three new upstream connections every ~5 s per node.

    On the candidates you listed:

    • (a) wrong pin: no. sanURIs = spiffe://<td>/ns/<ns>/sa/<bare svc> (cache/mtls.go:95-127). Both services run on a ServiceAccount named after the service. The dialers succeed about 99.9% of the time.
    • (b) TLSRoute passthrough mis-count: no. The soak's L4 legs are plain nc, with no client TLS at all (e2e/soak/multiprotocol.yaml:189-213), and no TLSRoute targets these services.
    • (c) inboundready_ probe: no. See §1.

    4. Fix (no PR yet, with reasons)

    1. aether: set use_original_dst: false on the capture listener. Keep the explicit original_dst listener filter first. Mesh traffic never relies on the handoff: every capture decision is a filter-chain match on the restored destination, or the ORIGINAL_DST passthrough. The handoff can only ever pick the wrong netns's 0.0.0.0:18008. Correct the comment at capture.go:221 and the one at capture.go:262 ("already sets use_original_dst"). This is a one-line change, but it redefines every per-pod capture listener, so it is a full listener replace plus drain on rollout. It also needs the passthrough e2e and the ORIGINAL_DST path (original_dst_cluster.cc reads localAddressRestored()) confirmed green with the field off. That is why I did not open it as a drive-by.
    2. Envoy: return to /proc/thread-self/ns/net. Better, open the calling thread's own ns fd (/proc/self/task/<tid>/ns/net, which is what vishvananda/netns Get() does for the same reason). Carry it as a patch under proxy/bazel/patches/ and file it upstream. ExecInNetnsTest mocks open(), so it cannot catch this; a real two-thread test can.
      • With (1) alone, a leaked socket would pass through the correct endpoint's ORIGINAL_DST from a pod IP and succeed silently. (1) is correct on its own merits, but (2) is the root cause, and after (1) this counter no longer shows it.
    3. Gate and observability.
      • Give L4 clusters a distinct stat key (e.g. tcp:<ns>/<svc>[:port]) so aether_cluster separates L4 from HTTP. Today mixed-svc's HTTP and :9000 clusters are merged.
      • Add the L4 clusters to the soak's verify_san gate.
      • Add an L4 access log (the capture and inbound tcp_proxy have none, which is why this took a counter join to attribute).
      • A cheap discriminator for the defect: envoy_tcp_in_tcp_<pod>_downstream_cx_total on any pod that serves no raw-TCP port. It should be structurally zero, and here it is non-zero on svc-1..5, prober, k6 and udp-dialer.

    Falsification tests. For (b): apply the thread-self patch alone and the stray in_tcp landings (and these ticks) should go to zero. If they persist, something other than the netns leak is putting node-proxy sockets into pod netnses. For (a): with the field off, the landings should stop even while (b) still leaks.

    🤖 Generated with Claude Code

    https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

  3. bpalermo commented on Sep 27, 2026

    @bpalermo
    OwnerAuthor

    Scoping after the attribution above: this issue now tracks part (a) only — use_original_dst: true on the capture listener hands a diverted connection to whichever inbound listener bound 0.0.0.0:18008 last (address-string lookup, no netns), so a stray connection lands on the newest pod's inbound chain and is rejected by SAN. Part (b), how a host-network proxy socket ends up inside a pod netns at all, is #1022 (must be proven before or with the (a) fix, because (a) alone hides it). The stat-key / access-log / gate gaps are #1023.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions