arrow
返回

SCL-CVD: Supervised contrastive learning for code vulnerability detection via GraphCodeBERT

delete2024-10-01
delete1
PRE
AI
R
Rongcun Wang *
S
Senlei Xu
Y
Yuan Tian
X
Xingyu Ji
X
Xiaobing Sun
S
Shujuang Jiang
DOI:10.1016/j.cose.2024.103994delete
delete原文链接
delete原文求助
delete分享
delete收藏
摘要

摘要

En 中文
Detecting vulnerabilities in source code is crucial for protecting software systems from cyberattacks. Pre- trained language models such as CodeBERT and GraphCodeBERT have been applied in multiple code-related downstream tasks such as code search and code translation and have achieved notable success. Recently, this pre-trained and fine-tuned paradigm has also been applied to detect code vulnerabilities. However, finetuning pre-trained language models using cross-entropy loss has several limitations, such as poor generalization performance and lack of robustness to noisy labels. In particular, when the vulnerable code and the benign code are very similar, it is difficult for deep learning methods to differentiate them accurately. In this context, we introduce a novel approach for code vulnerability detection using supervised contrastive learning, namely SCLCVD, which leverages GraphCodeBERT. This method aims to enhance the effectiveness of existing vulnerable code detection approaches. SCL-CVD represents the source code as data flow graphs. These graphs are then processed by GraphCodeBERT, which has been fine-tuned using a supervised contrastive loss function combined with R-Drop. This fine-tuning process is designed to generate more resilient and representative code embedding. Additionally, we incorporate LoRA (Low-Rank Adaptation) to streamline the fine-tuning process, significantly reducing the time required for model training. Finally, a Multilayer Perceptron (MLP) is employed to detect vulnerable code leveraging the learned representation of code. We designed and conducted experiments on three public benchmark datasets, i.e., Devign, Reveal, Big-Vul, and a combined dataset created by merging these sources. The experimental results demonstrate that SCL-CVD can effectively improve the performance of code vulnerability detection. Compared with the baselines, the proposed approach has a relative improvement of 0.48%-3.42% for accuracy, 0.93%-45.99% for precision, 35.68%-67.48% for recall, and 16.31%-49.67% for F1-score, respectively. Furthermore, compared to baselines, the model fine-tuning time of the proposed approach is reduced by 16.67%-93.03%. In conclusion, our approach SCL-CVD offers significantly greater cost-effectiveness over existing approaches.
Keyword:
Contrastive learning
Vulnerability detection
Pre-trained models
LoRA

期刊

C
Computers and Security
IF:
5.4
论文数:
4.6K
被引数:
1.4W

机构

Y
Yangzhou University
学者数:
2.8W
论文数: 1.9W
被引数: 3.3W
引用论文

引用论文

SPVF: security property assisted vulnerability fixing via attention-based models
err2022-09-20
err12
PREAI
errZhou, Zhou; Bo, Lili; Wu, Xiaoxue; Sun, Xiaobing; Zhang, Tao; Li, Bin; Zhang, Jiale; Cao, Sicong
err分享
err收藏
err分享
err收藏
VUDENC: Vulnerability Detection with Deep Learning on a Natural Codebase for Python
err2022-04-01
err57
errOAAI
errWartschinski, Laura; Noller, Yannic; Vogel, Thomas; Kehrer, Timo; Grunske, Lars
err分享
err收藏
Automatic software vulnerability assessment by extracting vulnerability elements
err2023-10-01
err7
PREAI
errSun, Xiaobing; Ye, Zhenlei; Bo, Lili; Wu, Xiaoxue; Wei, Ying; Zhang, Tao; Li, Bin
err分享
err收藏
Investigation of Structural and Optical Properties of MoO[sub 3]-PbO-B[sub 2]O[sub 3]:V[sub 2]O[sub 5] Glasses
err2011-01-01
err0
PREAI
errSanjay; N. Kishore; A. Agarwal; S. K. Tripathi; Keya Dharamvir; Ranjan Kumar; G. S. S. Saini
err分享
err收藏
err分享
err收藏
Improved Glycemic Control through Continuous Glucose Sensor-Augmented Insulin Pump Therapy: Prospective Results from a Community and Academic Practice Patient Registry
err2009-07-01
err0
errOAAI
errOhad Cohen; Anna Körner; Rudolf Chlup; Christos S. Zoupas; Anton K. Ragozin; Krisztina Wudi; Dagmar Bartaskova; Aggelos Pappas; Tamás Niederland; Zoltán Taybani; Lubomir Barák; Andriani Vazeou
err分享
err收藏
Hydrogen-Enhanced Local Plasticity in Aluminum: AnAb InitioStudy
err2001-08-08
err0
errOAAI
errGang Lu; Qing Zhang; Nicholas Kioussis; Efthimios Kaxiras
err分享
err收藏
Automated event extraction of CVE descriptions
err2023-06-01
err8
PREAI
errWei, Ying; Bo, Lili; Sun, Xiaobing; Li, Bin; Zhang, Tao; Tao, Chuanqi
err分享
err收藏
学者 查看更多内容