[Paper Review] Automated Vulnerability Detection in Source Code Using Deep Representation Learning
This paper proposes a deep learning-based system for automated vulnerability detection in C/C++ source code using learned representations from millions of open-source functions. By combining a custom lexer with convolutional neural networks and random forest ensembles on curated static analyzer findings, the method achieves state-of-the-art performance on benchmark datasets, outperforming traditional static analyzers and prior ML approaches.
Increasing numbers of software vulnerabilities are discovered every year whether they are reported publicly or discovered internally in proprietary code. These vulnerabilities can pose serious risk of exploit and result in system compromise, information leaks, or denial of service. We leveraged the wealth of C and C++ open-source code available to develop a large-scale function-level vulnerability detection system using machine learning. To supplement existing labeled vulnerability datasets, we compiled a vast dataset of millions of open-source functions and labeled it with carefully-selected findings from three different static analyzers that indicate potential exploits. The labeled dataset is available at: https://osf.io/d45bw/. Using these datasets, we developed a fast and scalable vulnerability detection tool based on deep feature representation learning that directly interprets lexed source code. We evaluated our tool on code from both real software packages and the NIST SATE IV benchmark dataset. Our results demonstrate that deep feature representation learning on source code is a promising approach for automated software vulnerability detection.
Motivation & Objective
- Address the growing challenge of software vulnerabilities in open-source and proprietary codebases.
- Overcome limitations of rule-based static analyzers that miss novel or complex vulnerabilities.
- Leverage large-scale, real-world code to train machine learning models that generalize across diverse vulnerability patterns.
- Develop a scalable, function-level vulnerability detection system using deep representation learning on lexed source code.
- Improve detection accuracy and reduce false positives by combining deep neural features with ensemble classification.
Proposed method
- Constructed a dataset of over 12 million C/C++ functions from Debian, GitHub, and the SATE IV Juliet Test Suite.
- Applied a custom lexer to convert source code into a tokenized, sequence-based representation suitable for deep learning.
- Used three static analyzers (Clang, Flawfinder, Cppcheck) to label functions with potential vulnerabilities, creating a curated dataset.
- Trained multiple machine learning models, including RNNs, CNNs, and fully connected networks, to learn deep feature representations from the lexed code.
- Combined learned deep features with random forest classifiers to improve generalization and prediction performance.
- Employed precision-recall and ROC AUC metrics to evaluate model performance, with visualization of attention maps to interpret predictions.
Experimental results
Research questions
- RQ1Can deep representation learning on raw, lexed source code effectively detect a wide range of software vulnerabilities across diverse codebases?
- RQ2How does model performance on real-world code (Debian, GitHub) compare to performance on synthetic benchmarks like SATE IV?
- RQ3To what extent do deep neural network features outperform traditional bag-of-words or rule-based representations in vulnerability detection?
- RQ4Can ensemble models combining deep features with random forests improve detection accuracy and robustness over individual models?
- RQ5How do the predictions of the ML model compare to those of established static analysis tools in terms of precision, recall, and F1 score?
Key findings
- The CNN + Random Forest model achieved the highest PR AUC (0.518) and F1 score (0.566) on the natural code test set (Debian and GitHub), outperforming BOW + RF and RNN-based models.
- On the SATE IV benchmark, the CNN + RF model achieved a PR AUC of 0.916 and an F1 score of 0.824, significantly outperforming static analyzers like Clang (F1: 0.450) and Flawfinder (F1: 0.365).
- The model's performance was substantially better on the SATE IV dataset than on real-world code, likely due to the higher consistency and label balance in the synthetic data.
- The use of deep features from CNNs and RNNs led to a 10–15% improvement in F1 score compared to traditional bag-of-words representations.
- Visualization of convolutional feature maps enabled interpretable explanations of model predictions, highlighting code regions associated with vulnerabilities.
- The system demonstrated scalability, processing large codebases rapidly without requiring compilation, and allowed tunable thresholds for precision-recall trade-offs.
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.