arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2310.16263cs.SEcs.AIcs.CLcs.CR
收藏

增强大型语言模型以实现安全代码生成:一项基于数据集的漏洞缓解研究

Enhancing Large Language Models for Secure Code Generation: A Dataset-driven Study on Vulnerability Mitigation

South China University of Technology(华南理工大学);University of Innsbruck(因斯布鲁克大学)

Jiexin Wang, Liuwen Cao, Xitong Luo, Zhiping Zhou, Jiayuan Xie, Adam Jatowt, Yi Cai

AI总结:

本文针对LLM生成代码的安全漏洞风险,构建了含180个样本的SecuCoGen数据集,通过代码生成、修复和分类实验评估现有模型,并提出缓解漏洞、增强鲁棒性的方法。

摘要:

大型语言模型(LLMs)为代码生成带来了显著进步,使新手和经验丰富的开发者均能受益。然而,使用来自GitHub等开源存储库的未清理数据对其进行训练,引入了无意中传播安全漏洞的风险。为了有效缓解这一问题,本文提出了一项综合性研究,重点从软件安全角度评估和增强代码LLMs。我们引入了SecuCoGen,这是一个精心策划的数据集,针对21种关键漏洞类型。SecuCoGen包含180个样本,并作为在三个关键代码相关任务上进行实验的基础:代码生成、代码修复和漏洞分类,且强烈侧重于安全性。我们的实验结果表明,现有模型在代码生成过程中经常忽略安全问题,导致生成易受攻击的代码。为了解决这一问题,我们提出了有效的方法来缓解安全漏洞,并增强LLMs生成代码的整体鲁棒性。此外,我们的研究指出了现有模型在修复易受攻击代码方面的弱点,即使提供了漏洞信息也是如此。另外,某些漏洞类型给模型带来了挑战,阻碍了其在漏洞分类中的表现。基于这些发现,我们相信我们的研究将对软件工程社区产生积极影响,激发改进LLMs训练和使用方法的开发,从而实现更安全、更可信的模型部署。

英文摘要:

Large language models (LLMs) have brought significant advancements to code generation, benefiting both novice and experienced developers. However, their training using unsanitized data from open-source repositories, like GitHub, introduces the risk of inadvertently propagating security vulnerabilities. To effectively mitigate this concern, this paper presents a comprehensive study focused on evaluating and enhancing code LLMs from a software security perspective. We introduce SecuCoGen\footnote{SecuCoGen has been uploaded as supplemental material and will be made publicly available after publication.}, a meticulously curated dataset targeting 21 critical vulnerability types. SecuCoGen comprises 180 samples and serves as the foundation for conducting experiments on three crucial code-related tasks: code generation, code repair and vulnerability classification, with a strong emphasis on security. Our experimental results reveal that existing models often overlook security concerns during code generation, leading to the generation of vulnerable code. To address this, we propose effective approaches to mitigate the security vulnerabilities and enhance the overall robustness of code generated by LLMs. Moreover, our study identifies weaknesses in existing models' ability to repair vulnerable code, even when provided with vulnerability information. Additionally, certain vulnerability types pose challenges for the models, hindering their performance in vulnerability classification. Based on these findings, we believe our study will have a positive impact on the software engineering community, inspiring the development of improved methods for training and utilizing LLMs, thereby leading to safer and more trustworthy model deployment.

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

↑