GoFetch is a family of Side-Channel Attacks on recent Apple silicon CPUs that exploits the CPU's on-chip data memory-dependent prefetcher (DMP) and Cache to investigate the contents of memory. CPUs affected include the M1, M2, M3 and A14 series system-on-a-chip processors.
This webpage aims to offer viewers a comprehensive introduction to the working mechanisms of GoFetch. Before diving into detailed explanations and simulations, please make sure you have a basic understanding of the following concepts:
If you are unfamiliar with any of the terms, please click on the term and explore the underlying principles and mechanisms.
If you are ready, LET's GET START!!!
We have already learned that if the time required for the program to run under different branches is various, we can obtain the running information of the program by measuring the time.
Such as, if we use the function shown below to swap values in two arrays, the attacker could easily deduce the secret, because when secret == False, the function would terminate much more quickly than when secret == True.
void swap(boolean secret, int[] a, int[] b, int len) {
if (secret) {
for (int i = 0; i < len; i++) {
int tmp = a[i];
a[i] = b[i];
b[i] = tmp;
}
}
}
Thus, we should use a constant-time swap function to enhance the system security. ct-swap program is a constant-time swap primitive used in various cryptographic implementations. No matter what value the secret takes, the function would terminate in a constant time.
void ct-swap(int secret, int[] a, int[] b, int len) {
int delta;
int mask = ~(secret - 1);
for (int i = 0; i < len; i++) {
delta = (a[i] ^ b[i]) & mask;
a[i] = a[i] ^ delta;
b[i] = b[i] ^ delta;
}
}
By using ct-swap, the attacker can't guess program running branches by measuring the execution time. However, DMP makes it different.
Data Memory-dependent Prefetchers (DMPs) are hardware optimizations designed to speed up irregular memory access patterns by prefetching data into the cache based on the contents of data memory. However, this behavior can be exploited to leak sensitive information, even from constant-time cryptographic implementations.
Here's a simplified explanation of how DMPs can be leveraged in an attack:
The following steps outline how an attacker can use GoFetch to exploit the ct-swap program:
Let's simulate an attack using GoFetch on a simplified program which simulates the cache, ct-swap funciton, and the attacker!
To mitigate such attacks, developers can employ several defense mechanisms:
This example highlights the importance of understanding hardware mechanisms like DMPs and their potential security implications. By studying and simulating attacks, developers can better protect their applications against sophisticated side-channel attacks.
For more detailed information on GoFetch and its capabilities, please refer to the full research paper.