Summary
Ingress-nginx incorrectly trusts the nginx.ingress.kubernetes.io/auth-method annotation, allowing crafted values to inject configuration into the underlying nginx process.
In clusters where attackers can create or modify Ingress objects, this misvalidation can lead to arbitrary code execution in the ingress-nginx controller and exposure of Kubernetes Secrets accessible to that controller.
Affected context
The vulnerability affects Kubernetes clusters using ingress-nginx where:
- The controller processes user-controlled Ingress resources
- The
nginx.ingress.kubernetes.io/auth-methodannotation is honored to configure authentication behavior - Ingress objects may be created or updated by less-trusted tenants, namespaces, or automation
In typical default setups, the ingress-nginx controller has broad or cluster-wide access to Kubernetes Secrets, increasing the blast radius of a compromise.
Exploit preconditions
- Attack surface: Kubernetes API surface exposed to parties who can create or modify Ingress resources.
- Required access: Ability to define or update an Ingress with a controlled
nginx.ingress.kubernetes.io/auth-methodannotation in a namespace managed by the affected ingress-nginx controller. - Trigger point: Reconciliation and reload of nginx configuration by the ingress-nginx controller after processing the malicious annotation.
- Why exploitation is possible: The annotation value is not sufficiently validated or constrained before being translated into nginx configuration, allowing configuration injection and eventual code execution in the controller context.
Why this happens
The root cause is improper input validation (CWE-20) in how ingress-nginx interprets the nginx.ingress.kubernetes.io/auth-method annotation and transforms it into nginx configuration directives.
Instead of treating annotation values as untrusted data with strict, enumerated options or robust syntax checking, the controller effectively passes user-supplied values into the nginx configuration layer.
This configuration-injection pathway breaks the intended abstraction between Kubernetes API objects and the underlying web server, enabling attackers to smuggle directives that can be abused to execute code or access sensitive resources.
Potential impact
- Execution of arbitrary code within the ingress-nginx controller Pod.
- Theft or exposure of Kubernetes Secrets that the controller is permitted to read, potentially cluster-wide.
- Unauthorized access to TLS private keys and credentials used by Ingress resources.
- Lateral movement from the ingress-nginx controller into other workloads or cluster components.
- Service disruption through manipulated nginx configuration leading to outages or traffic hijacking.
General mitigation guidance
Mitigation generally focuses on tightening trust boundaries around annotations and reducing controller blast radius:
- Constrain Ingress annotations to a safe, finite set of values for fields like
auth-method, using strict schema validation and defensive parsing. - Treat all annotation content as untrusted input and avoid directly mapping arbitrary strings into server configuration directives.
- Apply least-privilege principles to the ingress-nginx controller ServiceAccount, granting only the Secrets and resources it strictly needs.
- Segregate high-risk, multi-tenant namespaces behind dedicated ingress controllers with reduced privileges to limit cross-tenant impact.
- Use admission controls or policy engines to enforce annotation allowlists and to block unsafe or unknown annotation patterns.
How teams detect issues like this
Effective detection usually combines configuration analysis, runtime monitoring, and policy enforcement:
- Use policy engines (e.g., admission controllers, OPA/Gatekeeper, Kyverno) to flag or block Ingress resources containing non-approved or unusual
auth-methodvalues. - Employ static configuration scanning of cluster manifests and Git repositories to identify risky ingress-nginx annotations and configuration-injection patterns.
- Monitor ingress-nginx controller logs and nginx error logs for unexpected configuration reloads, syntax anomalies, or directives that fall outside standard templates.
- Regularly review RBAC bindings and Secret access patterns for the controller's ServiceAccount to detect over-privileged configurations.
- Integrate automated security review tools into CI/CD pipelines to highlight unsafe usage of powerful annotations before deployment.

