Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
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.

FeedsContactPrivacyΒ© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2026-31431 β€” Exploit and detector for a Linux kernel local privilege escalation (CVE-2026-31431) that corrupts page cache to gain root, with mitigation guidance. | Kitploit
Tools/GitHubGitHub/kaleth4/cve-2026-31431
Privilege EscalationExploit FrameworksVulnerability AnalysisExploitationPenetration Testing
GitHubkaleth4/cve-2026-31431

CVE-2026-31431

Exploit and detector for a Linux kernel local privilege escalation (CVE-2026-31431) that corrupts page cache to gain root, with mitigation guidance.

View Repository
135 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: Copy Fail

A critical 9-year-old flaw in the Linux kernel that allows obtaining root access in seconds


πŸ“‹ Executive Summary

AttributeDetails
CVECVE-2026-31431
NicknameCopy Fail
TypeLocal Privilege Escalation (LPE)
CVSS7.8 (High)
Discovered byTheori (Xint Code)
DisclosureApril 29, 2026
ComponentLinux kernel algif_aead subsystem

⚑ Why is it so dangerous?

🎯 Speed

  • Instant exploit: < 1 second to obtain root
  • Python script of only 732 bytes

πŸ‘» Absolute Stealth

  • Modifies only RAM memory (page cache), not disk
  • File integrity tools do not detect it
  • After reboot, the trace disappears (forensic analysis compromised)

🌍 Massive Scope

  • Affects practically all modern distributions
  • Kernels from v4.14 (2017) to v7.0-rc
  • Vulnerable for 9 years without being detected

☁️ Cloud/Kubernetes Risk

  • Allows container escape to the host node
  • Page cache is shared between host and containers
  • Critical impact in multi-tenant environments

πŸ” Technical Details

Root Cause

Flaw in the "in-place operation" optimization introduced in 2017 (commit 72548b093ee3). It allows a local user to perform a controlled 4-byte write directly into the kernel's page cache.

Exploitation Mechanism

  1. The attacker uses the AF_ALG interface to access kernel cryptographic algorithms
  2. Corrupts the in-memory version of setuid binaries (/usr/bin/su) or sensitive files (/etc/passwd)
  3. By executing the corrupted binary, obtains a root shell

Why it went unnoticed

It is a logical design bug, not a memory overflow. It required deep analysis of the cryptographic subsystem to detect it.


πŸ“Š Affected Systems

βœ… Confirmed

  • Ubuntu: 20.04, 22.04, 24.04 LTS
  • RHEL/AlmaLinux/Rocky Linux: All modern versions
  • Debian: All versions with kernel v4.14+
  • Amazon Linux 2023
  • SUSE: Recent versions

πŸ›‘οΈ Remediation Plan

1️⃣ Definitive Solution: Update the Kernel

# Ubuntu/Debian
sudo apt update
sudo apt upgrade
sudo reboot

# RHEL/AlmaLinux/Rocky
sudo dnf update kernel
sudo reboot

# Verify kernel version
uname -r

⚠️ Reboot is mandatory to activate the new kernel.


2️⃣ Emergency Mitigation (without immediate reboot)

For Ubuntu/Debian:

# Disable loading of the vulnerable module
echo "install algif_aead /bin/false" | sudo tee /etc/modprobe.d/copyfail_mitigation.conf

# Unload the module if already in use
sudo rmmod algif_aead

For RHEL/AlmaLinux:

# The module is usually built into the kernel
# Add boot parameter to disable it
sudo grubby --update-kernel=ALL --args="initcall_blacklist=algif_aead_init"

# Reboot to apply changes
sudo reboot

3️⃣ Clear Caches (if you suspect prior exploitation)

# Purge page cache on the fly
sudo sysctl -w vm.drop_caches=3

⚠️ Note: This does not replace the patch. It is only a complementary measure.


πŸ“… Event Timeline

DateEvent
April 29Public disclosure by Theori
May 1First active exploitation attempts detected
May 2CISA orders US federal agencies to patch before May 15
May 3Patches available in Ubuntu, RHEL, AlmaLinux, Debian

πŸ“¦ Patch Status

DistributionStatusReference
Ubuntuβœ… PatchedUSN-8226-1 (20.04, 22.04, 24.04)
RHEL/AlmaLinux/Rockyβœ… AvailableSince May 1
Debianβœ… In security repositoriesUpdate available
Android⏳ Coming soonJune 2026 security bulletin

πŸ” Verify Your System

Is your kernel vulnerable?

# Get kernel version
uname -r

# Vulnerable if:
# - v4.14 to v7.0-rc (released between 2017 and April 2026)
# - Contains commit 72548b093ee3

# Check if the algif_aead module is loaded
lsmod | grep algif_aead

# If it appears in the list, your system is vulnerable

🧬 Security Analysis: The AI Factor

The most disruptive: Discovered by AI in 1 hour

An AI identified this flaw that went unnoticed by developers for 9 years. This marks a before and after:

  • πŸ€– Machines can audit kernel code faster than humans
  • πŸ” Finding complex logical flaws automatically
  • ⚠️ Implications for the future of 0-day research

Quick start

# 1. Detect
python3 prueba.py
#   exit 0 = not vulnerable, 2 = vulnerable, 1 = test error

# 2. Exploit (interactive β€” su will prompt for your own password)
python3 exploit.py --shell

Detector usage

python3 prueba.py

What it does:

  1. Confirms that AF_ALG and the algorithm authencesn(hmac(sha256),cbc(aes)) are accessible from an unprivileged process.

  2. Creates a 4 KiB sentinel file in a temporary directory and fills the page cache.

  3. Sends 8 bytes of in-line AAD via sendmsg+cmsg with seqno_lo set to the PWND marker, then copies 32 bytes from the sentinel's page cache page into the AF_ALG operation socket via os.splice().

  4. Calls recv() to initiate decryption. The authentication check fails with EBADMSG; the temporary write is performed anyway.

  5. Re-reads the file (page cache, not disk) and looks for the marker.

Output classes:

  • Precondition not met: AF_ALG or authencesn not available. Exit 0.
  • VULNERABLE to CVE-2026-31431: the PWND marker was inserted into the modified page.

Exit 2.

  • Page cache MODIFIED via an in-place AEAD insertion path: the page was written to, but the marker was not inserted at the expected position. Treat as vulnerable. Exit 2.
  • Page cache intact: patched. Exit 0.

The detector never modifies /usr/bin/su, /etc/passwd, or any other file outside the temporary directory it creates, and that file is removed upon completion.

Exit. ## LPE usage

python3 exploit_cve_2026_31431.py # Only patches, prints next steps
python3 exploit_cve_2026_31431.py --shell # Patches and runs `su <user>`

Function:

  1. Looks up the running user's UID line in /etc/passwd and finds the

byte offset of the 4-character UID field.

  1. Performs a write4 at that offset, replacing the UID with

0000.

  1. Calls pwd.getpwnam(user) to confirm that libc now reports UID 0.
  2. With --shell, runs execvp("su", ["su", user]). Enter your own password. PAM validates against /etc/shadow (unmodified), then

setuid(getpwnam(user).pw_uid) is set to 0.

Requirements

  • The running user has a 4-digit UID (1000–9999). 1- to 3-digit UIDs

require multi-shot writes; extend write4 accordingly.

  • No NSS cache daemon (nscd, sssd, systemd-userdbd) is masking /etc/passwd reads. If getpwnam still returns the real UID after the patch is applied, restart or ignore the cache, or select a different user.

  • The /etc/passwd page must remain in cache between applying the patch and running su. In practice, this is reliable on any system with normal memory pressure.

Reversion

The /etc/passwd file on disk remains unchanged.

The dry run (exploit_cve_2026_31431.py without --shell) automatically removes the corrupted page upon exit via POSIX_FADV_DONTNEED, so UID β†’ name lookups return to normal immediately.

After using --shell**, the page remains corrupted until cleared. While corrupted, any operation that resolves UID 1000 β†’ name (e.g., ls, file managers, scp/sftp ownership checks) will fail or show numeric identifiers. To clear it:

# Without privileges: request page cache eviction for /etc/passwd:
python3 -c "import os; fd=os.open('/etc/passwd', os.O_RDONLY); \
os.posix_fadvise(fd, 0, 0, os.POSIX_FADV_DONTNEED); os.close(fd)"

# From the root console:
echo 3 > /proc/sys/vm/drop_caches

A reboot also clears it.

How write4 works

Download Tool