You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 🔎 Side-Channel Research — Flush+Reload (Cache) PoC
248
+
249
+
**Warning:** The experimental code in this section is for educational purposes only and must be executed exclusively in a local virtual machine or dedicated experimental equipment, and only in environments with explicit authorization.
250
+
251
+
Side-channel attacks are techniques that infer secrets from incidental information such as computation time, power consumption, or cache behavior. This repository includes a PoC of **Flush+Reload**, a representative cache-based attack technique. Flush+Reload is a high-resolution, low-noise attack targeting the L3 cache that can determine whether specific memory lines have been accessed, without requiring the attacker and victim to share the same CPU core. This PoC consists of C code located in the `PoCs/cache/` directory.
252
+
253
+
### Overview
254
+
255
+
-**Victim Program**: A simulator that repeatedly accesses specific memory indices
256
+
-**Attacker Program**: Uses `clflush` and `rdtscp` to measure memory access times, distinguishing cache hits from misses
257
+
-**Execution Script**: Runs the victim in the background, saves attacker results to CSV, then terminates the victim
The CSV format is `iter,cycles` where small values (~1,000 cycles) indicate cache hits and large values (hundreds of thousands of cycles) indicate cache misses or interrupt/context switches.
276
+
277
+
**Sample Output:**
278
+
```csv
279
+
iter,cycles
280
+
0,158000
281
+
1,1000
282
+
2,1000
283
+
3,155000
284
+
4,1000
285
+
...
286
+
```
287
+
288
+
Measurements typically form two distinct clusters:
289
+
-**Low latency cluster**: Cache hits (victim accessed the memory, data in cache)
290
+
-**High latency cluster**: Cache misses or interrupts/context switches
291
+
292
+
### Analysis Examples
293
+
294
+
**Statistics:**
295
+
```bash
296
+
# Count samples
297
+
wc -l /tmp/flush_reload_data.csv
298
+
299
+
# Calculate mean
300
+
awk -F, 'NR>1{n++; sum+=$2} END{print "Samples:", n, "Mean:", sum/n}' /tmp/flush_reload_data.csv
301
+
```
302
+
303
+
**Visualization (Python):**
304
+
```python
305
+
import csv, numpy as np
306
+
import matplotlib.pyplot as plt
307
+
308
+
xs = []
309
+
withopen('/tmp/flush_reload_data.csv') as f:
310
+
r = csv.reader(f)
311
+
next(r)
312
+
for _, c in r:
313
+
xs.append(int(c))
314
+
315
+
xs = np.array(xs)
316
+
plt.hist(xs, bins=200, log=True)
317
+
plt.xlabel('Cycles')
318
+
plt.ylabel('Count (log scale)')
319
+
plt.title('Flush+Reload Distribution')
320
+
plt.yscale('log')
321
+
plt.show()
322
+
```
323
+
324
+
### Security Implications
325
+
326
+
Flush+Reload can be exploited for practical attacks such as tracking AES S-box accesses to extract cryptographic keys. Therefore, defensive techniques should be applied to reduce side-channel leakage, including:
0 commit comments