/CVE-2024-21626

PoC and Detection for CVE-2024-21626

CVE-2024-21626

Exploit

Exploit via Running a Container

Don't need to build a custom image, just run a container with -w parameter:

docker run -w /proc/self/fd/8 --name cve-2024-21626 --rm -it debian:bookworm

exploit via running a container

Exploit via Execing into a Running Container

Exploit via execing into a running container

How to detect

The exploits have the following characteristics:

  • A container will execve(2) a process with a special working directory which starts with /proc/self/fd/.
  • A container will create symbolic links via symlink(2) or symlinkat(2) with a special target directory link which starts with /proc/self/fd/.
  • A container will open files via open(2), openat(2) or openat2(2) with filenames like /proc/\d+/cwd/.*.

Leaky vessels dynamic detector from synk

https://github.com/snyk/leaky-vessels-dynamic-detector

Falco

Here is the custom Falco rule:

- macro: container
  condition: (container.id != host and container.name exists)

- rule: CVE-2024-21626 (runC escape through /proc/[PID]/cwd) exploited
  desc: >
    Detect CVE-2024-21626, runC escape vulerability through /proc/[PID]/cwd.
  condition: >
    container and ((evt.type = execve and proc.cwd startswith "/proc/self/fd") or (evt.type in (open, openat, openat2) and fd.name glob "/proc/*/cwd/*") or (evt.type in (symlink, symlinkat) and fs.path.target startswith "/proc/self/fd/")) and proc.name != "runc:[1:CHILD]"
  output: CVE-2024-21626 exploited (%container.info evt_type=%evt.type process=%proc.name command=%proc.cmdline target=%fs.path.targetraw)
  priority: CRITICAL

But filtering false positives with proc.name is not a good idea.

detect exploits with Falco

References