CVE-2023-5043 Overview
CVE-2023-5043 is an annotation injection vulnerability in Kubernetes ingress-nginx that enables arbitrary command execution. Attackers with permission to create or modify Ingress objects can inject malicious content through the nginx.ingress.kubernetes.io/configuration-snippet annotation. The injected content is rendered into the underlying NGINX configuration, allowing execution of arbitrary commands in the context of the ingress controller. Successful exploitation exposes the controller's service account credentials, which can be used to access cluster secrets across namespaces. The flaw is tracked under [CWE-20] Improper Input Validation and [CWE-74] Injection.
Critical Impact
Authenticated attackers with Ingress write permissions can execute arbitrary commands inside the ingress-nginx controller and steal its service account token, leading to cluster-wide secret disclosure.
Affected Products
- Kubernetes ingress-nginx controller (versions prior to the fixed releases listed in the upstream advisory)
- Kubernetes clusters using ingress-nginx with the default --allow-snippet-annotations setting enabled
- NetApp products bundling vulnerable ingress-nginx builds (see NetApp advisory ntap-20240307-0012)
Discovery Timeline
- 2023-10-25 - CVE-2023-5043 published to the National Vulnerability Database (NVD)
- 2023-10-25 - Public disclosure via the Kubernetes Security Announcement and Openwall OSS Security discussion
- 2024-03-07 - NetApp publishes downstream advisory ntap-20240307-0012
- 2025-02-13 - Last updated in NVD database
Technical Details for CVE-2023-5043
Vulnerability Analysis
The ingress-nginx controller translates Kubernetes Ingress objects into NGINX configuration directives. The nginx.ingress.kubernetes.io/configuration-snippet annotation allows users to inject raw NGINX configuration into the generated nginx.conf. The controller does not adequately sanitize this annotation value before rendering it into the configuration template. An attacker who can create or update an Ingress resource can supply crafted annotation content that breaks out of the intended directive scope and adds arbitrary directives, including Lua blocks that execute shell commands. Because the controller runs with a service account that has broad read access to Kubernetes secrets, exploitation typically results in exfiltration of the controller's token and pivoting to other cluster resources.
Root Cause
The root cause is improper input validation and injection ([CWE-20], [CWE-74]) in the handling of the configuration-snippet annotation. User-controlled annotation content is concatenated into NGINX configuration without sufficient escaping or restriction of allowed directives.
Attack Vector
The attack vector is network-based and requires low privileges, specifically the ability to create or modify Ingress objects in any namespace handled by the controller. No user interaction is required. An attacker submits an Ingress manifest containing a malicious configuration-snippet annotation. When the controller reloads its configuration, the injected directives execute inside the ingress-nginx pod, exposing the mounted service account token and any environment data accessible to the controller.
No verified public exploit code is referenced in the advisory. Refer to the GitHub issue #10571 and the Kubernetes Security Announcement for technical details.
Detection Methods for CVE-2023-5043
Indicators of Compromise
- Ingress objects containing the nginx.ingress.kubernetes.io/configuration-snippet annotation with NGINX directives such as access_by_lua_block, content_by_lua_block, or shell metacharacters.
- Unexpected outbound network connections from ingress-nginx-controller pods to attacker-controlled hosts.
- Reads of /var/run/secrets/kubernetes.io/serviceaccount/token inside the ingress controller pod outside of normal controller operation.
- Kubernetes audit log entries showing create or update actions on ingresses.networking.k8s.io from unusual service accounts or users.
Detection Strategies
- Inspect Kubernetes audit logs for Ingress create/update events and alert when the request body contains configuration-snippet, server-snippet, or lua keywords.
- Use admission controllers such as OPA Gatekeeper or Kyverno to reject Ingress objects that include snippet annotations from unauthorized namespaces or service accounts.
- Monitor the ingress-nginx-controller pod for unexpected child processes spawned from the nginx worker, particularly shells or network utilities.
Monitoring Recommendations
- Forward Kubernetes API server audit logs and ingress controller stdout/stderr to a centralized analytics platform for correlation.
- Baseline normal annotations used in your environment and alert on deviations introduced after the disclosure date.
- Track service account token usage from the ingress-nginx service account and alert on access patterns inconsistent with controller behavior.
How to Mitigate CVE-2023-5043
Immediate Actions Required
- Upgrade ingress-nginx to a fixed release as listed in the Kubernetes Security Announcement.
- Set the controller flag --allow-snippet-annotations=false to disable snippet annotations entirely until the upgrade is complete.
- Restrict RBAC permissions so only trusted principals can create or modify Ingress resources.
- Rotate the ingress-nginx service account token and any secrets that may have been exposed if compromise is suspected.
Patch Information
The Kubernetes maintainers released fixed versions of ingress-nginx that validate the configuration-snippet annotation and restrict allowed directives. Consult GitHub issue #10571 and the Kubernetes Security Announcement for the exact fixed versions. Downstream consumers should review the NetApp Security Advisory ntap-20240307-0012 for product-specific patch availability.
Workarounds
- Disable snippet annotations cluster-wide by deploying the controller with --allow-snippet-annotations=false.
- Enforce an admission policy that rejects any Ingress object containing nginx.ingress.kubernetes.io/configuration-snippet or nginx.ingress.kubernetes.io/server-snippet annotations.
- Limit Ingress create/update RBAC verbs to a small set of platform administrators rather than tenant namespaces.
# Disable snippet annotations on the ingress-nginx controller deployment
kubectl -n ingress-nginx set env deployment/ingress-nginx-controller \
POD_NAMESPACE=ingress-nginx
kubectl -n ingress-nginx patch deployment ingress-nginx-controller \
--type=json \
-p='[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--allow-snippet-annotations=false"}]'
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

