How Wiz found a Critical NVIDIA AI vulnerability: Deep Dive into a container escape (CVE-2024-0132)
A time-of-check/time-of-use flaw in the NVIDIA Container Toolkit allowed a malicious container image to mount the host's root filesystem into the container. An attacker could then access host files and, via the Docker socket, launch a privileged container to fully compromise the host.
Published on wiz.io
In September of last year, Wiz Research uncovered a critical security vulnerability, tracked as CVE-2024-0132, in the widely used NVIDIA Container Toolkit, which provides containerized AI applications with access to GPU resources. Our initial blog post was purposely vague because the vulnerability was under embargo…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a time-of-check/time-of-use race: the toolkit resolved library paths during initialisation but mounted them later, allowing a container-controlled symlink to redirect the mount source outside the container.
Impact
The vulnerability could allow full host compromise, including access to sensitive data and the ability to launch privileged containers; the host filesystem was mounted read-only, but the Docker socket allowed privilege escalation.
What the attacker needed
Control over a container image; NVIDIA Container Toolkit installed; container run with the toolkit
The fix
The issues were fixed in version 1.17.4 of the NVIDIA Container Toolkit.
How it was found
- Start a container with a crafted /usr/local/cuda/compat directory containing a directory and a regular file.
- During the first mount iteration, a planted symlink causes the compat directory to be replaced by the directory.
- In the second iteration, the regular file has become a symlink pointing to the host root.
- The kernel follows the symlink and mounts the host root filesystem into the container.
- Use the mounted host filesystem to access the Docker socket and launch a privileged container.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Containers are meant to keep programs isolated from the rest of the computer. This bug let a specially crafted container trick a helper tool into showing the computer's entire file system inside the container. From there, the attacker could take control of the whole machine.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.