Miggo Logo

CVE-2024-21626:
runc vulnerable to container breakout through process.cwd trickery and leaked fds

8.6

CVSS Score

Basic Information

EPSS Score
-
Published
1/31/2024
Updated
2/20/2024
KEV Status
No
Technology
TechnologyGo

Technical Details

CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:C/C:H/I:H/A:H
Package NameEcosystemVulnerable VersionsFirst Patched Version
github.com/opencontainers/runcgo>= 1.0.0-rc93, <= 1.1.111.1.12

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability (CVE-2024-21626) in runc stems from internal file descriptor (FD) leaks and improper handling of container configurations (process.cwd, process.args) that could leverage these leaked FDs. The analysis of the provided patches identified several key functions that were vulnerable:

  1. Functions that directly leaked file descriptors: libcontainer/cgroups.prepareOpenat2 (missing O_CLOEXEC for /sys/fs/cgroup handle), libcontainer/cgroups/fs.tryDefaultCgroupRoot (missing dir.Close() for /sys/fs/cgroup), and the anonymous action function for main.updateCmd (missing f.Close() for a config file).
  2. Functions that failed to prevent FD leaks into critical child processes: libcontainer.(*linuxContainer).start did not set O_CLOEXEC on non-stdio FDs before spawning runc init.
  3. Functions that processed potentially malicious inputs derived from these leaked FDs:
    • libcontainer.finalizeNamespace did not validate that process.cwd was inside the container, allowing a leaked host FD path to grant host filesystem access.
    • libcontainer.(*linuxStandardInit).Init and libcontainer.(*linuxSetnsInit).Init did not close all leaked FDs before execve, allowing a process.args[0] path constructed with a leaked host FD to execute/overwrite host binaries.

The patches address these issues by ensuring FDs are closed or marked O_CLOEXEC, and by adding validation for the container's working directory. The identified functions represent the locations where the vulnerabilities manifested, either by causing the leaks or by failing to handle the consequences of such leaks, thereby enabling the described container escape scenarios.

Vulnerable functions

Only Mi**o us*rs **n s** t*is s**tion

WAF Protection Rules

WAF Rule

### Imp**t In run* *.*.** *n* **rli*r, *u* to *n int*rn*l *il* **s*riptor l**k, *n *tt**k*r *oul* **us* * n*wly-sp*wn** *ont*in*r pro**ss (*rom `run* *x**`) to **v* * workin* *ir**tory in t** *ost *il*syst*m n*m*sp***, *llowin* *or * *ont*in*r *s**p

Reasoning

T** vuln*r**ility (*V*-****-*****) in run* st*ms *rom int*rn*l *il* **s*riptor (**) l**ks *n* improp*r **n*lin* o* *ont*in*r *on*i*ur*tions (`pro**ss.*w*`, `pro**ss.*r*s`) t**t *oul* l*v*r*** t**s* l**k** **s. T** *n*lysis o* t** provi*** p*t***s i**