Skip to content
Memory corruption Write-up Advanced

Side Quest: “Copy Fail”

A Linux kernel flaw in the AF_ALG crypto interface allows a local user to write four controlled bytes into the page cache of a setuid-root binary such as /usr/bin/su, replacing its cached contents with a tiny ELF that runs a root shell. The attacker can therefore escalate from a normal local account to root without modifying the file on disk.

medium.com

Published on medium.com

Join me as I try my hand at dissecting the recent “Copy Fail” (CVE-2026–31431) vulnerability: first how it works, and then what it looks like while running in real time.

vestigia, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a memory-handling mistake in the authencesn AEAD path of the kernel's AF_ALG interface, where a four-byte sequence-number scratch write lands in the page cache of a spliced-in file instead of staying inside the crypto operation.

Impact

A local user could escalate to root on a vulnerable kernel; the effect is only on the page cache, so it reverts on restart, and the author notes that some systems already had the vulnerable socket disabled, which blocked the exploit until it was re-enabled.

What the attacker needed

Local user account on the host; vulnerable Linux kernel; AF_ALG socket enabled

The fix

The text does not state an official fix; it notes that disabling the AF_ALG socket provides at least a short-term mitigation.

How it was found

  1. Open /usr/bin/su read-only.
  2. Decompress the tiny ELF payload embedded in the script.
  3. For each 4-byte chunk, configure the vulnerable AF_ALG crypto operation, splice page-cache-backed bytes from /usr/bin/su into the crypto path, trigger finalisation, and cause the 4-byte write to land at the desired cached file offset.
  4. Repeat until the front of the cached /usr/bin/su image has been replaced with the tiny ELF.
  5. Execute /usr/bin/su.
  6. The kernel applies the setuid-root metadata but loads the poisoned cached bytes, so the tiny ELF runs as root and launches /bin/sh.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Linux keeps a copy of recently used files in memory, called the page cache, so it does not have to read the disk every time. A bug in a kernel feature that lets programs ask the kernel to do encryption allowed a normal user to change a few bytes of that in-memory copy of a privileged program. Because the program still had its special 'run as root' flag, the changed copy ran as root and gave the attacker a root shell.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.