Python port of badsectorlabs/copyfail-go (CVE-2026-31431). Linux only; requires Python 3.10+ (os.splice).
This tool does not use the /etc/passwd page-cache trick.
- It overwrites the page cache of the setuid
subinary with embedded shellcode (same payloads as the Gomain.go), then executessu. - Elevation comes from running the corrupted cached image of
suas a setuid root program, not from makinggetpwnam()think your UID is0via/etc/passwd.
Other public Python PoCs for the same CVE may patch /etc/passwd in the page cache and then instruct you to run su <user>. That is a different target file and a different follow-up than this script.
Authorized testing only — use only on hosts you own or are explicitly permitted to assess.
chmod +x copyfail_su.py
# Interactive-style flow (same idea as copyfail-go without --exec)
./copyfail_su.py --backup /tmp/su.bak
# Run another program elevated (passes path as argv to su; uses exec-argv1 payload)
./copyfail_su.py --backup /tmp/su.bak --exec /full/path/to/binaryAfter a successful run, restore the real su.
The PoC corrupts the page cache for /usr/bin/su. Do not assume the on-disk file is still trustworthy until you verify or reinstall.
-
Reinstall the package that owns
/usr/bin/su(find it first, then reinstall):- RPM family:
rpm -qf /usr/bin/suthensudo dnf reinstall shadow-utils(use the reported package name). - Debian/Ubuntu:
dpkg -S /usr/bin/suthensudo apt install --reinstall <package>.
- RPM family:
-
Verify:
sudo rpm -V <package>for unexpected changes to/usr/bin/su, ordebsumson Debian-style systems. -
Optional: reboot after reinstall to avoid stale cache assumptions.
-
If you cannot reinstall as root: recovery boot, Live USB, or replace
/usr/bin/sufrom a known-good same distro/version/arch image; ensure ownershiproot:rootand mode4755(-rwsr-xr-x).