arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2408.06428cs.SEcs.CR
收藏

用于安全代码评估的大型语言模型:多语言实证研究

Large Language Models for Secure Code Assessment: A Multi-Language Empirical Study

Technical University of Munich(慕尼黑工业大学);Siemens AG(西门子股份公司)

Kohei Dozono, Tiago Espinha Gasiba, Andrea Stocco

AI总结:

本文研究了多语言环境下大型语言模型在安全代码评估中的有效性,通过实验发现GPT-4o在漏洞检测和CWE分类中表现最佳,并开发了CODEGUARDIAN工具提升开发人员的漏洞检测效率。

摘要:

大多数漏洞检测研究专注于C/C++代码中的漏洞数据集,提供有限的语言多样性。因此,深度学习方法,包括大型语言模型(LLMs)在检测这些语言以外的软件漏洞的有效性仍然鲜有研究。在本文中,我们评估了不同提示和角色策略下LLMs在检测和分类常见弱点枚举(CWE)中的有效性。我们的实验研究针对六种最先进的预训练LLMs(GPT-3.5-Turbo,GPT-4 Turbo,GPT-4o,CodeLLama-7B,CodeLLama-13B和Gemini 1.5 Pro)和五种编程语言:Python,C,C++,Java和JavaScript。我们从不同来源编译了一个多语言漏洞数据集,以确保代表性。我们的结果表明,GPT-4o在少量样本设置下实现了最高的漏洞检测和CWE分类得分。除了我们研究的定量结果外,我们还开发了一个名为CODEGUARDIAN的库,集成了VSCode,使开发人员能够在现实世界的安全场景中进行LLM辅助的实时漏洞分析。我们通过涉及22名行业开发人员的用户研究评估了CODEGUARDIAN。我们的研究显示,通过使用CODEGUARDIAN,开发人员在检测漏洞的准确性和速度上都有所提高。

英文摘要:

Most vulnerability detection studies focus on datasets of vulnerabilities in C/C++ code, offering limited language diversity. Thus, the effectiveness of deep learning methods, including large language models (LLMs), in detecting software vulnerabilities beyond these languages is still largely unexplored. In this paper, we evaluate the effectiveness of LLMs in detecting and classifying Common Weakness Enumerations (CWE) using different prompt and role strategies. Our experimental study targets six state-of-the-art pre-trained LLMs (GPT-3.5- Turbo, GPT-4 Turbo, GPT-4o, CodeLLama-7B, CodeLLama- 13B, and Gemini 1.5 Pro) and five programming languages: Python, C, C++, Java, and JavaScript. We compiled a multi-language vulnerability dataset from different sources, to ensure representativeness. Our results showed that GPT-4o achieves the highest vulnerability detection and CWE classification scores using a few-shot setting. Aside from the quantitative results of our study, we developed a library called CODEGUARDIAN integrated with VSCode which enables developers to perform LLM-assisted real-time vulnerability analysis in real-world security scenarios. We have evaluated CODEGUARDIAN with a user study involving 22 developers from the industry. Our study showed that, by using CODEGUARDIAN, developers are more accurate and faster at detecting vulnerabilities.

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

↑