
eBPF-based runtime detector for container breakout vulnerabilities in runc and Docker, monitoring syscalls and Docker daemon calls to detect exploitation of CVE-2024-21626, CVE-2024-23651, CVE-2024-23652, and CVE-2024-23653 during builds and runtime.
This repository is now archived.
No more updates will be made to the code and it may be insecure or even broken by the time you read this notice. Consider it for historical purpose only and treat it carefully.

In this repository you'll find a reference implementation for an eBPF-based runtime detection for the runc and Docker vulnerabilities CVE-2024-21626, CVE-2024-23651, CVE-2024-23652 and CVE-2024-23653. It hooks into Linux syscalls (e.g., chdir, mount) and function invocations of the Docker daemon and associates them with Docker builds and container processes to identify exploitations of these vulnerabilities.
For a static analysis-based approach, please see this.
CVE-2024-21626 is a vulnerability in the runc container runtime allowing an attacker to break out of the container isolation and achieve full root RCE via a crafted image that exploits an issue within the WORKDIR instruction's handling. Since there's a "race" condition between the time some file descriptors to the host are opened and closed, an attacker can create a Dockerfile with the following instruction WORKDIR /proc/self/fd/[ID] (with ID being a system dependent file descriptor) that will point to the underlying host machine's file system. This can be exploited when running:
docker build - In 2 cases:
FROM instruction that contains an ONBUILD command triggering the exploit e.e. ONBUILD WORKDIR /proc/self/fd/[ID]. The ONBUILD instruction injects the command not in the image that contains it but in the image that uses it as a base image. This means that if a base image is compromised or intentionally nefarious i.e. hosted on Dockerhub or other public container registries, exploitation if possible even if nothing changes in the image that the docker build command actually builds.docker runThus, this vulnerability can put both build systems and production environments at risk.
CVE-2024-23651 is a vulnerability in Docker where a RUN command is using the --mount=cache flag. There's a time-of-check/time-of-use (TOCTOU) vulnerability between the check that a source dir exists on the Docker daemon's host and the actual call to the mount syscall. An attacker is able to craft a Dockerfile that would plant a symlink in between these two calls to induce an arbitrary bind mount that results in full root RCE on the host.
This vulnerability only affects the docker build command.
CVE-2024-23653 is a vulnerability in Docker that occurs when using a custom Buildkit LLB generator is used with the # syntax directive. The generator can use the Client.NewContainer and Container.Start GRPC calls to execute a new container during build. The StartRequest.SecurityMode argument is not appropriately checked against the privilege expectations of the docker daemon or docker build call, which allows the GRPC caller to create a privileged container during build. This new privileged container can then be escaped to gain full root RCE on the build host.
This vulnerability only affects the docker build command.
CVE-2024-23652 is an arbitrary deletion vulnerability in Docker. When RUN --mount is used in a Dockerfile, if the target of the mount does not exist it will be created for that environment. When the execution completes this created directory will be cleaned up. If the executing command changes the path used for the mount to a symbolic link, the cleanup procedure will traverse this symbolic link and potentially clean up arbitrary directories in the host root filesystem.
This vulnerability only affects the docker build command.
The build-time detection applies to all 4 vulnerabilities.
GOOS=linux GOARCH={{amd64/arm64}} go build.sudo (as required by eBPF) in your build environment (i.e., sudo ebpf-detector &).Leaky vessels vulnerability detected printed to STDOUT, alongside the respective CVE, vulnerability name and additional forensics.The run-time detection applies the WORKDIR vulnerability only (CVE-2024-21626).
Dockerfile and push it to an image registry.image value in the detector.yaml (marked with TODO).kubectl apply -f detector.yml.Leaky Vessels vulnerability detected printed in the DaemonSet pod logs.Unit tests need to run in sudo, as they rely on eBPF: sudo go test ebpf-detector/....
WORKDIR exploitation (CVE-2024-21626) happens during container initialization, so it won't be detected on running containers. The detection also assumes the container runtime is containerd.CVE-2024-23651) and Buildkit Build-time Container Teardown Arbitrary Delete (CVE-2024-23652) detections are timing-based and may have false negatives due to race conditions.For updated list of bugs and issues see the project issues.
Contributions are welcome. See CONTRIBUTING.md for details.
The Leaky Vessels Dynamic Detector is under the Apache-2.0 license. See LICENSE for more information.