TL;DR
Researchers at Politecnico di Torino have developed a hardware-based approach to detect Stack Buffer Overflow (SBO) attacks on RISC-V architectures by monitoring micro-architectural events. By leveraging Hardware Performance Counters (HPCs) and machine learning—specifically the Local Outlier Factor (LOF) algorithm—they achieved over 95% detection accuracy with minimal performance overhead.
What Problem Does This Paper Address?
Memory-corruption vulnerabilities, particularly Stack Buffer Overflows (SBOs), remain a top-tier global cybersecurity threat. In a typical SBO attack, a program receives unvalidated input that overflows a buffer on the stack, overwriting the function's return address to redirect execution toward malicious code.
While software-based defenses exist, they often come with significant performance penalties or can be bypassed by sophisticated exploits. This paper explores a "hardware-first" defense strategy. The goal is to detect these anomalies at the processor level by observing subtle changes in hardware behavior (like branch patterns or memory access frequencies) that occur when an attack deviates from a program's normal execution flow.
Methods
The authors developed a methodology that combines architectural simulation with semi-supervised machine learning.
- Simulation Environment: They used the GVSoC simulator to model the Parallel Ultra Low Power (PULP) platform, a popular RISC-V-based architecture.
- Data Collection: They monitored Hardware Performance Counters (HPCs), which track micro-architectural events such as instructions executed, load/store hazards, jumps, and branch behavior.
- Machine Learning Pipeline: The researchers tested four semi-supervised anomaly detection models:
- One-class Support Vector Machines (OC-SVM)
- Local Outlier Factor (LOF)
- Isolation Forest (IF)
- Elliptic Envelope (EE)
- Feature Engineering: They also evaluated whether passing the HPC data through an autoencoder (a type of neural network that learns compressed representations of data) would improve detection accuracy.
The overall workflow is illustrated in the methodology overview below:
Datasets
To train and test their models, the researchers used four standard benchmarks:
- AES (Advanced Encryption Standard)
- RSA (Rivest–Shamir–Adleman) encryption
- SHA (Secure Hash Algorithm)
- Dijkstra algorithm
They artificially injected SBO vulnerabilities into these benchmarks. Upon a successful exploit, the program flow was redirected to a Fibonacci number generator (acting as the "malicious" payload). The dataset consisted of 10,000 "clean" executions for training and a balanced set of 10,000 executions (mixed clean and attacked) for testing.
Key Insights and Ideas
- The Power of Simplicity: The Local Outlier Factor (LOF) algorithm emerged as the clear winner. It achieved high accuracy even when monitoring only a single HPC, making it highly efficient for resource-constrained IoT devices.
- Noise in the Machine: Detecting attacks in the RSA benchmark was significantly harder than in others. This is because the RSA algorithm's random search for prime numbers creates "noisy" hardware signatures that look like anomalies even during normal operation.
- Autoencoders Aren't Always Better: Surprisingly, adding a deep-learning-based autoencoder to the pipeline did not provide a significant gain in detection performance. This suggests that for this specific type of hardware data, traditional statistical ML models are already quite effective.
- Payload Size Matters: Detection is easier when the malicious function is larger (e.g., 10% of the original code size) compared to very small injections (1%), as larger payloads leave a more distinct micro-architectural footprint.
Key Results
The study demonstrated that hardware-based detection is highly viable for RISC-V systems:
- High Accuracy: For AES, SHA, and Dijkstra, the models achieved over 90% accuracy with a malicious payload size of just 1%.
- Efficiency: The LOF classifier reached 95% accuracy using only 1 HPC for most benchmarks.
- Robustness: Because the system uses semi-supervised learning, it can theoretically detect "zero-day" attacks without needing a prior database of known malware signatures.
The performance breakdown across different models and configurations is shown in Figure 2:
Limitations and Future Work
The authors acknowledge that while hardware-based detection is promising, it faces challenges in complex, noisy environments (like the RSA example). They suggest that the most robust future defense will likely be a hybrid approach, where hardware acts as a fast, primary defense layer that triggers more intensive software-based checks when a potential anomaly is detected.
Future research could explore how these models perform against more diverse and stealthy attack payloads beyond simple control-flow deviations.
Summary updated