
Bash script to assess Linux host exposure to CVE-2026-31431, check kernel module status, apply mitigation by blocking algif_aead, and update kernel packages.
This repository documents a Bash script used to assess exposure to CVE-2026-31431 on Linux hosts, with a focus on Ubuntu, and to apply a simple mitigation by blocking the algif_aead module.
Language versions:
README.mdREADME.pt-BR.mdThe script supports three modes:
--check: collect host information and classify the current status.--mitigate: create a modprobe rule to block the vulnerable module and try to unload it.--update: run kernel package upgrades through apt.CVE-2026-31431, publicly referred to as Copy Fail, is a local privilege escalation vulnerability in the Linux kernel associated with the algif_aead module, which implements the AEAD interface of the kernel userspace crypto API through AF_ALG.
In practical terms, the issue allows a low-privileged local user to abuse a logic flaw in the memory-handling path of this subsystem and escalate the impact to full system integrity compromise. The score published by kernel.org and reflected in the NVD is CVSS 7.8, with vector AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H, meaning the attack requires local execution but has high impact on confidentiality, integrity, and availability.
2017, when an in-place optimization was added to algif_aead.April 22, 2026.Copy Fail and with a public proof of concept, occurred on April 29, 2026.April 1, 2026, before broad end-user disclosure.According to the published technical advisories, the flaw relies on the combination of:
AF_ALG interfacealgif_aead modulesplice()The practical result is the ability for a local process to perform a small controlled write into page-cache-backed pages of readable files. In favorable conditions, that is enough to turn a limited local foothold into root privilege escalation.
The real risk is not simply "running a vulnerable Linux kernel", but allowing low-trust local code to reach this kernel path. In enterprise environments, that usually means higher exposure on:
If an attacker already has some form of local execution, even without root, this CVE can become the next step toward host compromise. In practice, that expands the risk of:
algif_aead module is used foralgif_aead is part of the kernel userspace crypto interface (AF_ALG). It allows applications to use kernel cryptographic primitives over sockets, especially AEAD operations (Authenticated Encryption with Associated Data).
This module is usually not essential for most standard server workloads. According to the mitigation guidance published by CERT-EU, disabling algif_aead as a temporary mitigation:
dm-crypt or LUKSkTLSIPsec/XFRMOpenSSL, GnuTLS, NSS, or SSH in standard useOn the other hand, disabling it may affect:
afalg engineAF_ALG sockets directlyaead, skcipher, or hash through the kernel crypto APIIn other words, for most corporate hosts, blocking the module tends to have low impact. In appliances, custom cryptographic stacks, or heavily optimized software paths, the impact should be validated before rollout.
Blocking the module reduces exposure immediately, but it comes with trade-offs:
AF_ALG may fail to start or may lose kernel-backed crypto accelerationFor production environments, the safer approach is to apply the mitigation in a controlled maintenance window and validate critical applications afterward.
Blacklisting the module is only a temporary mitigation. The permanent fix is:
Additional recommended measures:
AF_ALG socket creation with seccomp in containers and pipelines where applicableafalg or the kernel crypto API is explicitly usedThe script inspects:
/etc/os-releasealgif_aead modulemodprobe rule/var/run/reboot-required)pro fix CVE-2026-31431 --dry-run, when availableBased on that, it returns one of the following classifications:
PATCHED_OR_NOT_AFFECTEDLIKELY_NOT_VULNERABLEMITIGATEDVULNERABLE_MODULE_LOADEDPOTENTIALLY_VULNERABLEUNKNOWNIn summary:
PATCHED_OR_NOT_AFFECTED.algif_aead module does not exist in the current kernel, the status tends to be LIKELY_NOT_VULNERABLE.MITIGATED.VULNERABLE_MODULE_LOADED.POTENTIALLY_VULNERABLE.modinfomodprobelsmodawkgrephostnameunameapt-get for --updatesudo when running as a non-root userpro optionally, to enrich the analysis on UbuntuIf the script file is named check_cve_2026_31431.sh:
chmod +x check_cve_2026_31431.sh
./check_cve_2026_31431.sh --check
./check_cve_2026_31431.sh --check
Example output:
Host: srv-app-01
OS: Ubuntu 24.04 LTS
Kernel: 6.8.0-58-generic
CVE: CVE-2026-31431
Module exists: 1
Module loaded: 0
Module blocked: 1
Ubuntu affected: yes
Fix available: yes
Reboot required: 0
Status: MITIGATED
Reason: algif_aead exists but is blocked and not loaded
./check_cve_2026_31431.sh --check --json
Example:
{"host":"srv-app-01","os":"Ubuntu 24.04 LTS","kernel":"6.8.0-58-generic","cve":"CVE-2026-31431","module":"algif_aead","module_exists":1,"module_loaded":0,"module_blocked":1,"ubuntu_affected":"yes","fix_available":"yes","reboot_required":0,"status":"MITIGATED","reason":"algif_aead exists but is blocked and not loaded"}
This output is useful for automation, asset inventory, and compliance pipelines.
The --mitigate mode creates the file:
/etc/modprobe.d/disable-algif_aead-CVE-2026-31431.conf
With the following content:
install algif_aead /bin/false
blacklist algif_aead
After that, the script tries to remove the module from memory with:
modprobe -r algif_aead
Usage:
./check_cve_2026_31431.sh --mitigate
If the user is not root, the script will try to use sudo.
The --update mode runs:
apt-get update
apt-get install --only-upgrade -y 'linux-image-*' 'linux-modules-*' 'linux-aws*'
Usage:
./check_cve_2026_31431.sh --update
This mode attempts to upgrade kernel-related packages on Debian and Ubuntu based systems. In other environments, this step may not apply.
./check_cve_2026_31431.sh --help
Output:
Usage: ./check_cve_2026_31431.sh [--check|--mitigate|--update] [--json]
ubuntu_affected and fix_available fields depend on the presence of the pro command.--update step uses Ubuntu and Debian-oriented package patterns and may not cover all custom kernels.--check to assess the host.--mitigate.--update or apply the official vendor update.--check --json to validate the final state and keep evidence.For publication clarity, the script should ideally use a descriptive name such as:
check_cve_2026_31431.sh
Material organized and published with credit to SEC17.
Official website:
https://sec17.com