Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2026-31431-Copy-Fail — 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. | Kitploit
Tools/GitHubGitHub/sec17br/cve-2026-31431-copy-fail
Vulnerability AnalysisConfiguration AuditingIncident Response
GitHubsec17br/cve-2026-31431-copy-fail

CVE-2026-31431-Copy-Fail

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.

View Repository
213 months agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

CVE-2026-31431 - Verification and Mitigation Script

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:

  • English: README.md
  • Portuguese: README.pt-BR.md

The 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.

About the vulnerability

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.

When it was introduced and disclosed

  • The exploitable root cause was introduced into the kernel in 2017, when an in-place optimization was added to algif_aead.
  • The CVE was published in the NVD on April 22, 2026.
  • Broader public disclosure of the issue, under the name Copy Fail and with a public proof of concept, occurred on April 29, 2026.
  • The main upstream fix was committed on April 1, 2026, before broad end-user disclosure.

What it exploits

According to the published technical advisories, the flaw relies on the combination of:

  • the kernel AF_ALG interface
  • the algif_aead module
  • an in-place operation optimization introduced in 2017
  • chaining this interface with splice()

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.

How this affects the company

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:

  • multi-user servers
  • jump hosts and bastions
  • CI/CD runners
  • containerized workloads running untrusted code
  • Kubernetes clusters
  • VMs hosting automation, agents, plugins, or third-party jobs

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:

  • full server takeover
  • modification of local binaries or artifacts
  • theft of credentials, tokens, and resident secrets
  • lateral movement to other assets
  • sabotage of pipelines and build chains

What the algif_aead module is used for

algif_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:

  • should not affect dm-crypt or LUKS
  • should not affect kTLS
  • should not affect IPsec/XFRM
  • should not affect OpenSSL, GnuTLS, NSS, or SSH in standard use

On the other hand, disabling it may affect:

  • applications explicitly configured to use the afalg engine
  • software that opens AF_ALG sockets directly
  • custom integrations that use aead, skcipher, or hash through the kernel crypto API

In 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.

Operational impact of disabling the module

Blocking the module reduces exposure immediately, but it comes with trade-offs:

  • applications that depend on AF_ALG may fail to start or may lose kernel-backed crypto acceleration
  • custom workloads may fail only at runtime, not at boot
  • if the module is already loaded, the mitigation is only complete after a successful unload or a reboot

For production environments, the safer approach is to apply the mitigation in a controlled maintenance window and validate critical applications afterward.

Recommended permanent fix

Blacklisting the module is only a temporary mitigation. The permanent fix is:

  1. install a patched kernel provided by the distribution vendor
  2. reboot the host so the new kernel is actually loaded
  3. validate that the host is no longer reported as affected
  4. only then decide whether the module blacklist should remain in place

Additional recommended measures:

  • prioritize patching on hosts with local users, containers, or untrusted code execution
  • restrict AF_ALG socket creation with seccomp in containers and pipelines where applicable
  • review where afalg or the kernel crypto API is explicitly used
  • maintain inventory of kernel versions and pending reboots
  • treat CI/CD runners and Kubernetes nodes as high priority

What the script checks

The script inspects:

  • host hostname
  • running kernel version
  • operating system via /etc/os-release
  • presence of the algif_aead module
  • whether the module is currently loaded
  • whether the module is blocked by a modprobe rule
  • whether the host requires a reboot (/var/run/reboot-required)
  • status reported by Ubuntu Pro through pro fix CVE-2026-31431 --dry-run, when available

Based on that, it returns one of the following classifications:

  • PATCHED_OR_NOT_AFFECTED
  • LIKELY_NOT_VULNERABLE
  • MITIGATED
  • VULNERABLE_MODULE_LOADED
  • POTENTIALLY_VULNERABLE
  • UNKNOWN

Classification logic

In summary:

  • If Ubuntu tooling indicates that the host is not affected or is already fixed, the status becomes PATCHED_OR_NOT_AFFECTED.
  • If the algif_aead module does not exist in the current kernel, the status tends to be LIKELY_NOT_VULNERABLE.
  • If the module exists but is blocked and not loaded, the status becomes MITIGATED.
  • If Ubuntu indicates the host is affected and the module is loaded, the status becomes VULNERABLE_MODULE_LOADED.
  • If the module exists and is loadable but patch state cannot be confirmed, the status becomes POTENTIALLY_VULNERABLE.

Requirements

  • Bash
  • modinfo
  • modprobe
  • lsmod
  • awk
  • grep
  • hostname
  • uname
  • apt-get for --update
  • sudo when running as a non-root user
  • pro optionally, to enrich the analysis on Ubuntu

Usage

If the script file is named check_cve_2026_31431.sh:

root@kitploit:~
chmod +x check_cve_2026_31431.sh
./check_cve_2026_31431.sh --check

Default check

root@kitploit:~
./check_cve_2026_31431.sh --check

Example output:

root@kitploit:~
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

JSON output

root@kitploit:~
./check_cve_2026_31431.sh --check --json

Example:

root@kitploit:~
{"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.

Mitigation

The --mitigate mode creates the file:

root@kitploit:~
/etc/modprobe.d/disable-algif_aead-CVE-2026-31431.conf

With the following content:

root@kitploit:~
install algif_aead /bin/false
blacklist algif_aead

After that, the script tries to remove the module from memory with:

root@kitploit:~
modprobe -r algif_aead

Usage:

root@kitploit:~
./check_cve_2026_31431.sh --mitigate

If the user is not root, the script will try to use sudo.

Update

The --update mode runs:

root@kitploit:~
apt-get update
apt-get install --only-upgrade -y 'linux-image-*' 'linux-modules-*' 'linux-aws*'

Usage:

root@kitploit:~
./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.

Help

root@kitploit:~
./check_cve_2026_31431.sh --help

Output:

root@kitploit:~
Usage: ./check_cve_2026_31431.sh [--check|--mitigate|--update] [--json]

Important limitations

  • The script uses heuristics. It does not prove exploitation; it estimates exposure and mitigation state.
  • The ubuntu_affected and fix_available fields depend on the presence of the pro command.
  • The --update step uses Ubuntu and Debian-oriented package patterns and may not cover all custom kernels.
  • On some distributions, the module may exist with behavior that differs from what the script expects.
  • Blocking the module may require a reboot in some environments to guarantee a consistent state.

Recommended workflow

  1. Run --check to assess the host.
  2. If the module is available and no patch is applied, run --mitigate.
  3. Run --update or apply the official vendor update.
  4. Reboot the host if required.
  5. Run --check --json to validate the final state and keep evidence.

Note

For publication clarity, the script should ideally use a descriptive name such as:

root@kitploit:~
check_cve_2026_31431.sh

Credits

Material organized and published with credit to SEC17.

Official website:

  • https://sec17.com
Download Tool