Skip to content

038 Phase 4b blocker: Envoy's QUIC client requires the server leaf's DNS SAN to match the SNI hostname — SVIDs have only URI SANs, the mesh's SNI is the port #957

Closed

Description

@bpalermo

Finding (2026-09-26, //test/mtlspool HTTP/3 arm, pinned proxy 719f66a / Envoy 726d7ac)

A per-source quic: cluster built exactly as the cache builds it (PR #956: QUICClusterFrom + QUICUpstreamTransportSocket, SNI = the destination port, SAN pin = the destination SPIFFE ID) never completes a handshake to a quic-go HTTP/3 server presenting a SPIFFE SVID. Envoy component log (quic:debug):

[info][quic] tls_handshaker.cc:288] Cert chain verification failed: Leaf certificate doesn't match hostname: 18008
[debug][pool] conn_pool_base.cc:659 client disconnected, failure reason: QUIC_TLS_CERTIFICATE_UNKNOWN

The route returns 503 to the source. The SAN pin PASSED — the chain validation succeeded — and then source/common/quic/envoy_quic_proof_verifier.cc runs verifyLeafCertMatchesHostname(cert_view, hostname, …), which matches hostname (the SNI) against the leaf's subject_alt_name_domains() only (DNS SANs, dnsNameMatch). It runs on every successful validation; the only way past it is accept_untrusted, which disables validation entirely.

The TCP path has no such step: Envoy's TLS client validator does no hostname check at all, and the match_typed_subject_alt_names URI pin IS the identity check. That asymmetry is what 038 Phase 4b ran into.

Why it blocks

  • SPIFFE X.509-SVIDs carry the identity as a URI SAN; the mesh's SVIDs have no DNS SANs.
  • The mesh's inbound SNI is the destination port ("18008", "8080", …) — the per-port demux key (proposal 005/037), not a hostname.
  • So verifyLeafCertMatchesHostname("18008", ⟨URI-only leaf⟩) is false for every destination, always.

#953's inbound QUIC listener is unaffected (it is the server side; #47623's SDS check passes). #956 (outbound) is parked as a draft until one of the paths below is chosen — merging it would ship an allow-list that 503s.

Paths

A. Upstream Envoy. In EnvoyQuicProofVerifier, skip the hostname match when the validation context configured match_typed_subject_alt_names (the operator has stated the identity check explicitly, same as the TCP validator's semantics), or when the SNI is not a DNS name. Small, and consistent with how DefaultCertValidator treats SAN matchers. Needs an upstream PR, a merge, a registry snapshot and a pin bump (#952 took one day end to end once the snapshot existed; the registry publishes irregularly).

B. Give SVIDs DNS SANs, no Envoy change. SPIRE's ClusterSPIFFEID supports dnsNameTemplates; an entry with ["{{ .PodSpec.ServiceAccountName }}.{{ .PodMeta.Namespace }}.aether.internal", "*.{{ .PodSpec.ServiceAccountName }}.{{ .PodMeta.Namespace }}.aether.internal"] puts the service FQDN and a wildcard under it into every SVID. The QUIC upstream then uses SNI <port>.<svc>.<ns>.<domain> (the waypoint's structured shape, matches the wildcard), and the QUIC inbound's per-port chains match server_names: ["<port>.<fqdn>"] instead of ["<port>"]. Costs: the identity document changes (DNS SANs on every SVID — SPIFFE permits it), a SPIRE chart change, and the QUIC inbound/outbound SNI shape diverges from TCP's bare port. Verifiable end to end in the mtlspool harness today.

Path B is being tried in the harness now; the result goes here.

Activity

  1. bpalermo commented on Sep 26, 2026

    @bpalermo
    OwnerAuthor

    Path B verified end to end (2026-09-26, //test/mtlspool HTTP/3 arm, pinned proxy 719f66a)

    Same harness, two changes and nothing else:

    1. the HTTP/3 destination's leaf carries DNS SANs echo.demo.svc and *.echo.demo.svc beside its URI SAN (the shape SPIRE's ClusterSPIFFEID.dnsNameTemplates would produce);
    2. the quic: twins dial with SNI 18008.echo.demo.svc (<port>.<fqdn>) instead of 18008.

    Result: TestQUICSelectionPresentsEachSourceIdentity PASSES — Envoy's QUIC client handshakes, every request from source-a arrives at the destination verified as source-a's SVID and every request from source-b as source-b's, all HTTP/3.0, no QUIC connection shared between the two clusters. The negative control (TestQUICSelectionArmsAreLoadBearing, arms swapped) shows the swapped identities, so the route's matcher is what attributes identity.

    So the whole 038 Phase 4b stack — per-source quic: clusters, the filter-state matcher cluster specifier, MaxSessionKeys: 0, the SAN pin — works at the pinned Envoy the moment the server's SVID carries a DNS SAN the SNI can match. The port demux survives as <port>.<fqdn> against the wildcard SAN, mirroring the waypoint's structured-SNI shape. Path A (upstream: skip the hostname match when SAN matchers are configured) would let the DNS SANs be dropped again later; it is not required to ship.

    If B is chosen: #953's QUIC inbound chains change to server_names: ["<port>.<fqdn>"] (default chain unchanged), #956's twins to SNI <port>.<fqdn>, envoy_validate fixtures follow, and the talos SPIRE chart (GitOps) gains the dnsNameTemplates — deployed only after the running rev239 soak is graded.

  2. bpalermo commented on Sep 26, 2026

    @bpalermo
    OwnerAuthor

    Path A design (from the envoy session, verified against 726d7acb73)

    What the hostname is. On the QUIC client it is the SNI and nothing else: the HTTP/3 pool builds the QuicServerId host from sni() (source/common/http/http3/conn_pool.cc:54-58 — the transport-socket-options serverNameOverride, else UpstreamTlsContext.sni); the upstream address is never used. So every QUIC upstream today needs a DNS-shaped SNI present in the server cert; a port SNI cannot pass by construction.

    Why TCP differs. DefaultCertValidator::verifyCertAndUpdateStatus (default_validator.cc:327-348) matches the SNI against a DNS SAN only when auto_sni_san_validation is set (match_sni_san), otherwise it uses the configured subject_alt_name_matchers_; the proto doc says auto-SNI validation "replaces any SAN validations". TCP lets the operator pick ONE identity check; QUIC adds the SNI-derived one on top. The fix is to make QUIC follow the same rule — not to add a bypass.

    Condition. Run the QUIC hostname check unless accept_untrusted (as today) or an explicit identity check is configured and auto_sni_san_validation is off. Explicit = any of: match_typed_subject_alt_names non-empty; verify_certificate_hash / verify_certificate_spki non-empty; custom_validator_config set (SPIFFE or any custom validator owns identity); or the per-connection verifySubjectAltNameListOverride() non-empty. With none configured the current behaviour stays — a bare trusted_ca on QUIC still gets the hostname check (what Envoy Mobile relies on for public HTTP/3). Nothing that passes today fails after; nothing is accepted unless it chains to the trusted CA AND satisfies the operator's matcher/pin.

    Where. (1) quic_client_transport_socket_factory.cc:159-196 getCryptoConfig() already derives accept_untrusted from the validation context and rebuilds the proof verifier on SSL-context change (SDS updates included) — derive a second bool explicit_identity_check there and pass it to the EnvoyQuicProofVerifier ctor (envoy_quic_proof_verifier.h:58-61, one member beside accept_untrusted_). (2) VerifyCertChain: verify_hostname = !accept_untrusted_ && !(explicit_identity_check_ || override non-empty) && runtime guard; pass it to QuicValidateResultCallback (lines 106-108 / 51-55) and use it in the sync branch (line 124) — which today does not consult accept_untrusted_ at all, an asymmetry the same PR removes. (3) Runtime guard envoy.reloadable_features.quic_hostname_check_deferred_to_explicit_san_match (name negotiable), default true, in runtime_features.cc. (4) Docs in tls.proto for match_typed_subject_alt_names / auto_sni_san_validation; changelog under minor_behavior_changes (area quic). ~40 lines plus tests.

    Guard, not a field. A skip_hostname_verification field is the footgun #35551's title warns about and would be QUIC-only for behaviour TCP does implicitly. Framing: #35551 (aa8d0f7d7a) fixed ACCEPT_UNTRUSTED not being honoured by the QUIC hostname check; this change leaves the no-matcher path untouched and does not weaken trust-chain validation — it stops QUIC adding an SNI-derived DNS-SAN requirement on top of an operator-configured identity check, the rule TCP has always had and one URI-only X.509-SVIDs cannot meet; RFC 9000 adds no hostname requirement beyond TLS 1.3. Likely reviewers: the QUIC owners and ggreenway for TLS (his TODO at default_validator.cc:340-341 already treats SNI/SAN matching as validator territory).

    Tests. envoy_quic_proof_verifier_test.cc (fixture already mocks subjectAltNameMatchers/hash/spki/customValidatorConfig/autoSniSanMatch, lines 50-58): SanMatcherSkipsHostnameCheck (sync + async twin via timed_cert_validator), the existing InvalidHost tests unchanged (no-matcher path), guard-off variant, AutoSniSanMatchKeepsHostnameCheck, a success case on VerifySubjectAltNameListOverrideFailure, and a SPIFFE case with san_uri_cert. quic_transport_socket_factory_test.cc for the derivation and its SDS refresh. Optionally an HTTP/3 upstream case in quic_http_integration_test.cc (upstream presents spiffe_san_cert, cluster with URI matcher and sni: not-a-dns-name, expect 200; the twin without matchers fails) — the reproduction of this issue in upstream's own harness.

    Path B stays valid as the interim: DNS SANs plus a DNS-shaped SNI is exactly what today's rule demands.

  3. bpalermo commented on Sep 26, 2026

    @bpalermo
    OwnerAuthor

    Status 2026-09-26: blocked on upstream, not actionable here.

    When #47740 merges and the proxy pin moves past it: the DNS SANs become optional (leave the SNI shape as is), the runbook's SPIRE prerequisite paragraph and docs/getting-started.md §11 bullet go, and this issue closes.

  4. bpalermo commented on Sep 27, 2026

    @bpalermo
    OwnerAuthor

    Path A validated against the real aether-proxy binary, 2026-09-27 09:47Z — envoyproxy/envoy#47740 carried as a patch on the 726d7ac pin (#972, bot pin cb79180 → chart 0.95.3), run through the mtlspool HTTP/3 arm with the original path-A configuration: destination presents a URI-only X.509-SVID, the quic: twins dial SNI "18008", combined_validation_context + match_typed_subject_alt_names URI == destination SPIFFE ID, no auto_sni / auto_sni_san_validation anywhere (asserted). Tests in #973.

    test result on the #47740 binary on the previous pin
    TestQUICPathAHandshakesWithoutDNSSANs PASS — every request from both sources 200 over HTTP/3.0 with the caller's own SPIFFE ID; no doesn't match hostname, no QUIC_TLS_CERTIFICATE_UNKNOWN FAIL: 503, Cert chain verification failed: Leaf certificate doesn't match hostname: 18008, pool QUIC_TLS_CERTIFICATE_UNKNOWN … CERTIFICATE_VERIFY_FAILED
    TestQUICPathAWrongSANStillFails (pin = wrong SPIFFE ID) PASS — 503 on every attempt with Cert chain verification failed: verify cert failed: SAN matcher, certificate SANs are [127.0.0.1, spiffe://aether.internal/ns/demo/sa/echo]; the hostname message never appears — the identity check is still enforced PASS (same failure; the validator already ran before the hostname check)
    TestQUICPathAGuardOffRestoresHostnameCheck (envoy.reloadable_features.quic_hostname_check_deferred_to_explicit_san_match: false in the bootstrap static layer) PASS — the handshake fails again with Leaf certificate doesn't match hostname: 18008 + QUIC_TLS_CERTIFICATE_UNKNOWN: the guard really restores the old behaviour PASS (the check was unconditional)

    Log level needed to see the verify lines: --component-log-level quic:info,pool:debug (both messages come from quiche's tls_handshaker.cc).

    So with #47740 the DNS-SAN workaround (path B) becomes optional: the SPIRE dnsNameTemplates prerequisite can be dropped once the upstream PR merges and a plain pin carries it. Production keeps the <port>.<fqdn> SNI either way. This issue stays open only for that cleanup.

  5. bpalermo commented on Sep 27, 2026

    @bpalermo
    OwnerAuthor

    Closing: path B (SNI <port>.<fqdn> + workload DNS SANs, #956) shipped and runs on talos-main; path A (envoyproxy/envoy#47740) carried on the pin (#972) and validated on the real binary with the original configuration (#973 — handshake over HTTP/3 with a URI-only SVID and SNI "18008", wrong-SAN control fails on the SAN matcher, guard-off control restores the hostname failure). The only remaining work is removing the workaround and the carried patches once a plain pin contains the upstream fix: #980.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions