• Severity: CVSS 7.8 (High)
  • Affected: Linux kernel 4.9 – 6.8 (all major distros since 2017)
  • Patched: April 1, 2026 · Exploitation: PoC public since April 29, 2026. python exploit

Introduction

In late April 2026, a vulnerability quietly disclosed in the Linux kernel began circulating across security researchers and communities under the name: CopyFail. At first glance, it didn’t look extraordinary. It was “just” another local privilege escalation bug, something Linux has seen before. But as researchers and engineers dug deeper, a different picture emerged.

This wasn’t a fragile exploit that depended on race conditions or obscure kernel quirks. It was something much simpler, and far more dangerous. 732 bytes of Python. One execution. Root access. And it worked across nearly every major Linux distribution released since 2017.


A Bug That Shouldn’t Have Been This Powerful

Most kernel exploits earn their reputation through complexity. They require precise timing, deep knowledge of memory layouts, or version-specific adjustments. Even then, they tend to be unreliable. CopyFail breaks that pattern completely.

Tracked as CVE-2026-31431, the vulnerability is rooted in a logic flaw inside the Linux kernel’s cryptographic subsystem, specifically in the algif_aead module. According to the official advisory from National Vulnerability Database, the issue stems from unsafe handling of data during authenticated encryption operations.

The origin spans three separate changes across six years. In 2011, authencesn was added to support IPsec’s 64-bit sequence numbers, it used the caller’s destination buffer as scratch space, which was harmless at the time. In 2015, AF_ALG gained AEAD support, and authencesn was converted to the new AEAD interface. In 2017, an in-place optimization was added to algif_aead that chained page cache pages directly into the writable destination scatterlist. None of these changes were dangerous alone. Together, they quietly created a condition that went unnoticed for nearly a decade.


How CopyFail Actually Works

At its core, CopyFail is not exploiting memory corruption in the traditional sense. It’s exploiting perfectly valid kernel behavior that leads to the wrong outcome. The attack begins with a normal, unprivileged user. No special permissions are needed.

From there, the exploit interacts with the Linux crypto API through the AF_ALG interface, which allows user-space programs to request cryptographic operations from the kernel. This interface is widely available and enabled by default on most distributions.

By carefully crafting these requests using the authencesn AEAD template, and combining them with Linux’s zero-copy mechanisms like splice(), the attacker can manipulate how data flows through the kernel. authencesn, an IPsec wrapper uses the destination buffer as scratch space during decryption, writing 4 bytes past its intended output boundary. When the 2017 in-place optimization placed page cache pages in that same writable scatterlist, that scratch write lands directly in the kernel’s cached copy of the target file. What they ultimately gain is surprisingly small: The ability to write just 4 bytes into the Linux page cache.

That might not sound like much. But the page cache is where Linux keeps in-memory copies of files for fast access. It’s what the system actually uses when executing binaries. If an attacker can modify those cached bytes, they can effectively alter how a program behaves, without ever touching the file on disk.

CopyFail exploit chain: from unprivileged user through AF_ALG and authencesn flaw to root access via page cache manipulation

Fig 1: CopyFail exploit chain


Turning 4 Bytes Into Root

This is where CopyFail becomes powerful.

Instead of targeting arbitrary memory, the attacker aims those 4 bytes at a trusted executable, such as /usr/bin/su or another setuid binary. These are programs that run with elevated privileges by design.

Once the cached version of that binary is modified, the next execution uses the altered version from memory. The disk remains untouched. Checksums still match. File integrity tools see nothing wrong. But the system executes something different. And that difference is enough to grant root access. No race conditions. No repeated attempts. No crashes. Just a deterministic path from user to root.


Why It Works Everywhere

One of the most unusual aspects of CopyFail is its universality. Because the bug exists in a core kernel subsystem and not in distribution-specific code, it affects a wide range of environments, from desktops to cloud infrastructure. The same technique works across:

  • Ubuntu
  • Red Hat Enterprise Linux
  • SUSE
  • Amazon Linux

and many others.

This consistency is rare. Most Linux exploits are fragile and require tuning. CopyFail behaves more like a function: given the right input, it produces the same result every time.


The Part That Should Worry You

What makes CopyFail particularly unsettling isn’t just that it works, it’s how quietly it works. The exploit never modifies files on disk. If you image the system afterward, everything appears normal. Hashes match official packages. There’s no obvious sign of tampering.

Even persistence is subtle. The malicious change lives only in memory. A reboot clears it. Heavy memory pressure can evict it. From a forensic standpoint, that makes post-incident analysis significantly harder. And then there’s the container problem.

Because the Linux page cache is shared across the entire host, containers offer no protection here. A process running inside a container can potentially manipulate cached files used by the host itself.

In practical terms, that means:

  • A compromised container can escape to the host
  • A malicious CI job can gain root on the runner
  • A shared server user can take over the entire system

A Vulnerability Born from Optimization

The root cause of CopyFail is almost embarrassingly simple. A performance optimization introduced in 2017 allowed cryptographic operations to occur “in place,” avoiding unnecessary memory copies. Over time, that change propagated through kernel versions and distributions.

Individually, the code changes seemed harmless. Together, they created a condition where the kernel could be tricked into modifying file-backed memory in unsafe ways. When the issue was finally identified, the fix was straightforward: remove the unsafe behavior and revert to a safer model.

According to National Vulnerability Database, patched kernels eliminate these in-place operations and restore proper data isolation.


Timeline of Disclosure

The discovery and disclosure of CopyFail moved relatively quickly once identified:

  • March 23, 2026 – Reported to the Linux kernel security team
  • April 1 – Patch committed to mainline kernel
  • April 22 – CVE assigned
  • April 29 – Public disclosure

For a bug that lived nearly a decade, the response window was short, but the risk remains for unpatched systems.


Mitigation and Hardening

The primary fix is simple: update to a patched kernel that includes the upstream fix.

For systems that cannot be patched immediately, there are temporary mitigations. Disabling the vulnerable module (algif_aead) removes the attack surface entirely, and restricting access to the AF_ALG interface can further reduce exposure.

In environments that run untrusted code, such as CI pipelines, containers, or shared compute platforms, it’s worth reconsidering whether user-space access to kernel crypto APIs is needed at all. In most cases, it isn’t.


What CopyFail Changes

CopyFail is a reminder that the most dangerous vulnerabilities aren’t always the most complex ones.

It didn’t rely on obscure tricks or deep memory corruption. It relied on a logical assumption that turned out to be wrong. And because that assumption existed in widely used code, the impact spread quietly across the entire ecosystem.

It also highlights a broader shift: modern kernel features, especially those exposed to user space, are expanding the attack surface in subtle ways. Each new interface adds power, but also risk.


Final Thoughts

Linux remains one of the most robust and widely trusted operating systems in the world. CopyFail doesn’t change that. But it does reinforce something important: even mature systems can carry hidden flaws for years, especially when those flaws don’t cause obvious failures.

What makes CopyFail stand out is not just its impact, but its elegance. A tiny, deterministic exploit that works everywhere is rare, and when it appears, it demands attention. If you’re running Linux systems today, the takeaway is simple:

Patch your kernel.

Because sometimes, four bytes are all it takes.


References