Severity:

HIGH RISK

(8.8)

Improper Input Validation in Kubernetes ingress-nginx

CVE-2026-3288

Analyzed

Vulnerability type

Category:

Improper Input Validation

CWE:

CWE-20

Impact:

Remote Code Execution and Secret Disclosure

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 validation flaw in ingress-nginx allows the nginx.ingress.kubernetes.io/rewrite-target annotation to inject attacker-controlled configuration fragments into the generated nginx config.

Under certain configurations, this can lead to arbitrary code execution within the ingress-nginx controller pod and exposure of Kubernetes Secrets that the controller can access, which may include all cluster-wide Secrets in default setups.

Affected context

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

  • Ingress objects are created or modified by users or services that may not be fully trusted.
  • The nginx.ingress.kubernetes.io/rewrite-target annotation is honored and not restricted.
  • The ingress-nginx controller has broad permissions to read Kubernetes Secrets (commonly all Secrets in the cluster by default).

The issue arises during the translation of Ingress resources into nginx configuration, where annotation values are merged into the config without sufficiently strict validation of allowed content.

Exploit preconditions

  • Attack surface: Kubernetes API surface for creating or updating Ingress resources using ingress-nginx.
  • Required access: Ability to create, update, or control Ingress objects in a namespace serviced by the ingress-nginx controller (via Kubernetes credentials, compromised CI/CD, or misconfigured multi-tenancy).
  • Trigger point: Application of an Ingress manifest that uses a malicious nginx.ingress.kubernetes.io/rewrite-target value, which the controller then renders into the nginx configuration and reloads.
  • Why exploitation is possible: Annotation values are treated as configuration snippets without robust syntactic and semantic validation, allowing an attacker to escape the intended value context and inject arbitrary nginx directives that can execute commands or exfiltrate data available to the controller.

Why this happens

The root cause is improper input validation (CWE-20) of user-controlled configuration metadata in Kubernetes Ingress resources.

The ingress-nginx controller takes the nginx.ingress.kubernetes.io/rewrite-target annotation, assumes it is a benign path rewrite value, and interpolates it into nginx configuration templates.

Because the content is not constrained to a strict grammar or escaped safely, attackers can craft values that break out of the expected directive value and introduce new nginx directives or configuration blocks.

This configuration injection can be chained into command execution (for example, via nginx modules or misused directives) and makes it possible to read or forward Kubernetes Secrets that are accessible to the controller.

Abstractly, this is a configuration injection flaw stemming from mixing untrusted metadata with privileged infrastructure configuration without enforcing a minimal, well-specified input format.

Potential impact

  • Remote code execution in the security context of the ingress-nginx controller pod.
  • Unauthorized reading and exfiltration of Kubernetes Secrets that the controller can access (potentially all cluster-wide Secrets).
  • Lateral movement by using exposed credentials (e.g., cloud provider keys, database passwords, service account tokens).
  • Compromise of applications behind the ingress via tampered routing, header injection, or malicious response handling.
  • Disruption of traffic by forcing misconfiguration, denial-of-service, or redirecting requests to attacker-controlled endpoints.

General mitigation guidance

Mitigation focuses on tightening the trust boundary around Ingress metadata and constraining how annotations are processed into configuration:

  • Constrain annotation semantics: Treat nginx.ingress.kubernetes.io/rewrite-target as data, not config; accept only safe patterns (e.g., validated URL paths) and reject or normalize anything that does not match a strict regex or schema.
  • Introduce strict templating boundaries: Ensure that annotation values cannot break out of their intended configuration context by robust quoting, escaping, and avoiding direct concatenation of untrusted strings into configuration directives.
  • Harden RBAC and multi-tenancy: Limit who can create or modify Ingress resources, especially in shared clusters; avoid granting cluster-wide write access to Ingress in multi-tenant environments.
  • Reduce controller privileges: Apply least-privilege to the ingress-nginx controller's Kubernetes permissions, restricting it to only the Secrets it truly needs rather than all cluster Secrets.
  • Use policy enforcement layers: Apply admission controllers or policy engines (e.g., validating webhooks, policy-as-code) to disallow dangerous or overly flexible annotations in Ingress manifests.
  • Segregate critical workloads: Run highly sensitive applications behind separate ingress controllers or in isolated clusters where annotation-driven configuration is more tightly controlled.

How teams detect issues like this

Effective detection requires both code-centric and cluster-centric approaches:

  • Static analysis and code review: Examine ingress-nginx code and Helm templates for patterns where annotation values are interpolated directly into nginx configuration without strong validation or escaping; flag any string concatenation into config templates.
  • Configuration and policy checks: Use admission controllers or policy tools to scan Ingress manifests for suspicious nginx.ingress.kubernetes.io/rewrite-target values (e.g., containing newline characters, semicolons, or directive-like tokens).
  • Runtime configuration inspection: Periodically inspect rendered nginx configuration in controller pods to detect unexpected directives or anomalous blocks that can be traced back to specific Ingress resources.
  • Log monitoring and anomaly detection: Monitor ingress-nginx logs and Kubernetes audit logs for unusual Ingress creation patterns, frequent config reloads, or anomalous requests that might indicate configuration injection attempts.
  • Automated security review: Integrate automated configuration linters and policy-as-code tools into CI/CD for Kubernetes manifests to prevent unsafe annotation usage before deployment.

Sources

SourceLink
github.comgithub.com/kubernetes/kubernetes/issues/137560
openwall.comopenwall.com/lists/oss-security/2026/03/09/8
github.comgithub.com/bvabhishek/CVE-2026-3288-lab

Frequently asked

questions

It is indirectly exploitable. An external attacker needs a path to influence or control Ingress definitions (for example, by compromising a developer account, CI/CD pipeline, or tenant with permissions to create Ingress objects). Once they can create or modify an Ingress, they can exploit the annotation to inject configuration.

The attacker must be able to create or update Ingress resources in a namespace managed by the ingress-nginx controller. This typically requires Kubernetes API credentials with write access to Ingress objects, which may be held by application teams, automation systems, or compromised service accounts.

The safest pattern is to treat all user-controlled configuration metadata as untrusted input and strictly validate it against a minimal, well-defined grammar before using it in privileged configuration generation. That includes enforcing tight constraints on annotation values, robust escaping, and avoiding any mechanism that lets arbitrary strings be interpreted as configuration directives.

Prevent them by designing controllers and operators with clear trust boundaries, applying least-privilege to Kubernetes RBAC, and enforcing policies on high-impact fields such as ingress annotations. Combine secure-by-default templates, strong input validation for any configuration derived from user objects, and admission policies that block unsafe patterns before they reach critical infrastructure components.

Find out what's already
exploitable in your codebase.