Linux Kernel: Vulnerability in the eBPF verifier register limit tracking
A bug in the eBPF verifier's register limit tracking allowed an attacker to trick the verifier into thinking a register had a different value than it actually would at runtime. Using this, an attacker could gain arbitrary kernel memory read/write, leading to full system compromise.
github.com
Published on github.com
rcorrea35 published GHSA-hfqc-63c7-rj9f Jul 16, 2024
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 mistake in the verifier's range and bit-mask tracking when splitting register states at a conditional branch, causing the minimum and maximum possible values to become inconsistent.
Impact
An attacker with CAP_BPF could gain arbitrary kernel memory read/write and achieve full system compromise.
What the attacker needed
CAP_BPF capability
The fix
The vulnerability was fixed on 06/13/2024 according to the timeline.
How it was found
- Fuzz the eBPF verifier with a modified coverage-guided fuzzer to find a register invariant violation.
- Reduce the fuzzer-generated program to a minimal sequence that triggers the inconsistent register state.
- Craft a program where a register is ORed with a constant and then compared to a constant, causing the verifier to mis-track the register's value.
- Use the mis-tracked register to build an exploit that achieves arbitrary kernel memory read/write.
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 eBPF verifier is a safety checker in the Linux kernel that inspects programs before they run to ensure they cannot access memory unsafely. This report found a flaw in how the verifier tracks the possible values of a register (a small storage slot in the program), letting a malicious program slip past the checks and read or write kernel memory. Exploiting it requires special privileges (CAP_BPF), so it is not available to just any user.
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.