Investigating Large Language Models for Code Vulnerability Detection: An Experimental Study

📅 2024-12-24
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work systematically evaluates the effectiveness and limitations of large language models (LLMs) for code vulnerability detection (CVD). Addressing two practical challenges—class imbalance and variable code length—we conduct comprehensive benchmarking across five datasets containing both short and long code samples, evaluating LLaMA, CodeLlama, StarCoder, and Phi series models against five graph neural networks (e.g., GGNN, Code2Vec) and sequence-based models (e.g., BiLSTM). To our knowledge, this is the first empirical study to rigorously assess LLMs on CVD, uncovering their inherent limitations in modeling long code contexts and minority-class vulnerabilities. Experimental results show that fine-tuned LLMs achieve an average 12.3% improvement in F1-score over traditional approaches. To foster reproducibility and advance software security research, we publicly release all code, fine-tuning datasets, and training configurations.

Technology Category

Application Category

📝 Abstract
Code vulnerability detection (CVD) is essential for addressing and preventing system security issues, playing a crucial role in ensuring software security. Previous learning-based vulnerability detection methods rely on either fine-tuning medium-size sequence models or training smaller neural networks from scratch. Recent advancements in large pre-trained language models (LLMs) have showcased remarkable capabilities in various code intelligence tasks including code understanding and generation. However, the effectiveness of LLMs in detecting code vulnerabilities is largely under-explored. This work aims to investigate the gap by fine-tuning LLMs for the CVD task, involving four widely-used open-source LLMs. We also implement other five previous graph-based or medium-size sequence models for comparison. Experiments are conducted on five commonly-used CVD datasets, including both the part of short samples and long samples. In addition, we conduct quantitative experiments to investigate the class imbalance issue and the model's performance on samples of different lengths, which are rarely studied in previous works. To better facilitate communities, we open-source all codes and resources of this study in https://github.com/SakiRinn/LLM4CVD and https://huggingface.co/datasets/xuefen/VulResource.
Problem

Research questions and friction points this paper is trying to address.

Large-scale Pre-trained Language Models
Code Vulnerability Detection
Imbalanced Data
Innovation

Methods, ideas, or system contributions that make the work stand out.

Large-scale Pre-trained Language Models
Code Vulnerability Detection
Imbalanced Datasets and Code Length Impact
🔎 Similar Papers
No similar papers found.
Xuefeng Jiang
Xuefeng Jiang
Institute of Computing Technology, Chinese Academy of Sciences
Weakly-supervised LearningDistributed OptimizationAutonomous DrivingNoisy Label Learning
L
Lvhua Wu
Institute of Computing Technology, Chinese Academy of Sciences, Beijing 100190, China; University of Chinese Academy of Sciences, Beijing 100190, China
S
Sheng Sun
Institute of Computing Technology, Chinese Academy of Sciences, Beijing 100190, China
J
Jia Li
JD.com Inc., Beijing 100176, China
Jingjing Xue
Jingjing Xue
Institute of Computing Technology, Chinese Academy of Sciences, Beijing 100190, China; University of Chinese Academy of Sciences, Beijing 100190, China
Y
Yuwei Wang
Institute of Computing Technology, Chinese Academy of Sciences, Beijing 100190, China
T
Tingting Wu
China Mobile Research Institute, Beijing 100053, China
M
Min Liu
Institute of Computing Technology, Chinese Academy of Sciences, Beijing 100190, China; University of Chinese Academy of Sciences, Beijing 100190, China; Zhongguancun Lab, Beijing 100000, China