
Proof-of-concept exploit for CVE-2022-0847 (Dirty Pipe), a Linux kernel race condition enabling unprivileged writes to read-only files and privilege escalation.
A proof-of-concept exploit for CVE-2022-0847 (Dirty Pipe), a Linux kernel vulnerability that allows unprivileged users to write to read-only files.
CVE-2022-0847 affects Linux kernels 5.8 through 5.16. It exploits a race condition in the Linux kernel's pipe implementation to write arbitrary data to read-only file pages that are cached in memory.
/etc/passwd).
├── src/
│ └── exploit.c # Dirty Pipe exploit source code
├── run.sh # QEMU test environment launcher
├── initramfs/ # Root filesystem for testing
├── debugfs.cpio # Compressed initramfs
└── README.md # This file
libelf-dev (for kernel building)gcc ./src/exploit.c -o ./src/exploit -static -pthread
./run.sh
# Inside QEMU shell:
/home/exploit
cat /etc/passwd # Verify password hash was written
su root # Switch to root (no password needed after exploit)
./src/exploit
The exploit modifies /etc/passwd to inject a root user with a known password hash.
The exploit works by:
PIPE_BUF_FLAG_CAN_MERGE flagssplice() to connect a file page to the pipe bufferThis allows writing to read-only memory pages without triggering COW (Copy-on-Write).
/proc/self/mem if possibleThis exploit is for educational and authorized security testing purposes only. Unauthorized access to computer systems is illegal.
Minh Vu ([email protected])