The vulnerability, identified as GHSA-5r4w-85f3-pw66, allows an attacker to bypass mutual TLS (mTLS) checks on Traefik routers that use wildcard host rules. The root cause lies in the SNICheck middleware, which is responsible for preventing domain-fronting attacks by ensuring the TLS Server Name Indication (SNI) and the HTTP Host header resolve to the same TLS configuration.
The analysis of the provided patch, specifically commit 34c0abaaf4b3d23213961b3e103beebc8e17de71, reveals that the logic for this check was flawed. The vulnerable implementation, located in pkg/middlewares/snicheck/snicheck.go, used the functions findTLSOptionName and findTLSOptName to look up the TLS options for a given hostname. These functions only performed exact-string lookups and did not have the capability to match a hostname against a wildcard rule (e.g., matching api.example.com to *.example.com).
When an attacker sends a request using a permissive SNI (e.g., public.example.net) to establish the TLS session, and then specifies a Host header for a wildcard-protected domain (e.g., api.example.com), the vulnerable SNICheck fails. It cannot find a matching wildcard rule for api.example.com in its map and incorrectly falls back to the default TLS options. If the permissive SNI also uses default options, SNICheck sees no mismatch and allows the request to proceed, effectively bypassing the stricter mTLS requirement of the wildcard route.
The patch rectifies this by completely redesigning the mechanism. Instead of SNICheck re-simulating the routing logic, the actual TLS option name used during the TLS handshake is now injected into the request's context. The new SNICheck middleware, now attached to each router, simply compares this context value with its own configured TLS option name. This new approach is not susceptible to the wildcard resolution flaw because it relies on the correct routing components to supply the ground truth about the connection's TLS state.