Summary
A namespace authorization flaw in Traefik's Kubernetes Ingress provider allows a tenant outside the configured cross-provider namespace allowlist to attach an operator-owned middleware through a Service annotation. If that middleware adds backend credentials, the tenant may recover those credentials when traffic reaches a controlled backend.
Affected context
The issue can occur in Traefik deployments using the Kubernetes Ingress provider and the traefik.ingress.kubernetes.io/service.middlewares Service annotation. It becomes risky when namespace restrictions are intended to prevent tenant-owned resources from referencing operator-managed middleware, but that annotation path is not subject to the same restriction.
Exploit preconditions
- Attack surface: Kubernetes Service resources processed by Traefik's Ingress provider
- Required access: Permission for a namespace-limited tenant to create or modify a Service and its annotations
- Trigger point: Traefik processing the Service middleware annotation while configuring routed traffic
- Why exploitation is possible: The annotation reference can bypass the intended
crossProviderNamespacesrestriction and resolve middleware from an otherwise unauthorized namespace
Why this happens
The underlying bug is an incomplete authorization check on a resource-reference path. Traefik applies namespace restrictions to some cross-provider references but fails to enforce them consistently for the Service middleware annotation, allowing a less-trusted tenant to select an operator-owned middleware. This behavior maps to CWE-639: Authorization Bypass Through User-Controlled Key, because a user-controlled namespace and resource reference determines access to a protected object without adequate authorization enforcement.
Potential impact
- Operator-managed middleware may be attached to tenant-controlled services
- Backend credentials injected by the middleware may be disclosed
- Sensitive requests or responses could be exposed to a controlled backend
- Tenant isolation boundaries may be weakened
- Compromised credentials could enable further access to protected services
General mitigation guidance
Mitigation generally focuses on enforcing authorization consistently across every resource-reference path and reducing trust in tenant-controlled annotations.
Common defensive patterns include:
- Apply namespace allowlists to Service middleware references before resolving or attaching resources
- Use secure-by-default policies that deny cross-namespace references unless explicitly approved
- Restrict which tenants can create or modify annotations interpreted by ingress controllers
- Avoid placing reusable credential-injecting middleware in namespaces reachable by untrusted tenants
- Run backends and middleware with least privilege and narrowly scoped credentials
- Review existing references for unauthorized operator-owned middleware attachments
How teams detect issues like this
Organizations can identify this class of issue through:
- Static analysis and authorization tests covering every annotation-to-resource resolution path
- Code review checks for inconsistent enforcement of namespace or tenant boundaries
- Kubernetes admission policies that restrict middleware references to approved namespaces
- Controller audit logs correlating tenant-owned Services with operator-owned middleware
- Runtime alerts for cross-namespace references that fall outside approved policy
- Automated security review tools that flag user-controlled resource identifiers without matching authorization checks

