
Bash scripts to detect and mitigate CVE-2026-31431 (Copy Fail) Linux kernel local privilege escalation via AF_ALG socket, including module disabling and seccomp configuration.
This project provides a set of Bash scripts for detecting and mitigating CVE-2026-31431 (also known as "Copy Fail"), a Linux kernel local privilege escalation vulnerability.
a664bf3d603d and subsequent patchesThis vulnerability exists in the AF_ALG socket implementation of the Linux kernel. Attackers may achieve local privilege escalation by crafting specific authencesn bind operations.
| File | Purpose | Run Privilege |
|---|---|---|
check_cve_2026_31431.sh | Vulnerability impact detection and risk assessment | Normal user or root |
cve-2026-31431-mitigate.sh | Execute mitigation measures (disable module, generate seccomp config) | Requires root |
bash check_cve_2026_31431.sh
The script checks the following items one by one:
CONFIG_CRYPTO_USER_API_AEAD statusalgif_aead / af_alg module load statusauthencesn bind verification (to determine whether mitigation is already applied)Finally, it outputs an overall risk level: UNKNOWN / LOW / MEDIUM / HIGH.
Note: The mitigation script requires root privileges to run.
sudo bash cve-2026-31431-mitigate.sh
Mitigation operations include:
/etc/modprobe.d/disable-algif-aead.conf to block loading of the algif_aead modulermmod) the algif_aead module if it is already loadeddepmod -a to update module dependenciessudo bash cve-2026-31431-mitigate.sh --verify-only # Verify only, do not write configuration
sudo bash cve-2026-31431-mitigate.sh --write-seccomp # Additionally generate Docker seccomp configuration
sudo bash cve-2026-31431-mitigate.sh --seccomp-path /path # Specify seccomp output path
The gold standard for determining whether mitigation is effective: authencesn bind fails.
The "Check Item 5: Mitigation Verification (bind authencesn)" in the detection script attempts to execute:
import socket
s = socket.socket(38, 5, 0) # AF_ALG
s.bind(("aead", "authencesn(hmac(sha256),cbc(aes))"))
CONFIG_CRYPTO_USER_API_AEAD=y (statically compiled into the kernel), module disabling methods usually do not work; only a kernel upgrade will help.algif_aead is currently in use, rmmod may fail to unload it. It is recommended to verify after a reboot during a maintenance window.socket(AF_ALG) calls.a664bf3d603d and subsequent patches.The scripts have been tested in the following environments:
grep, sed, lsmod, modprobe, rmmod, depmod)python3 or python (for AF_ALG socket verification)MIT License
The scripts provided in this project are intended for security detection and temporary mitigation only and cannot replace official kernel patch upgrades. Please fully understand the operations they perform (such as disabling kernel modules) before using these scripts, and verify them in a test environment first. The author is not responsible for any direct or indirect losses caused by the use of this tool.