GHSA-5r4w-85f3-pw66: Traefik: SNICheck ignores wildcard TLSOptions mappings, allowing domain-fronted mTLS bypass
SummaryThere is a high severity vulnerability in Traefik's domain-fronting protection (`SNICheck`) that allows an unauthenticated client to bypass mutual TLS enforced through wildcard router `TLSOptions`. When a router uses a wildcard host rule such as `Host(`*.example.com`)` with stricter TLS options (for example `RequireAndVerifyClientCert`), `SNICheck` resolves the TLS options for the HTTP `Host` header using exact map lookups only and never applies wildcard matching. If another permissive SNI is served on the same entrypoint, an attacker can complete the TLS handshake under the permissive options and then send an HTTP `Host` header targeting the wildcard-protected backend, reaching it without presenting a client certificate. This affects the regular HTTPS / HTTP-2 path and does not require HTTP/3.Patcheshttps://github.com/traefik/traefik/releases/tag/v3.7.3For more informationIf you have any questions or comments about this advisory, please [open an issue](https://github.com/traefik/traefik/issues).SummaryTraefik's `SNICheck` domain-fronting protection ignores wildcard `TLSOptions` mappings. A wildcard router such as `Host("*.example.com")` can require mTLS for direct access, but an unauthenticated client can complete the TLS handshake with another permissive SNI on the same entrypoint and then send `Host: api.example.com` / HTTP request authority `api.example.com` to reach the wildcard-protected backend.This issue does not require HTTP/3. The PoC uses the regular HTTPS/HTTP2 path and abuses the domain-fronting consistency check between TLS SNI and the HTTP `Host` header.For HTTP/2, this corresponds to the request authority / `Host` value as exposed to Traefik's HTTP request handling.DetailsFor the v3 rule-syntax / file-provider path used in this PoC, wildcard `Host` / `HostSNI` matching and TLSOptions association for wildcard domains were introduced in Traefik v3.7. The normal HTTPS/TCP router path uses wildcard-aware matching. The `SNICheck` middleware does not.The router build records TLS option names for host rules:The HTTPS forwarder then installs SNI routes:`HostSNI` matching is wildcard-aware:But `pkg/middlewares/snicheck/snicheck.go` resolves the host's TLS option name with exact lookups only:There is no wildcard matching step for entries such as `*.example.com`. As a result, `Host: api.example.com` can be classified as using default TLS options even though the router matched a wildcard host with stricter `TLSOptions`.Preconditions:A protected router uses wildcard `Host` / `HostSNI` with router-specific `TLSOptions`.The protected wildcard router uses stricter TLS options, such as `RequireAndVerifyClientCert`.Another SNI/default TLS path on the same entrypoint allows a handshake without a client certificate.The client can send an HTTP `Host` header different from the TLS SNI.Relationship to my previous HTTP/3 report:I previously submitted a related HTTP/3 mTLS bypass involving `Router.GetTLSGetClientInfo()` and exact/case-sensitive SNI lookup.This report is separate. It does not require HTTP/3 or QUIC. It affects the regular HTTPS/HTTP2 path and is caused by `SNICheck` resolving `tlsOptionsForHost` with exact lookups only, without wildcard matching. The exploit uses domain fronting: a permissive TLS SNI is used for the handshake, while the HTTP request authority / `Host` header targets a wildcard-protected backend.Relationship to public issue #12349:This is related to public issue #12349, where wildcard hosts were observed to be classified as `default` by `SNICheck`, causing unexpected `421 Misdirected Request` responses in some wildcard setups:The public issue demonstrates the same wildcard resolution gap as an availability/operational problem. This report demonstrates a security-impacting false-negative variant that can bypass router-specific mTLS when a permissive SNI exists on the same entrypoint. When the attacker chooses a permissive/default SNI and sends a protected wildcard host in the HTTP `Host` header, both sides can be classified as `default`, so `SNICheck` does not return `421`. The later HTTP router then matches the wildcard-protected backend and the request is forwarded without enforcing the wildcard route's mTLS policy.Related wildcard `SNICheck` behavior has also been observed in Kubernetes Ingress setups, as described in public issue #12349. The PoC below uses the file provider and v3 rule syntax to keep the reproduction minimal and self-contained.Minimal dynamic configuration:Minimal Docker Compose:Certificate generation:PoCStart Traefik with the configuration above.Test environment:Traefik images tested: `v3.7.0`, `v3.7.1`Backend image: `traefik/whoami:v1.11`Client: `curl` with HTTPS/HTTP2 supportEntryPoint: TCP port `8443` exposed locallyProvider: file providerControl 1: the permissive public route works normally and reaches the public backend:Observed result:Control 2: direct access to the wildcard-protected host without a client certificate is blocked:Observed result:Bypass: use the permissive public SNI for the TLS handshake, but send the protected wildcard host in the HTTP request:Observed result:The curl verbose output shows that the HTTP/2 request authority / `Host` value is `api.example.com`, while the TLS SNI is taken from the URL host `public.example.net`:Expected result:Traefik should return `421 Misdirected Request` because the HTTP `Host` header resolves to the wildcard route's `mtls` TLSOptions while the TLS SNI resolves to permissive/default TLSOptions.Negative control with exact host:Replacing the protected router rule with exact `Host("api.example.com")` while keeping `tls.options=mtls` causes the same domain-fronting request to be rejected:Run the same request:Observed result:This shows that the bypass depends on wildcard TLSOptions resolution in `SNICheck`, not on a generic failure of the domain-fronting check.Regression test used during validation:Version matrix observed with Docker images:ImpactDeployments that use wildcard router `TLSOptions` for client certificate authentication can expose protected backends to unauthenticated clients when another permissive SNI exists on the same entrypoint.The TLS handshake is completed under the permissive/default TLS options selected for the SNI, while the later HTTP router still dispatches the request to the wildcard route that was configured with mTLS-specific TLSOptions. This bypasses a security boundary that administrators can reasonably expect to be enforced by `tls.options=mtls` on the wildcard route.A possible fix would be for `SNICheck` to resolve `tlsOptionsForHost` using the same wildcard-aware host matching semantics used by the router / `HostSNI` matching, rather than exact map lookups only.Possible workarounds until a fix is available:Avoid wildcard router `TLSOptions` for mTLS access control.Enumerate exact protected hostnames instead of using wildcard `Host` rules.Enforce mTLS in the default TLS options as well.Avoid mixing permissive and mTLS-protected hosts on the same entrypoint.Block or reject domain-fronted requests at another layer.
CVSS v4.0: 7.8