Severity:

HIGH RISK

(8.8)

Improper Input Validation / Configuration Injection

CVE-2026-4342

Analyzed

Vulnerability type

Category:

Improper Input Validation / Configuration Injection

CWE:

CWE-20

Impact:

Remote Code Execution and Sensitive Data Exposure

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A flaw in ingress-nginx allows specific combinations of Ingress annotations to inject attacker-controlled configuration into the underlying NGINX instance.

When exploited, this can result in arbitrary code execution within the ingress-nginx controller Pod and exposure of Kubernetes Secrets that are accessible to the controller, which in many default deployments includes Secrets across the entire cluster.

Affected context

This vulnerability affects Kubernetes clusters using the ingress-nginx controller where:

  • Application traffic is routed via NGINX Ingress resources, and
  • Users, automation, or CI systems can create or modify Ingress objects and their annotations, and
  • The controller trusts annotation values enough to convert them into NGINX configuration without fully constraining or normalizing them.

The issue is most significant in multi-tenant or shared clusters where different teams or tenants can define Ingress resources that the centralized ingress-nginx controller processes.

Exploit preconditions

  • Attack surface: Kubernetes API exposed for creating/updating Ingress resources interpreted by ingress-nginx.
  • Required access: Ability to create or modify Ingress objects (and their annotations) in a namespace served by the ingress-nginx controller. This normally requires authenticated Kubernetes API access with appropriate RBAC permissions.
  • Trigger point: Processing of crafted Ingress annotations by the ingress-nginx controller during sync/reload, resulting in dangerous NGINX configuration being rendered and applied.
  • Why exploitation is possible: Annotation values are not sufficiently validated or constrained before being translated into NGINX configuration directives, allowing a malicious combination of annotations to break out of expected configuration boundaries and inject attacker-controlled behavior.

Why this happens

At its core, this is an improper input validation (CWE-20) issue applied to configuration data.

The ingress-nginx controller accepts user-supplied Ingress annotations and uses them to generate NGINX configuration. The translation logic assumes annotations follow expected patterns and fails to strictly validate or normalize them against a safe, well-defined schema. As a result:

  • Certain annotation combinations can introduce raw or semi-raw configuration segments into the NGINX template, and
  • The NGINX worker or supporting components may be driven to execute unintended commands or scripts, or to access resources that should not be exposed.

Abstractly, the pattern is: user-controlled metadata is treated as trusted configuration, and the absence of strict validation or safe templating allows that configuration to alter the control flow and privileges of the component processing it.

Potential impact

  • Attacker-controlled execution of code or commands within the ingress-nginx controller Pod context.
  • Exposure of Kubernetes Secrets that are readable by the controller ServiceAccount, which in typical default setups can include:
  • TLS certificates and keys
  • Application credentials and API tokens
  • Other sensitive configuration secrets across multiple namespaces
  • Lateral movement within the cluster by pivoting from ingress-nginx to other workloads or control-plane-facing components.
  • Disruption of incoming traffic routing, including denial of service, response tampering, and forced redirects.
  • Injection of malicious behavior into NGINX (e.g., header rewriting, logging of sensitive data, or internal service endpoint disclosure).

General mitigation guidance

Effective mitigation focuses on reducing trust in annotation input, hardening the controller's configuration surface, and minimizing the blast radius if the controller is compromised.

Configuration and design patterns:

  • Treat Ingress annotations as untrusted input and constrain them through:
  • Strict schema validation (allowed keys, value formats, ranges, and enumerations).
  • Whitelisting of safe directives instead of passing through arbitrary NGINX configuration fragments.
  • Prefer configuration mechanisms that do not allow raw or free-form NGINX config snippets. Use high-level, parameterized options over text-based config injection.
  • Separate "admin-level" configuration from tenant/application-level configuration. Reserve powerful NGINX customization capabilities for tightly-controlled namespaces or operator-owned resources only.

Least privilege and isolation:

  • Run the ingress-nginx controller with the minimal possible RBAC permissions, particularly for reading Secrets. Limit Secret access to only those namespaces and objects necessary for TLS termination and routing.
  • Use distinct ServiceAccounts and roles for ingress-nginx in different environments or trust zones to reduce cross-tenant impact.
  • Apply Pod security hardening for the controller, such as:
  • Dropping unnecessary Linux capabilities,
  • Using non-root users,
  • Restricting host filesystem access,
  • Avoiding host networking unless strictly required.

Operational controls:

  • Limit who can create or modify Ingress resources and annotations via RBAC, admission policies, or namespace-level governance.
  • Use policy engines (e.g., admission controllers) to block unsafe combinations of annotations and enforce annotation allowlists or patterns.

How teams detect issues like this

Detection typically combines configuration analysis, runtime monitoring, and policy enforcement:

  • Static and policy-based checks:
  • Use admission controllers or policy engines to:
  • Deny Ingress resources containing disallowed annotations or suspicious annotation values (e.g., those that embed NGINX snippets or low-level directives).
  • Enforce per-namespace or per-team policies restricting powerful annotation use.
  • Apply static configuration scanning to cluster manifests and Git repositories to flag Ingress definitions using risky annotation patterns.
  • Code and template review:
  • Review ingress-nginx configuration templates and generation logic for:
  • Direct interpolation of annotation values into NGINX configuration.
  • Lack of normalization, escaping, or structural validation on user-supplied metadata.
  • Use static analysis or linters where available to detect unsafe template variable usage and configuration injection sinks.
  • Runtime and log monitoring:
  • Monitor ingress-nginx logs and metrics for abnormal reload patterns, unexpected NGINX errors, or unusual configuration re-renders.
  • Watch for anomalous network connections originating from the ingress-nginx controller Pod, especially to Kubernetes API endpoints or services it does not normally contact.

Sources

SourceLink
github.comgithub.com/kubernetes/kubernetes/issues/137893
openwall.comopenwall.com/lists/oss-security/2026/03/19/9

Frequently asked

questions

Indirectly. An external attacker typically needs a path to create or modify Ingress resources (for example, via a compromised CI system, exposed deployment automation, or stolen Kubernetes credentials). Once they can influence annotations on an Ingress interpreted by ingress-nginx, they can attempt to exploit the configuration injection behavior.

The attacker must be able to interact with the Kubernetes API in a way that lets them create or update Ingress objects with chosen annotations. In many clusters, this corresponds to namespace-level write or admin permissions for applications, which may be granted to multiple teams or automated systems.

The most robust fix is to ensure annotation values are treated as untrusted, strictly validated, and mapped only to a constrained set of safe configuration options. Avoid mechanisms that let user-controlled data be interpolated directly into low-level NGINX configuration, and separate powerful configuration capabilities from general application-level Ingress definitions.

Design configuration pipelines so that user- or tenant-controlled metadata never becomes raw configuration for privileged components. Implement schema-based validation, explicit allowlists for configuration keys and values, strong RBAC around who can set powerful options, and policy enforcement in CI/CD and admission control. Regular reviews of controller templates and config-generation logic help catch new injection paths early.

Find out what's already
exploitable in your codebase.