Summary
A namespace confusion vulnerability in Traefik's Kubernetes Gateway API provider can cause an HTTPRoute extension reference to resolve against the wrong namespace. A low-privileged route author may then attach a Middleware from a backend Service's namespace and inject trusted reverse-proxy identity headers into downstream requests when cross-namespace routing permissions are present.
Affected context
The issue occurs in Traefik deployments using the Kubernetes Gateway API provider to process HTTPRoutes with backend references and extension references. It becomes risky when a route author can use a ReferenceGrant for a cross-namespace Service, while the provider independently resolves the referenced Middleware using the backend namespace rather than the HTTPRoute namespace.
Exploit preconditions
- Attack surface: Kubernetes Gateway API route configuration processed by Traefik
- Required access: Permission to create or modify an HTTPRoute and access to an applicable cross-namespace Service reference
- Authorization condition: A ReferenceGrant must permit the cross-namespace Service relationship
- Trigger point: Resolution of
HTTPRoute.spec.rules[].backendRefs[].filters[].extensionRef - Why exploitation is possible: Namespace selection for the extension reference is derived from the backend Service instead of the HTTPRoute, allowing authorization boundaries for Middleware references to be bypassed
Why this happens
The underlying bug is an authorization and namespace-resolution mismatch. The provider evaluates an extension reference in the backend Service namespace, even though the HTTPRoute namespace should determine the reference's authorization context. This maps to CWE-863: Incorrect Authorization, because a permission granted for one cross-namespace relationship is incorrectly treated as sufficient for access to another resource.
Potential impact
- Downstream requests may contain attacker-selected or unauthorized trusted identity headers
- Backend services may misidentify the authenticated user, tenant, or originating proxy
- Authorization controls that trust reverse-proxy headers could be bypassed
- Cross-namespace isolation between route authors and Middleware resources may be weakened
- Requests could be routed through unintended security or policy behavior
General mitigation guidance
Mitigation generally focuses on preserving independent authorization checks for every referenced resource and maintaining the correct namespace context throughout resolution.
Common defensive patterns include:
- Resolve extension references using the HTTPRoute namespace and the API object's documented scoping rules
- Require an explicit, separately validated authorization relationship for cross-namespace Middleware references
- Treat identity headers as untrusted unless they are generated and protected by a trusted boundary
- Limit which namespaces and resource kinds route authors may reference
- Apply least-privilege permissions to Gateway API objects and controller identities
- Use secure-by-default policies that deny cross-namespace references unless explicitly allowed
How teams detect issues like this
Organizations can assess this class of issue through:
- Static analysis that compares namespace sources for related API references
- Code review checks requiring each cross-namespace resource relationship to undergo independent authorization
- Tests covering HTTPRoutes, backend Services, Middleware resources, and ReferenceGrant combinations across distinct namespaces
- Admission policies that restrict cross-namespace references and trusted identity-header behavior
- Audit-log analysis for route authors creating cross-namespace references or attaching identity-related Middleware
- Automated security review tools that flag inconsistent namespace resolution and authorization decisions

