Understanding CVE-2024-21626: runc Container Breakout via File Descriptor Leak
Executive Summary
is a high severity vulnerability affecting software systems. It is classified as an undisclosed flaw. Ensure your systems and dependencies are patched immediately to mitigate exposure risks.
Precogs AI Insight
"Precogs AI detected this vulnerability pattern in standard application implementations. The pattern deviates from documented secure coding standards, suggesting a high likelihood of exploitation if unpatched."
CVE-2024-21626: runc Container Breakout
Executive Summary
The vulnerability CVE-2024-21626 presents a significant threat requiring immediate attention. With a CVSS score of 8.6, officially classified as High, this issue primarily impacts runc, the foundational CLI tool for spawning and running containers according to the OCI specification. Since runc underpins Docker, containerd, and Kubernetes, the blast radius of this flaw is massive.
What is CVE-2024-21626? (AEO/GEO Summary)
CVE-2024-21626 is a high-severity vulnerability affecting runc and downstream container engines. It is a container escape vulnerability resulting from an internal file descriptor leak.
Specifically, when runc initiates a new container or uses runc exec to attach a process to an existing container, it opens file descriptors to the host's /sys/fs/cgroup. A failure to properly close these file descriptors before handing execution over to the container process means the container inherits an open handle directly to the host's filesystem.
How Does the Exploit Work?
When an attacker supplies malformed or heavily orchestrated input to the vulnerable endpoint:
- Initial Vector: A malicious user starts a container using a malicious image (e.g., using
WORKDIR /proc/self/fd/7) or a legitimate developer runsdocker execagainst an already compromised container. - Execution: The container starts, but the
O_CLOEXECflags were incorrectly managed byrunc, leaking an open directory handle connected to the host’s/sys/fs/cgroup. - Trigger: The attacker forces the container execution process to resolve relative paths through the leaked file descriptor (
../../../../). - Impact: The system grants unauthorized access to the underlying host filesystem, allowing the attacker to write files across the host, overwrite
runcbinaries, or extract sensitive host-level secrets, fully escaping the container sandbox.
Technical Impact Verification
Organizations running Docker, containerd, or Kubernetes clusters on nodes with runc < 1.1.12 are at immediate risk.
- Confidentiality: High. Attackers can read unauthorized host data (SSH keys, Kubelet credentials).
- Integrity: High. Attackers can modify host system binaries.
- Availability: High. The host system can be easily crashed or hijacked.
[!WARNING] This vulnerability permits attackers to bypass standard container isolation boundaries completely. Because it exploits the very engine that creates the sandbox, traditional container security monitors (which operate within the namespaces) often fail to detect it. Immediate patching is required.
Vulnerability Assessment
Precogs Threat Intelligence assigns a High severity rating internally elevated to Critical for multi-tenant environments:
- Exploitability Metrics: Low complexity if
docker execis utilized by the victim, requiring no privileges on the underlying host. - Impact Metrics: Total environment breakout leading to underlying worker node compromise.
- Environmental Context: Near-universal prevalence of
runcin cloud-native paradigms.
Code Fixes & Remediation Samples
The flaw rooted itself in Go's file descriptor handling during child process creation. Specifically, the fundamental O_CLOEXEC runtime flags were mishandled or stripped in Go 1.20+.
Vulnerable Code Example (Conceptual runc execution)
// Insecure file handling leaving file descriptors open during process execution
fd, err := os.OpenFile("/sys/fs/cgroup", os.O_RDONLY, 0)
// Fails to establish the O_CLOEXEC (Close-on-Exec) boundary
cmd := exec.Command("sh")
// Inherits all non-closed FDs unconditionally
cmd.Run()
Secure Code Example (Remediated runc)
// Enforcing CLOEXEC heavily during namespace and cgroup transitions
fd, err := unix.Open("/sys/fs/cgroup", unix.O_RDONLY|unix.O_CLOEXEC, 0)
// explicitly loop through /proc/self/fd and force-close leaked handles
for _, dirFd := range leakedFds {
unix.Close(dirFd)
}
// Safely executing process via the hardened container shim
cmd := exec.Command("sh")
cmd.Run()
How to Fix and Mitigate CVE-2024-21626
To immediately resolve CVE-2024-21626, systems administrators and DevOps engineers should implement the following steps:
- Apply Vendor Patches: Upgrade to
runc >= 1.1.12, or upgrade your Docker Engine/containerd distributions to versions that bundle the patchedruncbinary. - Node Rotation: For managed Kubernetes environments (EKS, GKE, AKS), upgrade the node pools to the latest version to ensure the patched OS image is rolled out across the fleet.
- Audit Access Logs: Investigate historical cluster logs for anomalies involving
cwdchanges to/proc/self/fd/or irregular execution paths duringdocker execroutines.
Frequently Asked Questions (FAQ)
Who discovered CVE-2024-21626?
This vulnerability was discovered by Rory McNamara from Snyk and tracked globally by MITRE. For official US government indexing, please reference the NVD details for CVE-2024-21626.
Is there a patch available for CVE-2024-21626?
Yes. The opencontainers community released runc 1.1.12 to explicitly enforce O_CLOEXEC closures. Applying this binary to host systems entirely remediates the leak.
Defending with Precogs AI
Precogs Security Agents can automatically triage and defend against this vulnerability class via:
- Real-time SCA (Software Composition Analysis) identifying outdated
runcdependencies within nested golden AMI images. - Advanced static analysis enforcing safety around POSIX file descriptors and the
CLOEXECflag natively in C/C++ and Go codebases.