Summary
An improper input validation issue in ingress-nginx allows the rules.http.paths.path Ingress field to inject attacker-controlled configuration into the underlying NGINX configuration.
When exploited, this can lead to arbitrary code execution in the context of the ingress-nginx controller and exposure of Kubernetes Secrets accessible to that controller, including in default setups where it can reach Secrets cluster-wide.
Affected context
The issue affects Kubernetes clusters using ingress-nginx where Ingress resources are translated into NGINX configuration.
It is most relevant in environments where:
- Users or services can create or modify Ingress objects,
- The NGINX configuration generated from Ingress fields is not strictly sanitized or bounded,
- The ingress-nginx controller has broad access to Secrets (such as default cluster-wide access).
Under these conditions, manipulating the rules.http.paths.path field can influence the generated NGINX configuration in unsafe ways.
Exploit preconditions
- Attack surface: Kubernetes API via Ingress resources processed by ingress-nginx.
- Required access: Ability to create or update Ingress objects in a namespace handled by the ingress-nginx controller (e.g., developer, application service account, or compromised workload with sufficient RBAC).
- Trigger point: The ingress-nginx controller reconciles the modified Ingress and regenerates the NGINX configuration, causing the injected directives to be applied.
- Why exploitation is possible: The
rules.http.paths.pathfield is treated as a largely trusted value and incorporated into NGINX configuration without sufficient validation or strict encoding, enabling configuration injection that can be leveraged to execute code or access sensitive data.
Why this happens
The underlying problem is improper input validation and contextual encoding of user-controlled configuration data mapped from Kubernetes Ingress objects to NGINX configuration.
The rules.http.paths.path field, which should represent a constrained HTTP path, is effectively treated as a free-form string and embedded into the generated NGINX configuration.
Because ingress-nginx does not adequately sanitize or restrict this field to a safe subset of characters and patterns, attackers can craft values that break out of the intended context and inject additional NGINX directives.
This aligns with CWE-20: Improper Input Validation, where the software fails to validate inputs against expected format, type, or range, allowing malformed or malicious values to alter program behavior.
Potential impact
- Execution of arbitrary commands or code in the context of the ingress-nginx controller.
- Reading or exfiltration of Kubernetes Secrets that the controller can access, potentially cluster-wide.
- Lateral movement within the cluster by abusing credentials or tokens exposed through the controller.
- Tampering with traffic routing, leading to request interception, redirection, or denial of service.
- Expansion of an initial compromise of a single namespace or service account into broader cluster compromise.
General mitigation guidance
Effective mitigation focuses on constraining input, hardening configuration generation, and limiting blast radius:
- Enforce strict validation on the
rules.http.paths.pathfield so it only accepts well-formed HTTP paths (e.g., disallow control characters, NGINX directive syntax, and unsafe metacharacters). - Treat Ingress-derived values as untrusted and ensure they are safely encoded or quoted before inclusion in template-generated NGINX configuration.
- Apply defense-in-depth RBAC so that only trusted principals can create or modify Ingress resources, and restrict which namespaces or tenants share a controller.
- Reduce the privileges of the ingress-nginx controller by limiting its access to Secrets and other sensitive resources to only what is strictly necessary for TLS and basic operation.
- Use policy engines (such as admission control or configuration policies) to block Ingress objects with suspicious path patterns or disallowed characters.
How teams detect issues like this
Detection commonly involves configuration analysis, policy enforcement, and behavioral monitoring:
- Use static or policy-based analysis (e.g., admission webhooks, OPA/Gatekeeper, Kyverno) to inspect Ingress definitions and reject paths that deviate from expected patterns.
- Perform code or template reviews of ingress-nginx configuration generation logic, looking for places where user-controlled fields are inserted into NGINX configuration without stringent validation or encoding.
- Monitor ingress-nginx logs and controller events for unusual configuration reloads, unexpected errors, or atypical directives appearing in rendered NGINX configs.
- Periodically scan the running NGINX configuration within ingress-nginx pods for injected or unrecognized directives that could indicate abuse.
- Integrate automated cluster security tools that flag over-privileged controllers and anomalous access to Secrets correlated with Ingress changes.

