GHSA-6765-c87h-8mrf Traefik: BasicAuth singleflight key collision allows authenticated identity spoofing
SummaryThere is a low severity vulnerability in Traefik's BasicAuth middleware. Concurrent password verifications are deduplicated through a singleflight group whose key was the delimiter-free concatenation of the submitted password and the stored secret, so a request carrying an unconfigured username — whose secret is empty — can produce the same key as a configured user's valid request and receive that request's successful result. Exploitation requires the attacker to already hold a valid credential **and** to read the stored password hash, which is only reachable through paths that are themselves privileged: the API is documented as admin-only, the Kubernetes path requires read access to the Secret, and the Docker path requires access to the socket. The key now encodes the password length as a prefix, so distinct (password, secret) pairs can no longer collide. Only the v3.6 line from v3.6.11 onwards and the v3.7 line are affected; earlier v3 releases and the v2 line do not carry the vulnerable deduplication path.Patcheshttps://github.com/traefik/traefik/releases/tag/v3.6.25https://github.com/traefik/traefik/releases/tag/v3.7.10For more informationIf you have any questions or comments about this advisory, please [open an issue](https://github.com/traefik/traefik/issues).SummaryTraefik's BasicAuth middleware deduplicates concurrent password checks with a
`singleflight.Group`. Its key is the delimiter-free concatenation
`password + secret`. For an existing user with password `P` and stored hash
`H`, the key is `P || H`. An unknown user can select the password `P || H`;
because its secret is the empty string, its key is also `P || H`.If the existing user's request starts the shared calculation, the unknown
user receives the existing user's successful Boolean result. Traefik then
continues processing the unknown user's original request and propagates the
attacker-selected username through `URL.User`, the access log, and the
configured BasicAuth `headerField`.A user who knows one valid username/password/hash tuple can therefore
authenticate concurrently under any unconfigured username. This becomes a
privilege escalation when a backend uses the BasicAuth `headerField` as a
trusted identity, which is the documented purpose of that option.DetailsThe vulnerable logic is in
`pkg/middlewares/auth/basic_auth.go:118-131`:For a configured user `viewer`:For an unconfigured user `admin`:`singleflight.Group.Do` shares the first in-flight result for equal keys. If
the configured user's check is first, the unknown user's closure is not run
and the unknown request receives `true`.The authorization result is not bound to the username. After the shared
result is accepted, `ServeHTTP` uses the username parsed from the unknown
request:Consequently, the backend sees the attacker-selected `admin` identity, not
the valid request's `viewer` identity.Attack prerequisitesThe attacker needs:network access to a route protected by the affected BasicAuth middleware;one valid low-privilege username and password;the corresponding stored password hash.The hash is often present in deployment labels or routing configuration.
Traefik's API is also a direct source when the attacker can access it:
`GET /api/http/middlewares/{id}` serializes `basicAuth.users`, including the
hash, despite the field carrying `loggable:"false"`. The official v3.7.8
binary returned the hash in the validation environment.The attacker does not need another user's password or a victim-generated
request. The attacker creates both concurrent requests: one with their valid
credentials and one with an arbitrary, unconfigured target username.Security impactWhen `headerField` is configured, an authenticated low-privilege user can
impersonate an arbitrary identity to the backend. Depending on downstream
authorization, this can allow:access to administrative data;execution of privileged state-changing operations;corruption of audit attribution;bypass of identity-based tenant or role separation.Without `headerField`, the unknown request is still admitted through the
BasicAuth middleware. The practical consequence then depends on whether the
protected route treats all authenticated users equally.Proof of ConceptValidation environmentOfficial Traefik v3.7.8 Linux amd64 release.Build timestamp: `2026-07-15T12:42:25Z`.Go version in the release: `go1.26.5`.Archive SHA-256:
`dbd809b1de85d86d0718c80bedbaabd9aebaa3c6697f9e986ab5f387f4196cb7`.The checksum matched the official
`traefik_v3.7.8_checksums.txt` release asset.No Traefik source files were modified.Dynamic configurationThe bcrypt hash below is for password `test` and uses cost 12:Save it as `dynamic.yml`. Use this install configuration as `static.yml`:The API is enabled only to demonstrate that the runtime representation
exposes the configured hash. It is not needed if the tester already knows the
hash from the configuration.Use this backend as `backend.py`; it responds with the identity Traefik puts
in the trusted header:Start the backend and Traefik in separate shells.Shell 1:Shell 2:Exploit clientObserved outputThe negative control proves that `admin` is not configured and cannot
authenticate alone. During the collision, all 25 requests were admitted and
the backend received the forged identity `admin`.The same behavior was first reproduced with Apache MD5. Its much shorter hash
calculation window yielded 2 successful identity forgeries in 100 attempts.
Using normal production-strength bcrypt made the race deterministic in this
environment because the expensive comparison remains in flight long enough
for the second request to join it.ImpactAn attacker with read access to a configured password hash and the ability to
send concurrent requests can authenticate as an unconfigured username. When
`headerField` is enabled, the attacker-selected username is forwarded to the
backend as a trusted authenticated identity, enabling privilege impersonation,
unauthorized data access, unauthorized actions, and incorrect security audit
attribution. Without `headerField`, the request still bypasses BasicAuth and
reaches the protected service.
CVSS v4.0 score: 2.1