Addressing the Latest Kubernetes NGINX Ingress Controller CVE-2024-7646 Vulnerability
Updated Anudeep Nalla

CVE-2024-7646 is a high-severity annotation validation bypass in the Kubernetes ingress-nginx controller. Anyone allowed to create Ingress objects can inject commands and obtain the controller’s credentials, which by default can read all Secrets in the cluster. Upgrade to v1.11.2 or v1.10.4. Until then, a Kyverno policy can block the risky annotations.
CVE-2024-7646 at a glance
| Field | Detail |
|---|---|
| CVE | CVE-2024-7646 (NVD, Kubernetes advisory) |
| Component | ingress-nginx controller |
| Severity | High, CVSS 3.1 base score 8.8 (AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H) |
| Affected | Controller versions before v1.10.4, and v1.11.0 to v1.11.1 |
| Fixed | v1.11.2 and v1.10.4 |
| Mitigation in this post | Upgrade, then enforce a Kyverno policy that disallows the server-snippet annotation, limits auth-tls-verify-client values and checks the controller image version |
What is CVE-2024-7646?
Attackers can exploit this vulnerability by injecting malicious annotations that bypass security checks. This can lead to severe consequences, such as command injection granting attackers control over the entire cluster. These malicious annotations can also disrupt the ingress-nginx controller’s operations, causing service outages and degraded performance. This vulnerability also exposes sensitive credentials and secrets, allowing attackers to access and exfiltrate them.
CVE-2024-7646 underscores critical aspects of Kubernetes security: the need for solid validation mechanisms to secure annotations, the importance of protecting the software supply chain given the widespread use of essential components like ingress-nginx, and the value of adopting a zero trust architecture to mitigate risks from both internal and external threats.
With a CVSS v3.1 base score of 8.8, this vulnerability threatens the confidentiality, integrity and availability of affected systems. Treat it as a top priority. Apply patches promptly, monitor systems closely and protect sensitive data and resources in your Kubernetes environments.
How do you fix CVE-2024-7646?
To resolve the CVE-2024-7646 vulnerability in Kubernetes environments using ingress-nginx, it’s critical to take immediate steps:
- Upgrade Ingress-NGINX: The most effective measure is to upgrade ingress-nginx to version 1.11.2 or higher. This version contains the necessary security patches to mitigate the vulnerability, preventing attackers from exploiting the annotation validation bypass.
- Restrict Annotations: Explicitly disallow the nginx.ingress.kubernetes.io/server-snippet annotation to further safeguard your system. This step ensures that no unauthorized or potentially malicious configurations can be injected.
- Enforce TLS Client Verification: Set the auth-tls-verify-client annotation to either ‘on,’ ‘off,’ ‘optional,’ or ‘optional_no_ca’ values. This enforces stricter control over TLS client authentication, reducing the attack surface by ensuring that only correctly authenticated clients can interact with your services.
The Kubernetes advisory also lists v1.10.4 as a fixed release for clusters on the 1.10 line. Ingress-nginx itself is now retired: the Kubernetes project announced that best-effort maintenance would continue only until March 2026, with no releases or security fixes after that.
How does Kyverno help mitigate CVE-2024-7646?
Kyverno is an open-source policy engine built to enforce policies and ensure compliance within Kubernetes environments. For CVE-2024-7646, you can use Kyverno policies to block malicious annotations, restrict access to sensitive resources and prevent unauthorized command execution. This reduces the risk from the vulnerability while you roll out the upgrade.
Nirmata Control Hub (NCH), built on Kyverno, enhances this by providing a centralized, user-friendly interface for policy deployment and enforcement across clusters. To address CVE-2024-7646, NPM allows the implementation of a targeted policy that mitigates the vulnerability and provides a detailed overview of all affected instances across the cluster fleet. This aligns with the Shift-Down approach by applying consistent and automated security measures, ensuring comprehensive protection and oversight at scale.
Using NPM ensures effective policy enforcement and governance, helping organizations quickly address vulnerabilities like CVE-2024-7646 and maintain a strong security posture. Ingress-nginx has had annotation-related CVEs before: see our posts on CVE-2021-25742 and the 2023 ingress-nginx CVEs.
How do you mitigate CVE-2024-7646 at scale?
The following policy verifies that your ingress-nginx is updated to version 1.11.2 or higher, disallows the nginx.ingress.kubernetes.io/server-snippet annotation, and ensures the auth-tls-verify-client annotation is set to ‘on,’ ‘off,’ ‘optional,’ or ‘optional_no_ca.’
apiVersion: kyverno.io/v1 kind: ClusterPolicy metadata: name: enforce-ingress-nginx-controller-version-and-annotation-policy spec: validationFailureAction: Enforce background: true rules: - name: validate-ingress-annotations match: resources: kinds: - Ingress validate: message: "The annotation nginx.ingress.kubernetes.io/server-snippet is not allowed." pattern: metadata: annotations: X(nginx.ingress.kubernetes.io/server-snippet): "" - name: validate-auth-tls-verify-client match: resources: kinds: - Ingress validate: message: "auth-tls-verify-client annotation must be 'on', 'off', 'optional', or 'optional_no_ca'." deny: conditions: any: - key: "{{request.object.metadata.annotations.\"nginx.ingress.kubernetes.io/auth-tls-verify-client\"}}" operator: AnyNotIn value: - "on" - "off" - "optional" - "optional_no_ca" - name: ensure-ingress-nginx-controller-version-pattern match: resources: kinds: - Pod validate: message: "The ingress-nginx controller image version must start with v1.11." pattern: spec: containers: - name: controller image: "registry.k8s.io/ingress-nginx/controller:v1.11.*" - name: deny-lower-ingress-nginx-controller-versions match: resources: kinds: - Pod validate: message: "The ingress-nginx controller image version must be v1.11.2 or greater." deny: conditions: - key: "{{ request.object.spec.containers[?(@.name=='controller')].image }}" operator: AnyIn value: - "registry.k8s.io/ingress-nginx/controller:v1.11.0" - "registry.k8s.io/ingress-nginx/controller:v1.11.1" - "registry.k8s.io/ingress-nginx/controller:v1.10.*" - "registry.k8s.io/ingress-nginx/controller:v1.9.*" - "registry.k8s.io/ingress-nginx/controller:v1.8.*" - "registry.k8s.io/ingress-nginx/controller:v1.7.*" - "registry.k8s.io/ingress-nginx/controller:v1.6.*" - "registry.k8s.io/ingress-nginx/controller:v1.5.*" - "registry.k8s.io/ingress-nginx/controller:v1.4.*" - "registry.k8s.io/ingress-nginx/controller:v1.3.*" - "registry.k8s.io/ingress-nginx/controller:v1.2.*" - "registry.k8s.io/ingress-nginx/controller:v1.1.*" - "registry.k8s.io/ingress-nginx/controller:v1.0.*"
Nirmata Control Hub provides capabilities for deploying and enforcing security policies across Kubernetes clusters, making it an effective tool for addressing vulnerabilities like CVE-2024-7646. Here’s how to use NPM to handle this issue:
- Developing a Security Policy: Create a policy specifically designed to address CVE-2024-7646. This policy should mandate upgrading ingress-nginx to version 1.11.2 or higher, disallow unsafe annotations such as nginx.ingress.kubernetes.io/server-snippet, and ensure the auth-tls-verify-client annotation is set correctly.
- Implement the Policy: Apply the security policy to the clusters that use ingress-nginx, or deploy it across all clusters in your environment to ensure comprehensive protection.
- Automate Policy Enforcement: Nirmata Control Hub will automatically enforce the policy across your clusters, immediately mitigating the vulnerabilities associated with CVE-2024-7646.
- Monitor and Audit: Implement real-time monitoring to ensure policy compliance. NPM will generate detailed audit reports to track policy enforcement, detect deviations, and provide insights into your security status.
- Remediate Non-Compliant Clusters: NPM can automatically address non-compliant clusters by enforcing the policy, ensuring all clusters adhere to the required security measures.
Frequently asked questions
Am I affected by CVE-2024-7646 if I don't run ingress-nginx?
No. The bug is in the ingress-nginx controller only, so clusters without it are not affected. To check, run kubectl get po -A and look for an ingress-nginx-controller pod. The advisory says multi-tenant clusters, where non-admin users have permission to create Ingress objects, are the most exposed, because those users are the ones who can submit the malicious annotations.
How can I tell whether CVE-2024-7646 was exploited in my cluster?
The Kubernetes advisory recommends reviewing your Kubernetes audit logs for Ingress objects created with annotations that contain carriage returns (\r). The nginx.ingress.kubernetes.io/auth-tls-verify-client annotation is the example it gives. If you find evidence of exploitation, the Kubernetes Security Response Committee asks you to report it to [email protected].
What access does an attacker need to exploit CVE-2024-7646?
Permission to create Ingress objects in the networking.k8s.io or extensions API group. No cluster-admin rights or user interaction are needed, and the CVSS vector rates it as network-reachable with low attack complexity and low privileges. That is why limiting who can create Ingress objects, alongside the upgrade, reduces exposure.