[Paper Review] VulBERTa: Simplified Source Code Pre-Training for Vulnerability Detection
VulBERTa proposes a simplified, small-scale pre-training approach for vulnerability detection in C/C++ code using a custom tokenization pipeline that combines BPE with predefined code tokens (keywords, punctuation, and API calls). Pre-trained on 2.28M functions with 125M parameters, it achieves state-of-the-art performance on multiple datasets and benchmarks, including SOTA F1 scores of 57.92% on Draper and 99.59% on muVuldeepecker, outperforming larger models despite minimal complexity.
This paper presents VulBERTa, a deep learning approach to detect security vulnerabilities in source code. Our approach pre-trains a RoBERTa model with a custom tokenisation pipeline on real-world code from open-source C/C++ projects. The model learns a deep knowledge representation of the code syntax and semantics, which we leverage to train vulnerability detection classifiers. We evaluate our approach on binary and multi-class vulnerability detection tasks across several datasets (Vuldeepecker, Draper, REVEAL and muVuldeepecker) and benchmarks (CodeXGLUE and D2A). The evaluation results show that VulBERTa achieves state-of-the-art performance and outperforms existing approaches across different datasets, despite its conceptual simplicity, and limited cost in terms of size of training data and number of model parameters.
Motivation & Objective
- To develop a simplified, low-complexity pre-training approach for vulnerability detection in C/C++ source code.
- To improve code representation learning by integrating syntactic and semantic information through a custom tokenization pipeline.
- To achieve state-of-the-art performance in vulnerability detection with fewer parameters and less training data than existing methods.
- To evaluate transferability and robustness of the pre-trained model across diverse datasets and benchmarks.
- To enable efficient fine-tuning with lightweight classifiers (MLP and CNN) while maintaining high detection accuracy.
Proposed method
- A custom tokenization pipeline combines Byte-Pair Encoding (BPE) with pre-defined tokens for C/C++ keywords, punctuation, and common API function names to preserve syntactic and semantic structure.
- The model uses RoBERTa as the backbone architecture, pre-trained via Masked Language Modeling (MLM) on 2.28 million C/C++ functions from open-source projects.
- Pre-training is conducted on a curated dataset of real-world C/C++ code, focusing on syntactic and semantic knowledge without explicit dependency or data flow analysis.
- Fine-tuning is performed using two lightweight classifiers: a MultiLayer Perceptron (VulBERTa-MLP) and a Convolutional Neural Network (VulBERTa-CNN).
- The approach avoids complex graph-based or sequence-based architectures, relying instead on the quality of the tokenization and pre-training to encode deep code representations.
- Evaluation is conducted across binary and multi-class vulnerability detection tasks on datasets including Vuldeepecker, Draper, REVEAL, muVuldeepecker, and benchmarks CodeXGLUE and D2A.
Experimental results
Research questions
- RQ1Can a simplified, small-scale pre-training model achieve state-of-the-art performance in vulnerability detection without relying on complex architectural designs?
- RQ2To what extent does a custom tokenization pipeline that preserves syntactic and semantic structure improve code representation learning for vulnerability detection?
- RQ3Does a smaller model with fewer parameters and less pre-training data still outperform larger models on benchmark datasets?
- RQ4How transferable is the pre-trained representation across diverse datasets and vulnerability detection tasks?
- RQ5Can lightweight fine-tuning heads (MLP and CNN) achieve high performance when combined with a strong pre-trained code representation?
Key findings
- VulBERTa achieved a state-of-the-art F1 score of 57.92% on the challenging Draper dataset, outperforming existing approaches despite its small size and limited training data.
- On the multi-class muVuldeepecker dataset, VulBERTa-MLP achieved a weighted F1 score of 99.59%, demonstrating strong performance on easier, balanced data.
- On the CodeXGLUE benchmark, VulBERTa-MLP ranked first with an accuracy of 64.75%, and VulBERTa-CNN ranked second with 60.68%, both outperforming larger models like C-BERT.
- On the D2A benchmark, VulBERTa-MLP achieved 62.30% accuracy on the 'function' task, ranking first, while VulBERTa-CNN achieved 60.68%, ranking second.
- Despite having only 125M parameters and 2.28M pre-training samples, VulBERTa outperformed models like C-BERT (8.1M samples, 110M parameters) and CodeBERT (8.5M samples, 125M parameters).
- The model's performance was robust across different fine-tuning heads, with VulBERTa-MLP achieving the best PEM score on 3 out of 4 datasets and VulBERTa-CNN on the remaining one.
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.