arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2408.04125cs.SEcs.CRcs.LG
收藏

VulScribeR:利用大语言模型探索基于检索增强生成的漏洞数据增强

VulScribeR: Exploring RAG-based Vulnerability Augmentation with LLMs

University of Manitoba(曼尼托巴大学);Washington State University(华盛顿州立大学);University at Buffalo(布法罗大学)

Seyed Shayan Daneshvar, Yu Nong, Xu Yang, Shaowei Wang, Haipeng Cai

AI总结:

本文提出 VulScribeR,利用大语言模型结合检索增强生成,通过变异、注入和扩展三种策略增强漏洞数据,在多个数据集上显著优于现有方法,并具备低成本大规模增强能力。

摘要:

漏洞检测对软件安全至关重要,但基于深度学习的漏洞检测器(DLVD)面临数据短缺问题,这限制了其有效性。数据增强有望缓解数据短缺,但增强易受攻击的代码具有挑战性,需要一种能够保持漏洞特性的生成式解决方案。以往的工作仅专注于生成包含单条语句或特定类型漏洞的样本。近年来,大语言模型(LLM)已被用于解决各种代码生成与理解任务,并取得了令人鼓舞的成果,尤其是在与检索增强生成(RAG)相结合时。因此,我们提出 VulScribeR,这是一种新颖的基于 LLM 的解决方案,利用精心设计的提示模板来增强漏洞数据集。更具体地说,我们探索了三种策略,利用 LLM 同时增强单语句和多语句漏洞,即变异(Mutation)、注入(Injection)和扩展(Extension)。我们在四个漏洞数据集和多个 DLVD 模型上使用三种 LLM 进行了广泛评估,结果表明,在平均生成 5K 个漏洞样本时,我们的方法在 f1-score 上分别比两种最先进的方法 Vulgen 和 VGX 以及随机过采样(ROS)高出 27.48%、27.93% 和 15.41%;在生成 15K 个漏洞样本时,分别高出 53.84%、54.10%、69.90% 和 40.93%。我们的方法通过以低至 1.88 美元的成本生成 1K 个样本,证明了其用于大规模数据增强的可行性。

英文摘要:

Detecting vulnerabilities is vital for software security, yet deep learning-based vulnerability detectors (DLVD) face a data shortage, which limits their effectiveness. Data augmentation can potentially alleviate the data shortage, but augmenting vulnerable code is challenging and requires a generative solution that maintains vulnerability. Previous works have only focused on generating samples that contain single statements or specific types of vulnerabilities. Recently, large language models (LLMs) have been used to solve various code generation and comprehension tasks with inspiring results, especially when fused with retrieval augmented generation (RAG). Therefore, we propose VulScribeR, a novel LLM-based solution that leverages carefully curated prompt templates to augment vulnerable datasets. More specifically, we explore three strategies to augment both single and multi-statement vulnerabilities, with LLMs, namely Mutation, Injection, and Extension. Our extensive evaluation across four vulnerability datasets and DLVD models, using three LLMs, show that our approach beats two SOTA methods Vulgen and VGX, and Random Oversampling (ROS) by 27.48%, 27.93%, and 15.41% in f1-score with 5K generated vulnerable samples on average, and 53.84%, 54.10%, 69.90%, and 40.93% with 15K generated vulnerable samples. Our approach demonstrates its feasibility for large-scale data augmentation by generating 1K samples at as cheap as US$ 1.88.

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

↑