Benchmarking Large Language Models for Multi-Language Software Vulnerability Detection
本文对多语言软件漏洞检测中的大型语言模型(LLMs)进行了全面评估,发现LLMs在漏洞检测任务中仍具有挑战性,并为未来利用生成式AI提高软件安全实践提供了实际见解。
更新于 2025-03-06。作者:Ting Zhang、Chengran Yang、Yindu Su、Martin Weyssow、Hung Nguyen、Tan Bui、Hong Jin Kang、Yikun Li、Eng Lieh Ouh、Lwin Khin Shar、David Lo。
中文摘要
近年来,生成式人工智能的进步使得大型语言模型(LLMs)在软件工程中得到广泛应用,解决了许多长期存在的挑战。然而,目前缺乏对LLMs在软件漏洞检测(SVD)方面的能力进行全面研究,而软件漏洞检测是软件安全的一个重要方面。现有的研究主要侧重于使用C/C++数据集评估LLMs。它们通常只探索提示工程、指令微调和开源LLMs的序列分类微调中的策略之一。因此,在多种编程语言中检测漏洞时,不同LLMs的有效性存在显著的认知差距。为了填补这一知识空白,我们进行了一项全面的实证研究,评估LLMs在SVD任务上的性能。我们整理了一个包含8,260个Python漏洞函数、7,505个Java漏洞函数和28,983个JavaScript漏洞函数的全面数据集。我们采用多种方法评估了五个开源LLMs,包括提示工程、指令微调和序列分类微调。这些LLMs与五个微调的小型语言模型和两个开源的静态应用安全测试工具进行了基准测试。此外,我们还探索了两个提高LLMs在SVD上性能的途径:a) 数据视角:使用下采样平衡数据集重新训练模型。b) 模型视角:研究结合多个LLMs预测的集成学习方法。我们的全面实验表明,SVD对于LLMs来说仍然是一个具有挑战性的任务。这项研究全面理解了LLMs在SVD中的作用,并为未来利用生成式人工智能提升软件安全实践提供了实用的见解。
英文摘要
Recent advancements in generative AI have led to the widespread adoption of large language models (LLMs) in software engineering, addressing numerous long-standing challenges. However, a comprehensive study examining the capabilities of LLMs in software vulnerability detection (SVD), a crucial aspect of software security, is currently lacking. Existing research primarily focuses on evaluating LLMs using C/C++ datasets. It typically explores only one or two strategies among prompt engineering, instruction tuning, and sequence classification fine-tuning for open-source LLMs. Consequently, there is a significant knowledge gap regarding the effectiveness of diverse LLMs in detecting vulnerabilities across various programming languages. To address this knowledge gap, we present a comprehensive empirical study evaluating the performance of LLMs on the SVD task. We have compiled a comprehensive dataset comprising 8,260 vulnerable functions in Python, 7,505 in Java, and 28,983 in JavaScript. We assess five open-source LLMs using multiple approaches, including prompt engineering, instruction tuning, and sequence classification fine-tuning. These LLMs are benchmarked against five fine-tuned small language models and two open-source static application security testing tools. Furthermore, we explore two avenues to improve LLM performance on SVD: a) Data perspective: Retraining models using downsampled balanced datasets. b) Model perspective: Investigating ensemble learning methods that combine predictions from multiple LLMs. Our comprehensive experiments demonstrate that SVD remains a challenging task for LLMs. This study provides a thorough understanding of the role of LLMs in SVD and offers practical insights for future advancements in leveraging generative AI to enhance software security practices.
解读
一句话总结
本文对多语言软件漏洞检测中的大型语言模型(LLMs)进行了全面评估,发现LLMs在漏洞检测任务中仍具有挑战性,并为未来利用生成式AI提高软件安全实践提供了实际见解。
问题1:这篇论文想要解决什么具体问题?
- 问题背景:软件漏洞检测(SVD)是软件安全的关键方面,但现有研究主要关注C/C++漏洞,缺乏对其他编程语言的评估。
- 现有方案不足:现有研究通常只采用有限的策略来评估LLMs,如提示工程、指令调整和序列分类微调,缺乏全面比较。
- 研究目标:评估不同LLMs在SVD任务中的性能,并与小型语言模型(SLMs)和静态应用安全测试(SAST)工具进行比较。
问题2:论文的核心创新点是什么?
- 技术创新:创建了包含Python、Java和JavaScript漏洞的全面数据集,并评估了多种LLMs和SLMs。
- 方法改进:采用多种提示工程和微调策略,包括零样本生成、上下文学习和序列分类微调。
- 优势:提供了对LLMs在SVD任务中有效性的全面理解,并为未来改进提供了见解。
问题3:实验结果如何验证了方法的有效性?
- 关键实验:对五款LLMs和五种SLMs进行了评估,并与SAST工具进行了比较。
- 性能提升:在JavaScript数据集上,指令调整的StarCoder-2实现了最高的F1分数。
- 对比结果:LLMs在JavaScript上的性能优于SLMs和SAST工具,但在Python和Java上的性能则不如SLMs。
问题4:这个研究的实际应用价值是什么?
- 应用场景:提高软件安全性和减少漏洞。
- 实施建议:使用平衡数据集进行微调,并根据特定模型和任务组合选择最佳策略。
- 局限与展望:未来研究可以探索更先进的提示工程技术、更复杂的集成学习方法和LLM协作策略。
来源
机器可读索引:llms.txt