Overview
Copy Fail (CVE-2026-31431) is a Linux kernel privilege escalation vulnerability. In short, it allows an ordinary user—with no write permission on any file—to temporarily corrupt the in-memory (page cache) representation of files that should be untouchable, then achieve arbitrary code execution and obtain root privileges. Nothing on disk changes; the attack lives entirely in memory.
Key Background Mechanisms
1. Page cache
To avoid slow disk I/O, the kernel caches file contents in physical memory pages. Programs often read from these cached copies rather than the disk. If the cached copy is modified while the disk file stays intact, the system still executes the corrupted content.2. setuid trust model
setuid binaries run with the privileges of their owner (usually root). Examples likepasswd must write to root-only files such as /etc/shadow. The model's security rests on the assumption that normal users cannot modify the binary on disk—Copy Fail attacks exactly this assumption by poisoning the cached image instead.3. splice() zero-copy
splice() moves data inside the kernel without copying: it attaches page cache pages directly to a pipe's pipe_buffer structures, which hold only references to struct page. Downstream consumers operate on the original page cache pages—not a private copy.4. AF_ALG and AEAD
AF_ALG is a socket address family letting user programs hand data to the kernel crypto framework for hashing, encryption, and authenticated encryption. The exploit targets AEAD (Authenticated Encryption with Associated Data), where plaintext/ciphertext is encrypted and associated data (AD) is authenticated in the clear.5. algif_aead's in-place optimization
A 2017 performance optimization allowed input and output to share the same buffer, assuming the caller's buffer is writable. When the buffer comes fromsplice(), it actually points to a read-only page cache page—and algif_aead does not check its origin.6. The fatal write in authencesn
The authencesn AEAD template (authenc + extended sequence number, used in IPsec ESP) writes a 4-byte (32-bit) sequence number into the output buffer at an offset roughly equal to AD length plus ciphertext length. Due to in-place handling, that write lands directly on the page cache page. Critically, this write happens before authentication tag verification—even if the kernel returns EBADMSG, the cache is already polluted.Attack Chain
1. Attacker selects a readable, non-writable file—e.g., a setuid binary.
2. splice() connects parts of the file to a pipe; pipe_buffer references page cache pages directly (no copy).
3. Pipe data is submitted via AF_ALG as AEAD input; algif_aead processes it in-place.
4. authencesn writes the 4-byte sequence number into the page cache page. The attacker repeats with different offsets to precisely patch the binary's cached image.
5. The attacker executes the setuid binary. The disk file is unchanged and permissions are intact, but the cached version has been modified—granting root.
The whole process modifies no disk file and touches no permissions: pure in-memory "living off the land."
Mitigation
- Apply the kernel patch: the fix removes the in-place logic in
algif_aead, separating input and output buffers so writes can never land in the (read-only) input buffer. - Interim mitigation: restrict or disable the AF_ALG interface and related modules if upgrading is not immediately possible.
Takeaway
Copy Fail is a reminder that performance optimizations—zero-copy references plus in-place crypto—must respect read-only boundaries and trust models. The wall between an ordinary user and root can be shaken by exactly four bytes.
------