arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2412.18260cs.CL
收藏

研究大型语言模型用于代码漏洞检测:一项实验研究

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

Institute of Computing Technology, Chinese Academy of Sciences(中国科学院计算技术研究所);University of Chinese Academy of Sciences(中国科学院大学);JD.com, Inc.(京东集团);China Mobile Research Institute(中国移动研究院);Zhongguancun Lab(中关村实验室)

Xuefeng Jiang, Lvhua Wu, Sheng Sun, Jia Li, Jingjing Xue, Yuwei Wang, Tingting Wu, Min Liu

AI总结:

本文通过微调四种开源LLM并对比五种传统模型,在五个CVD数据集上评估漏洞检测性能,重点分析类别不平衡与样本长度影响,并开源全部代码资源。

摘要:

代码漏洞检测(CVD)对于解决和预防系统安全问题至关重要,在保障软件安全方面发挥着关键作用。以往基于学习的漏洞检测方法要么依赖于对中等规模序列模型进行微调,要么依赖于从头训练较小的神经网络。近期,大型预训练语言模型(LLM)的进展在包括代码理解和生成在内的各种代码智能任务中展现了显著能力。然而,LLM在检测代码漏洞方面的有效性在很大程度上仍未得到充分探索。本工作旨在通过针对CVD任务微调LLM来研究这一差距,涉及四种广泛使用的开源LLM。我们还实现了另外五种以往的基于图或中等规模序列的模型用于比较。实验在五个常用的CVD数据集上进行,包括短样本和长样本部分。此外,我们开展定量实验,研究类别不平衡问题以及模型在不同长度样本上的性能,这些在以往工作中很少被研究。为更好地便利社区,我们在 https://github.com/SakiRinn/LLM4CVD 和 https://huggingface.co/datasets/xuefen/VulResource 开源了本研究的所有代码和资源。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑