[Paper Review] Stack-based Buffer Overflow Detection using Recurrent Neural Networks
This paper proposes using Long Short-Term Memory (LSTM) recurrent neural networks to detect stack-based buffer overflow vulnerabilities in assembly code by treating code as a natural language. The model achieves 99.00% correct classification rate on a synthetic dataset, demonstrating that RNNs can effectively learn contextual patterns in low-level code to identify subtle buffer overflow flaws.
Detecting vulnerabilities in software is a critical challenge in the development and deployment of applications. One of the most known and dangerous vulnerabilities is stack-based buffer overflows, which may allow potential attackers to execute malicious code. In this paper we consider the use of modern machine learning models, specifically recurrent neural networks, to detect stack-based buffer overflow vulnerabilities in the assembly code of a program. Since assembly code is a generic and common representation, focusing on this language allows us to potentially consider programs written in several different programming languages. Moreover, we subscribe to the hypothesis that code may be treated as natural language, and thus we process assembly code using standard architectures commonly employed in natural language processing. We perform a set of experiments aimed at confirming the validity of the natural language hypothesis and the feasibility of using recurrent neural networks for detecting vulnerabilities. Our results show that our architecture is able to capture subtle stack-based buffer overflow vulnerabilities that strongly depend on the context, thus suggesting that this approach may be extended to real-world setting, as well as to other forms of vulnerability detection.
Motivation & Objective
- To investigate whether assembly code can be treated as a natural language for vulnerability detection using machine learning.
- To evaluate the feasibility of using recurrent neural networks (RNNs) for detecting stack-based buffer overflow vulnerabilities in binary code.
- To assess whether RNNs can capture context-dependent patterns critical for identifying subtle buffer overflow flaws.
- To establish a proof-of-concept for applying NLP-inspired models to low-level software security analysis.
Proposed method
- The authors use Long Short-Term Memory (LSTM) networks, a type of recurrent neural network, to process sequences of assembly instructions.
- Assembly code is tokenized and embedded into dense vector representations before being fed into the LSTM architecture.
- A two-layer LSTM model with a batch size of 80 and a learning rate of $5 \cdot 10^{-5}$ is trained using binary cross-entropy loss for classification.
- The model is trained on a self-generated dataset of assembly code samples, including both vulnerable and non-vulnerable functions.
- Hyperparameter tuning is performed to optimize model performance, with a focus on learning rate and batch size.
- The model is evaluated on a test set using classification metrics including Correct Classification Rate (CCR) and loss.
Experimental results
Research questions
- RQ1Can assembly code be effectively modeled as a sequence of tokens similar to natural language, enabling the use of NLP techniques?
- RQ2Can LSTM-based models detect context-sensitive stack-based buffer overflow vulnerabilities in assembly code?
- RQ3How does model depth (e.g., one vs. two LSTM layers) affect detection performance on this task?
- RQ4What hyperparameter settings (learning rate, batch size) yield optimal performance for this vulnerability detection task?
Key findings
- The two-layer LSTM model achieved a Correct Classification Rate (CCR) of 99.00% on the test set, indicating strong generalization capability.
- The model showed significant improvement in performance after approximately 17,500 training steps, breaking through a training plateau.
- A two-layer LSTM configuration outperformed a shallower one-layer architecture under the same training constraints.
- The model demonstrated robustness in detecting context-dependent buffer overflow patterns, even in complex code samples.
- Low learning rates ($5 \cdot 10^{-5}$) were essential for stable convergence and high performance.
- The results support the hypothesis that code can be treated as a language, enabling effective vulnerability detection using sequence modeling.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.