Skip to content

quic: defer the upstream hostname check to explicit SAN matchers - #47740

Open
bpalermo wants to merge 5 commits into
envoyproxy:mainfrom
bpalermo:quic-hostname-check-explicit-san
Open

bpalermo wants to merge 5 commits into
envoyproxy:mainfrom
bpalermo:quic-hostname-check-explicit-san

Conversation

@bpalermo

Copy link
Copy Markdown
Contributor

Commit Message

quic: defer the upstream hostname check to explicit SAN matchers

Additional Description

EnvoyQuicProofVerifier unconditionally requires the server certificate to carry a DNS SAN
matching the hostname (the SNI) once the chain has been validated, in both the synchronous and the
asynchronous path. The TLS client on TCP has no such check: DefaultCertValidator matches the SNI
against a DNS SAN only when auto_sni_san_validation is set, and otherwise applies the configured
match_typed_subject_alt_names, pins or custom validator. So a server certificate with only a URI
SAN, such as an X.509 SVID pinned by a URI matcher or validated by the SPIFFE validator, is accepted
over TCP and rejected over HTTP/3 with Leaf certificate doesn't match hostname.

This makes the HTTP/3 client follow the TCP rule. The QUIC client transport socket factory derives
an explicit-identity-check flag from the validation context next to the existing ACCEPT_UNTRUSTED
handling (SAN matchers, certificate hash or SPKI pins, or a custom validator configured, and
auto_sni_san_validation not set), and the verifier also honors a per-connection SAN list override.
When the flag is set the SNI-derived DNS SAN check is skipped; trust-chain validation and the
configured identity check are unchanged.

What does not change: a validation context with only a trusted CA keeps the hostname check, so the
answer given in #33775 still holds and Envoy Mobile's public HTTP/3 behavior is unaffected. This is
not a bypass of the kind #35551 closed: nothing is accepted unless it chains to the trusted CA and
satisfies the operator's explicit matcher, pin or validator. Setting auto_sni_san_validation
keeps the SNI check on HTTP/3 as documented for TCP.

Also fixed: the synchronous verification path did not consult accept_untrusted_ while the
asynchronous path did; both now share one flag.

Risk Level

Low. Relaxes a redundant check only for configurations that already declare an explicit identity
check. Runtime guarded by
envoy.reloadable_features.quic_hostname_check_deferred_to_explicit_san_match.

Testing

  • envoy_quic_proof_verifier_test: truth table for the flag derivation; SAN matcher, certificate
    hash pin, per-connection SAN override and async custom validator all pass with a mismatched
    hostname; a mismatching SAN matcher still fails; auto_sni_san_validation keeps the hostname
    check; the runtime guard restores the old failure; the existing invalid-host tests are unchanged
    for the no-matcher path.
  • quic_mtls_integration_test: new fixture where the fake HTTP/3 upstream presents the URI-only
    test certificate. A URI SAN matcher and the SPIFFE validator both succeed with a non-DNS SNI, no
    matcher still fails with 503, and the runtime guard restores the failure.

Docs Changes

auto_sni_san_validation proto docs describe the HTTP/3 rule.

Release Notes

Added a minor behavior change fragment.

Platform Specific Features

N/A

The HTTP/3 client always required the server certificate to carry a DNS SAN
matching the SNI, even after the configured SAN matchers, certificate pins or
custom validator had validated the peer. The TLS client on TCP only matches the
SNI against SANs when auto_sni_san_validation is set, so URI-only server
certificates such as X.509 SVIDs worked over TCP but failed over HTTP/3.

The QUIC proof verifier now skips the SNI-derived DNS SAN check when the
validation context configures an explicit identity check and does not request
auto SNI SAN matching. Validation contexts without one keep the check. The
change is guarded by
envoy.reloadable_features.quic_hostname_check_deferred_to_explicit_san_match.
The synchronous validation path now also honors ACCEPT_UNTRUSTED like the
asynchronous one.

Signed-off-by: Bruno Palermo <[email protected]>
@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #47740 was opened by bpalermo.

see: more, trace.

@bpalermo
bpalermo marked this pull request as ready for review September 26, 2026 18:46
@bpalermo

Copy link
Copy Markdown
Contributor Author

@RyanTheOptimist @ggreenway early design check, since this touches the QUIC client's hostname verification.

The goal is TCP parity for server identity checks on HTTP/3 upstreams. On TCP, DefaultCertValidator matches the SNI against a DNS SAN only when auto_sni_san_validation is set; otherwise the configured match_typed_subject_alt_names, pins, or custom validator is the identity check. The HTTP/3 client adds an unconditional SNI-to-DNS-SAN requirement on top of that, so the same cluster config accepts a URI-only server cert (an X.509 SVID pinned by a URI matcher, or validated by the SPIFFE validator) over TCP and rejects it over HTTP/3 with Leaf certificate doesn't match hostname.

The change makes QUIC follow the TCP rule: skip the SNI-derived check only when the validation context configures an explicit identity check and auto_sni_san_validation is not set. A bare trusted_ca keeps today's behavior, so the answer in #33775 still holds and this doesn't reopen what #35551 closed. Runtime guarded, and the sync path now honors ACCEPT_UNTRUSTED like the async path already did.

Any concerns with treating matchers, pins, custom validators, and the per-connection SAN override as "explicit identity check", or would you rather see this gated differently (e.g. an explicit field instead of inferring from the validation context)? Happy to adjust.

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/runtime-guard-changes: FYI only for changes made to (source/common/runtime/runtime_features.cc).
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @markdroth
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #47740 was ready_for_review by bpalermo.

see: more, trace.

@bpalermo

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@bpalermo

Copy link
Copy Markdown
Contributor Author

/retest

bpalermo added a commit to bpalermo/aether that referenced this pull request Sep 26, 2026
…red to explicit SAN matchers) on the 726d7ac pin (#972)

aether#957 path A: Envoy's QUIC client verified the server leaf's DNS SANs
against the SNI after ANY validator succeeded, so a URI-SAN-only SVID with a
port-shaped SNI could never handshake. Upstream #47740 (67af4c692c +
01c09223bd on top of exactly our pin) skips that hostname check when an
explicit identity check is configured (match_typed_subject_alt_names, pins,
a custom validator) and auto_sni_san_validation is off, behind
envoy.reloadable_features.quic_hostname_check_deferred_to_explicit_san_match
(default true; the runtime_features.cc hunk registers the guard).

Second entry in the single_version_override patch list, applied after
47743; source + the SPIFFE validator BUILD visibility line, the api/ doc
comment (separate registry module), tests and changelog dropped. Verified:
`git apply --check` clean in sequence at 726d7ac; `bazel build --nobuild
--config=release //:envoy //...:aether_stats_test` fetches the patched
module with the guard registered.

Validation (test/mtlspool, once the chart pin carries this image): the QUIC
arm with its ORIGINAL path-A config (SNI "18008", URI-only SVID, SAN matcher
on the destination SPIFFE ID) must handshake and answer 200 over HTTP/3;
negative control = a wrong SPIFFE ID in the matcher fails on the SAN matcher,
not the hostname; guard control = the runtime flag set to false in the
bootstrap static layer brings the hostname failure back. Production keeps
the <port>.<fqdn> SNI + DNS SANs (valid under the fix either way).


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Fable 5.1 <[email protected]>
bpalermo added a commit to bpalermo/aether that referenced this pull request Sep 27, 2026
Parameterise the QUIC harness (quicOptions on startDestinationH3With,
quicTwinWith, startEnvoyQUICWith; the existing entry points delegate with
defaultQUICOptions, so the two selection tests run byte-identical config)
and add the path-A tests for envoyproxy/envoy#47740 (carried by #972):

- TestQUICPathAHandshakesWithoutDNSSANs: URI-only SVID, SNI "18008",
  correct pin -> 200 over HTTP/3 with each caller's identity, no hostname
  / QUIC_TLS_CERTIFICATE_UNKNOWN in the log. RED on the current pin
  (503, "Leaf certificate doesn't match hostname: 18008"); green once the
  chart pins an image with #47740.
- TestQUICPathAWrongSANStillFails: wrong pin -> fails on
  "verify cert failed: SAN matcher", never on the hostname. Green on both
  binaries (the validator runs before the hostname check).
- TestQUICPathAGuardOffRestoresHostnameCheck: runtime guard false ->
  hostname failure returns (anti-vacuity control; green on both).
- TestQUICTwinsLeaveAutoSNIOff: no twin sets auto_host_sni /
  auto_sni_san_validation / auto_sni / auto_san_validation, and the SAN
  pin is present as match_typed_subject_alt_names.

Envoy runs with --component-log-level quic:info,pool:debug for these:
the handshake failure detail is [info][quic], the pool failure code is
[debug][pool].

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
bpalermo added a commit to bpalermo/aether that referenced this pull request Sep 27, 2026
Parameterise the QUIC harness (quicOptions on startDestinationH3With,
quicTwinWith, startEnvoyQUICWith; the existing entry points delegate with
defaultQUICOptions, so the two selection tests run byte-identical config)
and add the path-A tests for envoyproxy/envoy#47740 (carried by #972):

- TestQUICPathAHandshakesWithoutDNSSANs: URI-only SVID, SNI "18008",
  correct pin -> 200 over HTTP/3 with each caller's identity, no hostname
  / QUIC_TLS_CERTIFICATE_UNKNOWN in the log. RED on the current pin
  (503, "Leaf certificate doesn't match hostname: 18008"); green once the
  chart pins an image with #47740.
- TestQUICPathAWrongSANStillFails: wrong pin -> fails on
  "verify cert failed: SAN matcher", never on the hostname. Green on both
  binaries (the validator runs before the hostname check).
- TestQUICPathAGuardOffRestoresHostnameCheck: runtime guard false ->
  hostname failure returns (anti-vacuity control; green on both).
- TestQUICTwinsLeaveAutoSNIOff: no twin sets auto_host_sni /
  auto_sni_san_validation / auto_sni / auto_san_validation, and the SAN
  pin is present as match_typed_subject_alt_names.

Envoy runs with --component-log-level quic:info,pool:debug for these:
the handshake failure detail is [info][quic], the pool failure code is
[debug][pool].


Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

Co-authored-by: Claude Fable 5.1 <[email protected]>
bpalermo added a commit to bpalermo/aether that referenced this pull request Sep 27, 2026
…s gone

Decision 2026-09-26: no opt-in for QUIC; the per-destination allow-list
(--east-west-quic-services / agent.eastWestQuicServices) was a proving gate
for the first QUIC soak. Every default service entry in the node's dependency
set now gets one per-source quic: twin per local ServiceAccount, selected on
both out_http and cap_http, identity-ready only, never per-port/alias entries.

New: a service with any waypoint-tagged endpoint (proposal 019) never gets a
twin -- the twin shares the EDS resource but not the waypoint socket matcher,
and the tunnel has no QUIC leg. The cache did not exclude these before; the
allow-list was the only thing keeping them off QUIC.

The fan-out log line drops allow_listed_services. Chart 0.95.4 removes the
value; the SPIRE DNS-SAN prerequisite is documented as mesh-wide until
envoyproxy/envoy#47740 is in a plain pin. e2e/eastwest-quic.sh drops the
EASTWEST_QUIC knob and the h2only destination (E3) and gains a real negative
control, QUIC_DNS_SANS=off (no DNS SANs + the #47740 runtime guard off),
expected red at E2 with the aether#957 hostname-mismatch shape.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@ggreenway

Copy link
Copy Markdown
Member

I haven't looked at the changes at all, but making it behave the same in QUIC as it does for TCP/TLS seems like the correct behavior

bpalermo added a commit to bpalermo/aether that referenced this pull request Sep 29, 2026
…s gone (#979)

* feat(038): east-west QUIC is unconditional — the proving allow-list is gone

Decision 2026-09-26: no opt-in for QUIC; the per-destination allow-list
(--east-west-quic-services / agent.eastWestQuicServices) was a proving gate
for the first QUIC soak. Every default service entry in the node's dependency
set now gets one per-source quic: twin per local ServiceAccount, selected on
both out_http and cap_http, identity-ready only, never per-port/alias entries.

New: a service with any waypoint-tagged endpoint (proposal 019) never gets a
twin -- the twin shares the EDS resource but not the waypoint socket matcher,
and the tunnel has no QUIC leg. The cache did not exclude these before; the
allow-list was the only thing keeping them off QUIC.

The fan-out log line drops allow_listed_services. Chart 0.95.4 removes the
value; the SPIRE DNS-SAN prerequisite is documented as mesh-wide until
envoyproxy/envoy#47740 is in a plain pin. e2e/eastwest-quic.sh drops the
EASTWEST_QUIC knob and the h2only destination (E3) and gains a real negative
control, QUIC_DNS_SANS=off (no DNS SANs + the #47740 runtime guard off),
expected red at E2 with the aether#957 hostname-mismatch shape.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* docs(038): name #979 in the proposal

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

* docs(038): the first proving soak did not pass; the #979 flip is gated on the next one; the h3/h2 cost baseline is the same-build 1.18x (#1021)

The 2026-09-27 proving soak (rev242) passed the prober but failed k6: 1,154
errors, 1,060 of them 503 NC at first use (#1008). Nothing in the PR may say it
passed. The ~3.3x per-request figure compared rev239 h2 with rev242 QUIC; the
same-build A/B of 2026-09-28 (rev247, 300 rps, matched 80-min no-roll windows)
measured 1.18x (10.5 ms vs 8.9 ms), under the <=1.5x gate:
#1021

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Comment on lines +128 to +132
const bool verify_hostname =
!accept_untrusted_ &&
!(explicit_identity_check &&
Runtime::runtimeFeatureEnabled(
"envoy.reloadable_features.quic_hostname_check_deferred_to_explicit_san_match"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to mirror the TCP-TLS behavior, and only do this check when the new runtime flag is set to false. I don't see any good reason for QUIC to behave differently than TCP-TLS.

@RyanTheOptimist or @danzh2010 any objection to unifying the behavior?

/wait-any

@bpalermo

Copy link
Copy Markdown
Contributor Author

@RyanTheOptimist gentle ping 🙏

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Per-connection SAN overrides can suppress required hostname verification without ensuring the replacement identity check runs.

2 open issues
What changed in this PR

This PR aligns HTTP/3 upstream certificate validation more closely with TCP TLS by deferring hostname checks to configured identity validation, while retaining hostname checks for CA-only configurations.

Changes:

  • Adds runtime-guarded hostname-check deferral and shares the decision across synchronous and asynchronous verification.
  • Adds unit and integration coverage for explicit identity checks, URI-only certificates, and rollback behavior.
  • Documents the HTTP/3 validation rule and adds a release note.
File Description
test/​integration/​quic_mtls_integration_test.cc Adds URI SAN and SPIFFE upstream validation scenarios.
test/​integration/​BUILD Adds test certificates and the SPIFFE validator dependency.
test/​integration/​base_integration_test.h Allows fixtures to override upstream TLS context creation.
test/​common/​quic/​envoy_quic_proof_verifier_test.cc Tests identity-check deferral and runtime rollback.
source/​extensions/​transport_sockets/​tls/​cert_validator/​spiffe/​BUILD Enables integration-test access to the SPIFFE validator.
source/​common/​runtime/​runtime_features.cc Registers the hostname-check runtime guard.
source/​common/​quic/​quic_client_transport_socket_factory.cc Derives and passes the explicit-identity-check flag.
source/​common/​quic/​envoy_quic_proof_verifier.h Declares identity-check detection and verifier state.
source/​common/​quic/​envoy_quic_proof_verifier.cc Applies shared hostname-check logic to both verification paths.
changelogs/​current/​minor_behavior_changes/​quic__upstream-hostname-check-explicit-san-match.rst Describes the behavior change and rollback guard.
api/​envoy/​extensions/​transport_sockets/​tls/​v3/​tls.proto Documents HTTP/3 behavior for auto-SNI validation.

Review effort: Balanced

Comment on lines +124 to +127
const bool explicit_identity_check =
explicit_identity_check_ ||
(verify_context->transportSocketOptions() != nullptr &&
!verify_context->transportSocketOptions()->verifySubjectAltNameListOverride().empty());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. On TCP, DefaultCertValidator already lets a non-empty SAN override replace the auto-SNI match (it is an either/or in verifyCertAndUpdateStatus), so QUIC was at parity. But this PR's auto_sni_san_validation doc says setting it keeps the SNI check, and an override was dropping it. Fixed in 837743e: with auto_sni_san_validation set, an override no longer lifts the QUIC hostname check (the validator still matches the override, as on TCP). Regression test: AutoSniSanMatchKeepsHostnameCheckWithSubjectAltNameOverride.

Comment on lines +128 to +132
const bool verify_hostname =
!accept_untrusted_ &&
!(explicit_identity_check &&
Runtime::runtimeFeatureEnabled(
"envoy.reloadable_features.quic_hostname_check_deferred_to_explicit_san_match"));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that the override is never checked here. With no trusted CA or other validation configured the context is SSL_VERIFY_NONE and the custom verify callback isn't installed, which is the same on TCP. Rather than fail closed (stricter than TCP), 837743e keeps the pre-existing hostname check in that case: an override only replaces it when the validator actually ran (detailed_status != NotValidated). Negative test without a trusted CA: SubjectAltNameListOverrideWithoutValidationKeepsHostnameCheck.

@bpalermo
bpalermo requested a review from ggreenway October 26, 2026 16:48
A per-connection SAN list override no longer replaces the upstream
hostname check when auto_sni_san_validation is set, as tls.proto
documents, or when the TLS context has no validation configured and so
never checks the override.

Signed-off-by: Bruno Palermo <[email protected]>
@bpalermo

Copy link
Copy Markdown
Contributor Author

/retest

@markdroth

Copy link
Copy Markdown
Contributor

/lgtm api

@RyanTheOptimist RyanTheOptimist left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. @ggreenway?

@bpalermo

Copy link
Copy Markdown
Contributor Author

@ggreenway gentle ping 🙏

@ggreenway ggreenway left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change still leaves deviation from the behavior of TCP-TLS, and adds extra docs and a lot of code to try to make it all work. Instead, could we get to exact parity of behavior?

I think the biggest risk is if someone is currently only using h3 and relying on the implicit hostname check. I wonder if that could be resolved with a big warning or something.

@RyanTheOptimist wdyt?

@bpalermo

Copy link
Copy Markdown
Contributor Author

Happy to do change it once we agree on how to handle it

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants