
CTF challenge deploying CVE-2022-0847 (Dirty Pipe) exploit to overwrite read-only files. Includes setup scripts, hints, and verification for kernel exploitation practice.
For this challenge, you want to overwrtie the "cat.txt" read-only file using CVE-2022-0847 exploit There are many way to do it using the exploit
Check file cat.txt is read-only file
The limitations are: the attacker must have read permissions (because it needs to splice() a page into a pipe) the offset must not be on a page boundary (because at least one byte of that page must have been spliced into the pipe) the write cannot cross a page boundary (because a new anonymous buffer would be created for the rest) the file cannot be resized (because the pipe has its own page fill management and does not tell the page cache how much data has been appended)
Create a pipe.
Fill the pipe with arbitrary data (to set the PIPE_BUF_FLAG_CAN_MERGE flag in all ring entries).
Drain the pipe (leaving the flag set in all struct pipe_buffer instances on the struct pipe_inode_info ring).
Splice data from the target file (opened with O_RDONLY) into the pipe from just before the target offset.
Write arbitrary data into the pipe; this data will overwrite the cached file page instead of creating a new anomyous struct pipe_buffer because PIPE_BUF_FLAG_CAN_MERGE is set.
Overwrite the cat.txt, change the
I'm a cat
1444
to
I'm a dog
2025
Use check_cat.sh to check if it work or not chmod +x check_cat.sh ./check_cat.sh
Use following chmod +x cat_generate.sh ./cat_generate.sh
Hints are in hints.txt