GHSA-fgjj-px3w-67xx Traefik: Gateway API route identity collision allows cross-namespace backend hijacking
SummaryThere is a high severity vulnerability in Traefik's Kubernetes Gateway API provider. Router and service identities for `HTTPRoute`, `GRPCRoute`, `TCPRoute` and `TLSRoute` objects were built by hyphen-concatenating the route namespace, the route name, the Gateway identity, the entry point and the rule index, a construction that is not injective because Kubernetes names may themselves contain hyphens. Two distinct Routes attached to the same Gateway with equivalent match rules can therefore produce the same identity, and the Route loaded later silently overwrites the earlier one, so a tenant able to create an accepted Route in a colliding namespace/name combination can redirect another namespace's traffic to a backend it controls. All Traefik v3 minor lines are affected; the lines older than v3.6 are no longer maintained and will not receive a patch of their own, so users running them should upgrade to a maintained, patched release.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 Kubernetes Gateway provider constructs internal HTTPRoute and
GRPCRoute identities by concatenating namespace, route name, Gateway identity,
entrypoint, and rule index with hyphens. Kubernetes names may themselves
contain hyphens, so the construction is not injective.For example, HTTPRoutes `team/a-app` and `team-a/app`, attached to the same
Gateway with the same match rule, produce identical router and service keys.
During configuration merging, the route loaded later overwrites the earlier
route's maps. A tenant that can create an accepted Route in a colliding
namespace/name combination can therefore redirect another namespace's
traffic to an attacker-controlled backend.The official v3.7.8 binary was reproduced returning the victim backend before
the second Route was created and the attacker backend immediately afterward.
The victim Route had the earlier creation timestamp and should win the
equivalent-match conflict under Gateway API precedence rules.DetailsThe HTTPRoute provider creates a route key as follows:`Normalize` replaces non-alphanumeric runs with `-`, but it does not encode
field lengths or otherwise preserve component boundaries:These distinct objects therefore have the same normalized key:`makeRouterName` adds a hash of the routing rule. When the attacker copies the
victim's hostname and path, that hash is also identical. Child service and
middleware names are derived from the same parent identity.Each Route is built into a temporary configuration and then merged into the
provider-wide configuration with `maps.Copy`:`maps.Copy` replaces an existing value for a duplicate key. No collision is
reported, and the resulting router points to the later Route's backend. The
GRPCRoute implementation uses the same delimiter-free route-key format and
the same HTTP configuration merge path.Attack prerequisitesThe attacker needs permission to create or modify an HTTPRoute or GRPCRoute
that the shared Gateway accepts. Exploitation also requires namespace and
Route names whose concatenation collides with a victim. The attacker does not
need permission to read or modify the victim Route, Service, or namespace.Proof of ConceptPrerequisites:a disposable Kubernetes cluster with Gateway API v1.5.1 experimental CRDs;`kubectl` configured for that cluster;curl;local TCP port 18080 available.The following script embeds all objects used by the reproduction. It runs the
official `traefik:v3.7.8` image, creates the victim Route first, verifies the
victim backend, then creates the colliding attacker Route and repeats the
request.Expected output on v3.7.8:The first Route is older, but creating the second Route changes existing
victim traffic to the attacker backend. The same test was also run with the
official standalone v3.7.8 Linux amd64 binary inside an isolated k3s cluster.
The release archive had SHA-256
`dbd809b1de85d86d0718c80bedbaabd9aebaa3c6697f9e986ab5f387f4196cb7`.ImpactIn a shared Gateway deployment, a Route author can hijack requests belonging
to another namespace when the object names admit a collision. Requests,
credentials, authorization headers, and response data can be delivered to an
attacker-controlled backend. The attacker can also return forged application
content or accept state-changing requests intended for the victim. The
favorable naming relationship and accepted shared Gateway are reflected in
the high attack-complexity rating.
CVSS v3.1 score: 8.2