Exploit databaseDownload repository ZIP
GH-cbca91a310e15759952d223f297f7569
nisec-eric/cve-2026-31431
Sources for CVE-2026-31431
166 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files10
nisec-eric/cve-2026-31431Revision b0a5dc0915bc
- ↑..Parent directory
- copy_fail_rust/
- README.md
- check_vulnerable.py
- copy_fail_exp.c
- copy_fail_exp.go
- copy_fail_exp.py
- copy_fail_exp_alpine.py
- copy_fail_exp_compat.py
- copy_fail_exp_readable.py
- mitigate.sh
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
poc/mitigate.sh
Shell · 4,060 bytes#!/bin/bash
# ============================================================================
# CVE-2026-31431 (Copy Fail) - Mitigation Script
#
# This script applies the recommended mitigations for CVE-2026-31431:
# 1. Blacklists the algif_aead kernel module
# 2. Attempts to unload the module if currently loaded
# 3. Updates initramfs to persist the blacklist across reboots
#
# Usage: sudo bash mitigate.sh
#
# What this breaks: Almost nothing.
# - dm-crypt/LUKS, IPsec, SSH, OpenSSL defaults — all unaffected
# - Only affects applications explicitly using AF_ALG AEAD sockets
#
# Reference: https://copy.fail/
# ============================================================================
set -euo pipefail
echo "============================================"
echo "CVE-2026-31431 (Copy Fail) Mitigation Script"
echo "============================================"
echo ""
# Check root
if [ "$(id -u)" -ne 0 ]; then
echo "[!] This script must be run as root"
exit 1
fi
# Step 1: Blacklist the algif_aead module
echo "[*] Step 1: Blacklisting algif_aead module..."
cat > /etc/modprobe.d/disable-algif.conf << 'EOF'
# CVE-2026-31431 (Copy Fail) mitigation
# Prevents loading of the algif_aead kernel module
# This blocks the page-cache write primitive used by Copy Fail
#
# This does NOT affect: dm-crypt/LUKS, IPsec, SSH, OpenSSL defaults
# Only affects: apps explicitly using AF_ALG AEAD sockets (rare)
#
# Remove this file after updating to a patched kernel (6.18.22+/6.19.12+/7.0+)
blacklist algif_aead
install algif_aead /bin/false
EOF
echo "[+] Blacklist file created: /etc/modprobe.d/disable-algif.conf"
# Step 2: Unload the module if currently loaded
echo ""
echo "[*] Step 2: Attempting to unload algif_aead module..."
if lsmod | grep -q algif_aead; then
if rmmod algif_aead 2>/dev/null; then
echo "[+] Module algif_aead unloaded successfully"
else
echo "[!] Could not unload algif_aead (may be in use)"
echo "[!] Module will be blocked on next reboot"
fi
else
echo "[+] Module algif_aead is not currently loaded"
fi
# Step 3: Update initramfs
echo ""
echo "[*] Step 3: Updating initramfs..."
if command -v update-initramfs &> /dev/null; then
update-initramfs -u
echo "[+] initramfs updated (Debian/Ubuntu)"
elif command -v dracut &> /dev/null; then
dracut -f
echo "[+] initramfs updated (RHEL/CentOS/Fedora)"
elif command -v mkinitcpio &> /dev/null; then
mkinitcpio -P
echo "[+] initramfs updated (Arch)"
else
echo "[!] Could not determine initramfs update tool"
echo "[!] Manually update initramfs for your distribution"
fi
# Step 4: Verify mitigation
echo ""
echo "[*] Step 4: Verifying mitigation..."
echo ""
# Check if module loads
if modprobe algif_aead 2>/dev/null; then
echo "[!] ⚠️ WARNING: algif_aead module loaded despite blacklist!"
echo "[!] The module may be compiled into the kernel (=y, not =m)"
echo "[!] Check: zgrep CONFIG_CRYPTO_USER_API_AEAD /proc/config.gz"
rmmod algif_aead 2>/dev/null || true
else
echo "[+] algif_aead module is blocked (good)"
fi
# Try the AF_ALG socket test
python3 -c '
import socket
try:
s = socket.socket(38, 5, 0)
s.bind(("aead", "authencesn(hmac(sha256),cbc(aes))"))
print("[!] ⚠️ WARNING: AF_ALG AEAD socket still works!")
print("[!] Mitigation may not be fully effective")
print("[!] Check if algif_aead is compiled into kernel (=y)")
s.close()
except (PermissionError, OSError) as e:
print(f"[+] AF_ALG AEAD socket blocked: {e}")
print("[+] Mitigation appears effective")
' 2>/dev/null || echo "[!] Python3 not available for socket test"
echo ""
echo "============================================"
echo "Mitigation complete."
echo ""
echo "Next steps:"
echo " 1. Schedule kernel update to patched version"
echo " 2. For containers: add seccomp profile blocking AF_ALG"
echo " 3. Reboot to ensure clean state"
echo ""
echo "Remove /etc/modprobe.d/disable-algif.conf after kernel update."
echo "============================================"