KernelSnitch: Leaking Kernel Heap Pointers by Exploiting Software-Induced Side-Channel Leakage
Description
KernelSnitch is a novel, hardware-agnostic software side-channel attack targeting Linux kernel hash tables. It allows unprivileged users to leak kernel heap pointers, such as the mm_struct, in under a minute by analyzing timing differences in syscall execution.
KernelSnitch: Breaking KASLR with Software-Induced Timing Side Channels
Introduction
In the world of kernel exploitation, achieving stability is often the greatest challenge. Traditional exploits often rely on memory corruption vulnerabilities to leak information, a process that risks crashing the system and alerting administrators. But what if you could leak sensitive kernel heap pointers without ever triggering a memory safety bug? This is the premise of KernelSnitch, a groundbreaking research project presented by Lukas Maar and Jonas Juffinger at Black Hat Asia.
KernelSnitch demonstrates a "software-induced" side-channel attack that targets the heart of the Linux kernel: its hash tables. By measuring the minute timing differences in how the kernel processes hash collisions, an unprivileged user can bypass Kernel Address Space Layout Randomization (KASLR) and leak the location of critical structures like the mm_struct in under a minute. This blog post dives deep into how this attack works, its implications for modern security, and why it remains a difficult problem for kernel maintainers to solve.
Background & Context
Modern operating systems use KASLR to randomize the location of kernel code and data in memory, making it difficult for an attacker to know where to point their exploit. To defeat KASLR, attackers usually need an information leak. Historically, side-channel research has focused on hardware-level flaws (like Meltdown or Spectre) or specific cryptographic implementations. However, KernelSnitch shifts the focus to the software logic of the OS itself.
Hash tables are ubiquitous in the Linux kernel for managing everything from timers to process memory. They are designed for speed, using linked lists (buckets) to store elements. However, this design contains a fundamental timing flaw: the more elements in a bucket, the longer it takes for the kernel to iterate through them. This timing variance is the "snitch" that leaks the underlying kernel addresses used to calculate the hash.
Technical Deep Dive
Understanding the Vulnerability
The vulnerability lies in the predictable behavior of hash table lookups. When a syscall like futex_wait or clock_gettime is called, the kernel calculates a hash to find the correct bucket. If multiple items share the same hash (a collision), the kernel must traverse a linked list to find the specific entry. KernelSnitch exploits the fact that an attacker can control one part of the hash input (a user-space ID or address) while the kernel provides the other (a kernel heap address).
Amplification Techniques
Measuring nanosecond-level differences from user space is inherently noisy. KernelSnitch overcomes this using two clever tricks:
- Bucket Stuffing: The attacker fills a bucket with thousands of elements to exaggerate the time it takes the kernel to traverse the list.
- Cache Eviction: By accessing a large array before the syscall, the attacker flushes the CPU cache. This forces the kernel to fetch list elements from main memory (DRAM), which is significantly slower than the cache, making the timing difference between 0 and 1000 elements massive and easy to measure.
Step-by-Step Exploitation
The attack is split into an online and offline phase:
- Online Phase (Fingerprinting): The attacker picks a set of user-space addresses and identifies which ones cause a hash collision with the target kernel object (e.g.,
mm_struct). This creates a unique "collision fingerprint." - Offline Phase (Brute-forcing): Since the kernel's hash function is open-source, the attacker can run a local program that simulates the hashing process. They iterate through possible kernel heap addresses (within the expected range of the slab allocator) until they find an address that produces the exact same collision fingerprint found in the online phase.
In the demonstration, the researchers used 16 threads to brute-force the search space of approximately 2^35.3 addresses, successfully leaking the mm_struct address in just 30 seconds.
Tools and Techniques
The attack is entirely hardware-agnostic, meaning it works on x86, ARM, and RISC-V. It doesn't require specialized hardware or even a high-privilege account. It can be executed from within a restricted environment like a Docker container, making it a potent tool for lateral movement or privilege escalation.
Mitigation & Defense
Defending against KernelSnitch is surprisingly difficult. The researchers proposed a patch that adds entropy to the hashing process (XORing keys with code base addresses), but it was criticized by the Linux community for its complexity and potential performance impact. Linus Torvalds famously dismissed the approach as "voodoo programming."
For defenders, the best mitigation is to monitor for unusual syscall timing patterns or massive amounts of page faults/cache misses triggered by a single process. However, because the attack uses legitimate syscalls as intended, it is extremely stealthy.
Conclusion & Key Takeaways
KernelSnitch reminds us that even when our hardware is secure and our memory management is bug-free, the architectural design of software can still betray us.
Key Takeaways:
- Software logic is a side-channel: Performance-oriented data structures like hash tables can leak metadata.
- KASLR is not a silver bullet: Side-channels provide a stable alternative to memory corruption for leaking pointers.
- Simplicity Wins: By using basic techniques like cache flushing, researchers can create attacks that are more reliable than complex microarchitectural exploits.
As we move forward, the security community must look closer at the "middle ground" between hardware and user applications—the operating system kernel itself.
AI Summary
This research presentation introduces KernelSnitch, a software-induced side-channel attack that exploits timing discrepancies in Linux kernel hash tables. The presenters, Lukas Maar and Jonas Juffinger, explain that while hardware side-channels (like Specter or Meltdown) are well-known, OS-level software side-channels remain an under-explored attack surface. The core vulnerability lies in how the Linux kernel handles hash collisions within linked-list buckets. When a syscall iterates through a hash bucket, its execution time is proportional to the number of elements in that bucket. By manipulating the number of elements (append/remove primitives) and measuring the time of access (access primitives), an attacker can deduce information about the kernel addresses used in the hashing process. To make this leakage exploitable from user space, the researchers employ two amplification techniques: increasing the number of elements in a bucket to widen timing gaps and enforcing CPU cache misses. By flushing the cache before timing a syscall, they eliminate the speedup provided by the microarchitecture, making the software-level latency much more distinct and reliable. They demonstrate that these techniques effectively eliminate false positives and negatives, even in noisy environments or across different architectures like x86_64, ARM, and RISC-V. The presentation details a practical end-to-end attack to leak the 'mm_struct' kernel heap pointer. This is achieved through a two-phase process. In the 'Online Phase,' the attacker identifies a 'fingerprint' of user-space addresses that cause hash collisions with a target kernel address. In the 'Offline Phase,' the attacker performs a localized brute-force search by running the kernel's hash function against potential kernel addresses to find a match for the fingerprint. On a modern Ubuntu system, this process takes approximately 30 seconds. While the attack does not grant immediate root access, it provides a critical 'read primitive' (KASLR bypass) that makes subsequent memory corruption exploits significantly more stable and reliable. The talk concludes with a discussion of the disclosure process, noting that while patches were proposed to add entropy to the hashing mechanism, they were met with resistance from upstream maintainers like Linus Torvalds, leaving many systems currently unpatched.
More from this Playlist




Dismantling the SEOS Protocol
