arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2401.03374cs.SEcs.AI
收藏

基于强化学习与语义奖励的LLM驱动代码漏洞修复

LLM-Powered Code Vulnerability Repair with Reinforcement Learning and Semantic Reward

University of Texas at San Antonio(德克萨斯大学圣安东尼奥分校);Louisiana State University(路易斯安那州立大学);University of the Incarnate Word(道成肉身大学)

Nafis Tanveer Islam, Joseph Khoury, Andrew Seong, Mohammad Bahrami Karkevandi, Gonzalo De La Torre Parra, Elias Bou-Harb, Peyman Najafirad

AI总结:

本文提出SecRepair系统,利用CodeGen2大语言模型结合强化学习与语义奖励机制,在生成漏洞修复代码的同时提供完整漏洞描述,并在6个开源物联网操作系统中验证了其对零日及N日漏洞的识别与修复能力。

摘要:

在软件开发中,对功能性的侧重往往超过对安全性的关注,这一趋势随着GitHub Copilot等AI驱动自动化工具的兴起而进一步加剧。这些工具显著提升了开发人员在功能代码开发方面的效率。然而,一个值得注意的问题是,这类工具同样会生成不安全的代码,主要原因是其在包含漏洞代码的公开仓库上进行了预训练。此外,开发人员被称为“链条中最薄弱的环节”,因为他们对代码安全的知识非常有限。尽管现有解决方案为漏洞代码提供了合理的修复方案,但它们必须充分描述并向开发人员传授代码安全知识,以确保安全问题不会重复出现。因此,我们引入了一个多用途代码漏洞分析系统SecRepair,该系统由大语言模型CodeGen2驱动,帮助开发人员识别并生成修复后的代码,同时通过代码注释提供对漏洞的完整描述。我们的创新方法采用强化学习范式来生成代码注释,并辅以语义奖励机制。受人类修复代码问题方式的启发,我们提出了一个适用于基于LLM进行漏洞分析的指令式数据集。我们进一步在GitHub上的6个开源物联网操作系统中识别出零日漏洞和N日漏洞。我们的研究结果强调,将强化学习与语义奖励相结合能够提升模型性能,从而增强其更有效地处理代码漏洞的能力。

英文摘要:

In software development, the predominant emphasis on functionality often supersedes security concerns, a trend gaining momentum with AI-driven automation tools like GitHub Copilot. These tools significantly improve developers' efficiency in functional code development. Nevertheless, it remains a notable concern that such tools are also responsible for creating insecure code, predominantly because of pre-training on publicly available repositories with vulnerable code. Moreover, developers are called the "weakest link in the chain" since they have very minimal knowledge of code security. Although existing solutions provide a reasonable solution to vulnerable code, they must adequately describe and educate the developers on code security to ensure that the security issues are not repeated. Therefore we introduce a multipurpose code vulnerability analysis system \texttt{SecRepair}, powered by a large language model, CodeGen2 assisting the developer in identifying and generating fixed code along with a complete description of the vulnerability with a code comment. Our innovative methodology uses a reinforcement learning paradigm to generate code comments augmented by a semantic reward mechanism. Inspired by how humans fix code issues, we propose an instruction-based dataset suitable for vulnerability analysis with LLMs. We further identify zero-day and N-day vulnerabilities in 6 Open Source IoT Operating Systems on GitHub. Our findings underscore that incorporating reinforcement learning coupled with semantic reward augments our model's performance, thereby fortifying its capacity to address code vulnerabilities with improved efficacy.

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

↑