Skip to content
Memory corruption Write-up Advanced

Fragnesia: Linux Kernel Local Privilege Escalation via ESP-in-TCP

A logic flaw in the Linux kernel's XFRM ESP-in-TCP handling lets an unprivileged local attacker corrupt file-backed pages in the page cache. By overwriting the first bytes of a setuid binary such as su in memory, the attacker can obtain a root shell.

Merav Bar Follow

Published on wiz.io

Researchers have disclosed a new variant in the DirtyFrag family of Linux local privilege escalation (LPE) vulnerabilities, named “Fragnesia.” The vulnerability impacts the Linux kernel’s XFRM ESP-in-TCP subsystem. The vulnerability allows unprivileged local attackers to modify read-only file contents in the kernel…

Merav Bar, on wiz.io

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 logic flaw in the XFRM ESP-in-TCP code where file-backed pages spliced into a TCP receive queue before the socket switches to espintcp mode are later decrypted in place, so the AES-GCM keystream writes into shared page-cache pages.

Impact

An unprivileged local user could gain root, though AppArmor restrictions on unprivileged user namespaces, as used by default on Ubuntu, may act as a partial mitigation that requires additional bypasses.

What the attacker needed

Local access to the machine; unprivileged user namespaces enabled; AppArmor namespace restriction absent or bypassed

The fix

Vendor kernel patches addressing the XFRM ESP-in-TCP flaw should be applied; until then the esp4, esp6 and rxrpc modules can be disabled and unprivileged user namespaces restricted.

How it was found

  1. Create user and network namespaces to gain CAP_NET_ADMIN inside the isolated namespace.
  2. Install a crafted ESP security association through NETLINK_XFRM.
  3. Splice file-backed pages into a TCP receive queue before the socket enters espintcp mode.
  4. Trigger ESP processing so the queued data is decrypted in place, corrupting the page cache.
  5. Repeat the controlled single-byte writes to overwrite the start of a setuid binary with a small payload.
  6. Run the modified binary to obtain a root shell.

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.

The kernel keeps a copy of files it has recently read in memory, called the page cache, so programs start faster. A bug in how the kernel handles certain encrypted network packets let a normal user write a few bytes into that in-memory copy of a file they should not be able to change. Because the changed file was a program that runs with administrator rights, the attacker could then get a root shell, even though the file on disk stayed the same.

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.

More by Merav Bar

View all

27 more disclosed reports, best first.

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.