Описание
Traefik: Gateway API route identity collision allows cross-namespace backend hijacking
Summary
There 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.
Patches
- https://github.com/traefik/traefik/releases/tag/v3.6.25
- https://github.com/traefik/traefik/releases/tag/v3.7.10
For more information
If you have any questions or comments about this advisory, please open an issue.
Original Description
Summary
Traefik'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.
Details
The 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 prerequisites
The 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 Concept
Prerequisites:
- a disposable Kubernetes cluster with Gateway API v1.5.1 experimental CRDs;
kubectlconfigured 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.
Impact
In 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.
Ссылки
- https://github.com/traefik/traefik/security/advisories/GHSA-fgjj-px3w-67xx
- https://github.com/traefik/traefik/pull/13580
- https://github.com/traefik/traefik/commit/a764166656f0cd337f917ac76315c381cca844f9
- https://github.com/traefik/traefik/releases/tag/v3.6.25
- https://github.com/traefik/traefik/releases/tag/v3.7.10
Пакеты
github.com/traefik/traefik/v3
>= 3.0.0, < 3.6.25
3.6.25
github.com/traefik/traefik/v3
>= 3.7.0, < 3.7.10
3.7.10
Связанные уязвимости
Traefik is an open source HTTP reverse proxy and load balancer. From 3.0.0 until 3.6.25 and 3.7.10, Traefik's Kubernetes Gateway API provider in pkg/provider/kubernetes/gateway/httproute.go, grpcroute.go, tcproute.go, and tlsroute.go builds HTTPRoute, GRPCRoute, TCPRoute, and TLSRoute router and service identities by hyphen-concatenating namespace, route name, Gateway identity, entry point, and rule index, allowing colliding Routes to overwrite another namespace's backend. This issue is fixed in 3.6.25 and 3.7.10.
Traefik is an open source HTTP reverse proxy and load balancer. From 3.0.0 until 3.6.25 and 3.7.10, Traefik's Kubernetes Gateway API provider in pkg/provider/kubernetes/gateway/httproute.go, grpcroute.go, tcproute.go, and tlsroute.go builds HTTPRoute, GRPCRoute, TCPRoute, and TLSRoute router and service identities by hyphen-concatenating namespace, route name, Gateway identity, entry point, and rule index, allowing colliding Routes to overwrite another namespace's backend. This issue is fixed in 3.6.25 and 3.7.10.
Traefik is an open source HTTP reverse proxy and load balancer. From 3 ...
Уязвимость файлов pkg/provider/kubernetes/gateway/httproute.go, grpcroute.go, tcproute.go и tlsroute.go провайдера Kubernetes Gateway API обратного прокси сервера Containous Traefik, позволяющая нарущителю оказать воздействие на конфиденциальность и целостность защищаемой информации