[Paper Review] Vulnerability Detection with Code Language Models: How Far Are We?
The paper audits code language models for vulnerability detection, reveals data quality and evaluation flaws in existing benchmarks, introduces PrimeVul with rigorous labeling and de-duplication, and shows current models perform poorly under realistic settings.
In the context of the rising interest in code language models (code LMs) and vulnerability detection, we study the effectiveness of code LMs for detecting vulnerabilities. Our analysis reveals significant shortcomings in existing vulnerability datasets, including poor data quality, low label accuracy, and high duplication rates, leading to unreliable model performance in realistic vulnerability detection scenarios. Additionally, the evaluation methods used with these datasets are not representative of real-world vulnerability detection. To address these challenges, we introduce PrimeVul, a new dataset for training and evaluating code LMs for vulnerability detection. PrimeVul incorporates a novel set of data labeling techniques that achieve comparable label accuracy to human-verified benchmarks while significantly expanding the dataset. It also implements a rigorous data de-duplication and chronological data splitting strategy to mitigate data leakage issues, alongside introducing more realistic evaluation metrics and settings. This comprehensive approach aims to provide a more accurate assessment of code LMs' performance in real-world conditions. Evaluating code LMs on PrimeVul reveals that existing benchmarks significantly overestimate the performance of these models. For instance, a state-of-the-art 7B model scored 68.26% F1 on BigVul but only 3.09% F1 on PrimeVul. Attempts to improve performance through advanced training techniques and larger models like GPT-3.5 and GPT-4 were unsuccessful, with results akin to random guessing in the most stringent settings. These findings underscore the considerable gap between current capabilities and the practical requirements for deploying code LMs in security roles, highlighting the need for more innovative research in this domain.
Motivation & Objective
- Analyze shortcomings in existing vulnerability detection datasets and benchmarks.
- Propose PrimeVul with high-label-accuracy labeling and de-duplication to reduce data leakage.
- Introduce realistic evaluation guidelines including VD-S and paired-function evaluations.
- Empirically evaluate a range of code LMs on PrimeVul to establish a realistic performance baseline.
Proposed method
- Critically analyze data collection, labeling accuracy, and duplication in existing vd benchmarks.
- Construct PrimeVul using two labeling techniques (PrimeVul - OneFunc and PrimeVul - NVDCheck) and thorough deduplication.
- Apply chronological train/validation/test splits to reduce leakage and introduce VD-S and paired-function evaluation.
- Fine-tune and evaluate multiple open-source code LMs and select LLMs on PrimeVul under realistic settings.
- Report metrics including accuracy, F1, VD-S, and pair-wise outcomes to assess practical utility.

Experimental results
Research questions
- RQ1RQ1: How do open-source code LMs perform on PrimeVul?
- RQ2RQ2: Can advanced training techniques improve vulnerability detection performance?
- RQ3RQ3: Can larger language models (LLMs) improve vulnerability detection performance?
Key findings
- Existing benchmarks overestimate code LM vulnerability detection performance in realistic settings.
- PrimeVul contains 6,968 vulnerable and 228,800 benign functions across 140 CWEs, with high labeling accuracy comparable to manual benchmarks.
- Code LMs show substantial performance gaps when evaluated on PrimeVul (e.g., a model scoring 68.26% F1 on BigVul drops to 3.09% F1 on PrimeVul).
- Advanced training techniques yield only marginal gains; GPT-3.5 and GPT-4 results are not reliably better and can resemble random guessing in stringent settings.
- New evaluation metrics (VD-S) and paired-function evaluations reveal weaknesses not captured by traditional accuracy/F1 metrics.
- Chronological data splits mitigate leakage and better reflect real-world model deployment constraints.

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.