Fractal is a kernel that spies on what happens inside CPUs. And it found something unexpected in the Apple M1
Understanding the internal behavior of a modern processor precisely and, consequently, whether everything works as it should, including regarding security.
This has been achieved at the MIT Computer Science and Artificial Intelligence Laboratory (CSAIL), where a group of researchers has created Fractal, a kernel specifically designed for this purpose.
The traditional modus operandi involves booting macOS or Linux, manually modifying the kernel, and hoping that the patches hold during experiments. This is an unstable, hardly reproducible approach, and on Apple platforms, it is destined to become unusable with updates.
Fractal, on the other hand, was designed with the goal of treating hardware as an object of study, minimizing the interference introduced by system software during measurements.
Image credit: Gabriel Maragaño
How Fractal works
Modern processors maintain state in numerous internal structures - branch predictor, cache, translation lookaside buffer - and studying their behavior across the boundary between user code and kernel code is particularly complex on a general-purpose operating system. The latter manages privilege levels, addressing spaces, and scheduling, introducing its own activities into every measurement.
Fractal inverts this model. It boots directly on hardware (bare metal), without any other software running, and exposes primitives that allow a single experiment to switch privilege levels at runtime, executing the same instructions in the same addressing space. The technique underlying this is called multi-privilege concurrency and is based on a new construct: the outer kernel thread, which resides in the memory of a user process but runs with kernel privileges.
The practical result is a low-noise experimental environment: where measurements on macOS or Linux are distorted by interrupts, scheduler activities, and addressing space management, Fractal produces clean signals.
"We are using the hardware in ways it was not designed for," stated Joseph Ravichandran, the PhD candidate in Electrical Engineering and Computer Science (EECS) who led the project. "It's like an electron microscope. With a handheld magnifying lens, you see something. With an electron microscope, however, you work at a completely different level. This is Fractal."
What Fractal found in the Apple M1
The first significant application of Fractal was an in-depth analysis of branch predictors - the mechanism by which a processor attempts to predict which instruction to execute next, before having certainty, to avoid waiting cycles - of the Apple M1.
The Apple M1 implements an ARM specification called CSV2, designed to prevent code running at one privilege level from influencing speculation at the other. Through Fractal, the team confirmed that the protection works during the execution phase of the indirect branch predictor: a user-mode program cannot make the kernel speculatively execute a target chosen through the predictor.
However, researchers found behavior that chip designers may not have intentionally anticipated: the processor still retrieves the target in the instruction cache before the protection intervenes. This fetch operation is observable via a side channel, meaning that user code can still affect the contents of the kernel cache across the privilege boundary. The same pattern was detected between processes with different address space identifiers.
Perhaps the most significant contribution pertains to the so-called Phantom speculation, a class of misprediction previously documented only on AMD and Intel processors. In this type of attack, ordinary instructions - including a simple no-op - are erroneously interpreted by the processor as branches, triggering speculative behaviors not requested by the program.
Fractal highlighted how the Apple Silicon chip is subject to this phenomenon: Phantom speculatory fetches were successful across both privilege levels and between different addressing spaces, even though the execution phase remains blocked.
The team also disproved a result from earlier research on the conditional branch predictor of the M1. Previous studies had reported that cross-privilege training worked on Apple's high-performance cores but not on those designed for energy efficiency. Fractal demonstrated that the conditional branch predictor has no privilege isolation, neither on one type of core nor the other, and that the previous result was likely an artifact of macOS silently shifting threads between cores during system calls.
A shared tool for the research community
Fractal supports x86_64, ARM64, and RISC-V architectures and contains over 31,000 lines of code. The kernel includes POSIX system calls, a C library, and ports of standard tools such as vim, GCC, and the dash shell, to facilitate the migration of existing experimental code.
The MIT team has communicated its findings related to the M1 to Apple's security team. In turn, Apple technicians have examined Fractal.
The long-term goal is to transform Fractal into shared infrastructure for the entire community that researches microarchitectures, modeled after projects like QEMU or FFmpeg in their respective fields. According to Mengyuan Li, an assistant professor at the University of Southern California and not involved in the study, Fractal transforms an often improvised microarchitectural reverse engineering process into reusable research infrastructure, thus becoming an important resource for the entire industry.