Skip to content

Lesson 9 of 14 · 12m

When the Runtime Is the Hole

runc CVE-2019-5736 and CVE-2024-21626 show the tool that builds the boundary leaking across it, and BuildKit made docker build attack surface too.

runc is host code holding a container door

Every namespace and capability check in this course assumes the wall is built correctly. Sometimes it isn't — the runtime itself is a host process that crosses the boundary constantly, and when it mishandles the crossing, the bug is yours. Two runc vulnerabilities define the class.

CVE-2019-5736, disclosed February 11, 2019 by Adam Iwaniuk and Borys Popławski of Twistlock. When you docker exec into a container, runc does execve("/proc/self/exe", ...). Inside the container, /proc/self/exe resolves to the runc binary — the host's runc binary, because that's what the runc process is. A malicious binary planted in the container could hold that /proc/<pid>/exe file descriptor open during the exec and overwrite runc's binary image on the host. Next docker exec, next container start anywhere on the box: attacker's code runs as root on the host. The precondition was an exec into the hostile container — an admin's debugging session, a Kubernetes liveness probe, a CI check — which is to say, an ordinary Tuesday. Docker shipped the fix in 18.09.2 the same day; upstream runc switched to copying itself into a sealed memfd before exec, so there was no host binary left to overwrite.

CVE-2024-21626, part of the "Leaky Vessels" disclosure by Rory McNamara at Snyk, January 31, 2024. runc leaked an open file descriptor into the container across chdir — a container's process.cwd could end up pointing at a directory on the host filesystem (/proc/self/cwd resolved outside the jail), and a second variant leaked a fd during exec. Either way: a running container holding a read-write handle into the host tree. Fixed in runc 1.1.12.

Note the mechanism difference. 5736 was the runtime's own binary being reachable from inside. 21626 was the runtime's own file descriptors leaking inside. Both are boundary-crossing bugs in the tool that builds the boundary — not misconfiguration, not kernel bugs, bugs in the bouncer.

BuildKit: the build is also execution

The same disclosure carried three BuildKit CVEs, and they matter because teams forget that docker build runs attacker code — RUN in a Dockerfile executes — and that the build engine itself has attack surface:

  • CVE-2024-23651 — a race in cache-mount validation let a crafted Dockerfile mount arbitrary host directories into the build container, exposing host files to the build.
  • CVE-2024-23652 — a build-time teardown path let it delete arbitrary host files.
  • CVE-2024-23653 — a checkSecrets endpoint path let a build run arbitrary containers.

All fixed alongside runc 1.1.12 in late January 2024. If you build untrusted Dockerfiles on hosts you care about — a SaaS CI runner, an internal build service — these were the bugs for you.

The shape of runtime risk

Runtime CVEs are rare compared to misconfiguration, but their preconditions are trivial: no privileged flag, no mounted socket, just a version number below the fix. That's also what makes the remediation boring: runc --version, docker version, containerd --version, and patch. Your package manager's container stack is part of your patch surface; a host running Docker 24 with a vendored old runc is a host running the old bug.

The other consequence is for architecture: because the runtime is host code, minimizing how often untrusted workloads make the runtime cross the boundary is real hardening. Fewer execs into hostile containers, builds on isolated hosts, docker exec treated as a privileged operation rather than a convenience.

What to actually do

  • Track runc/containerd/dockerd versions like kernel versions — they're the same category: host code that hostile guests can reach.
  • Don't build untrusted Dockerfiles on shared infra. BuildKit bugs mean docker build is an attack surface even when you never docker run the result.
  • Prefer runtimes that cross the boundary less: rootless modes and sandboxed runtimes (next module) shrink what a runtime bug can reach when the next 5736 shows up.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.