Exploit database

GH-b050e5dda12ccd5bdb023ccf54fa3822

xsanflip/cve-2026-31431-patch

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-31431

166 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files2
xsanflip/cve-2026-31431-patchRevision 655fc60a1f1e

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

patch_copy_fail.sh

Shell · 1,606 bytes
#!/bin/bash

# CVE-2026-31431 (Copy Fail) Mitigation & Patch Script
# Target: Kali Linux / Debian-based systems
# Author: XsanLahci thx to Aurel666 & Jos Ali Joe

if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root (use sudo)."
   exit 1
fi

echo "[+] Starting Mitigation for CVE-2026-31431..."

# 1. Immediate Workaround: Blacklist AF_ALG modules
# This prevents the exploit from creating the malicious socket required.
echo "[*] Blacklisting algif_aead and af_alg modules..."
cat <<EOF > /etc/modprobe.d/blacklist-copyfail.conf
blacklist algif_aead
blacklist af_alg
install algif_aead /bin/false
install af_alg /bin/false
EOF

# Unload the modules if they are currently loaded
modprobe -r algif_aead 2>/dev/null
modprobe -r af_alg 2>/dev/null

# 2. Memory Cleanup: Flush the Page Cache
# The exploit poisons the RAM (Page Cache). We must clear it to restore 
# the integrity of the 'su' binary in memory.
echo "[*] Flushing Page Cache to remove poisoned memory segments..."
sync
echo 3 > /proc/sys/vm/drop_caches

# 3. Permanent Fix: Update Kernel
# Kali has released 6.18.12-1kali1 and newer which contains the official fix.
echo "[*] Checking for official Kali kernel updates..."
apt update
apt install -y linux-image-amd64 linux-headers-amd64

# 4. Verification
echo "[+] Mitigation applied."
echo "[!] IMPORTANT: You MUST reboot your system to load the new kernel."
echo "    After reboot, verify your kernel version with: uname -r"
echo "    The fix is verified in 6.18.12+ or 6.19.x kernels."

read -p "Reboot now? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
    reboot
fi