
Proof-of-concept exploit for CVE-2026-31431, a Linux kernel AF_ALG memory corruption vulnerability. Uses splice to patch /usr/bin/su in page cache, enabling password-less root escalation.
CopyFail is a proof-of-concept exploit for CVE-2026-31431, targeting a memory corruption vulnerability in the Linux Kernel Crypto API (AF_ALG). The exploit leverages the splice system call to perform unauthorized page-cache patching of the /usr/bin/su binary, enabling a password-less escalation to root.
The vulnerability resides in the Linux kernel's handling of zero-copy data transfers between AF_ALG sockets and other file descriptors via splice. Due to improper synchronization or bounds checking in the aead implementation, data processed by the crypto engine can be written back into the source file's page cache.
AF_ALG socket and uses sendmsg to queue a malicious payload in the socket's internal buffers.splice to transfer data from the /usr/bin/su binary into the AF_ALG socket, the vulnerability causes the socket's buffer contents to overwrite the binary's page cache in memory.su with a minimal ELF payload that spawns a root shell. Since the page cache is modified, subsequent executions of su run the attacker's code instead of the original binary.RawSyscall for all kernel interactions.AF_ALG/splice interaction.fmt or os packages).Compile the exploit for the current architecture:
go build -ldflags="-s -w" -o CopyFail CVE-2026-31431.go
Run the compiled binary:
./CopyFail
Upon successful execution, the su binary will be patched in memory and executed, granting a root shell.
The following demonstration shows the exploit being compiled and executed on a standard Kali Linux installation.
# 1. Verify current unprivileged user
kali@kali:~$ whoami
kali
# 2. Compile the exploit
kali@kali:~$ go build -ldflags="-s -w" -o CopyFail CVE-2026-31431.go
# 3. Execute the CopyFail exploit
kali@kali:~$ ./CopyFail
[+] Triggering AF_ALG memory corruption...
[+] Patching /usr/bin/su in page-cache...
[+] Executing patched binary...
# 4. Success: Elevated to root shell
root@kali:/home/kali# id
uid=0(root) gid=0(root) groups=0(root)
root@kali:/home/kali# whoami
root
To mitigate this vulnerability, the following steps are recommended:
af_alg and related modules:
modprobe -r af_alg
auditd) to monitor for suspicious splice calls targeting sensitive system binaries.⚠️ Warning: This tool is for authorized security research and educational purposes only. Patching the page cache is a volatile operation and may cause system instability. The author assumes no liability for misuse.
CVE-2026-31431 ("Copy Fail") was discovered and disclosed by the research team at Theori.
This project is licensed under the MIT LICENSE.