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

通过在线强化学习与漏洞奖励模型实现安全代码生成

Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model

National University of Singapore(国立新加坡大学);Singapore Management University(新加坡管理学院);Nanyang Technological University(南洋理工大学);Monash University(墨尔本大学)

Tianyi Wu, Mingzhe Du, Yue Liu, Chengran Yang, Terry Yue Zhuo, Jiaheng Zhang, See-Kiong Ng

AI总结:

SecCoderX通过在线强化学习与漏洞奖励模型提升代码安全性,实现功能与安全性的平衡。

摘要:

大型语言模型(LLMs)在软件开发中被越来越多地使用,但其生成不安全代码的倾向仍然是实际部署的主要障碍。现有的安全代码对齐方法往往面临功能与安全性的矛盾,提高安全性会以显著的实用性退化为代价。我们提出了SecCoderX,一种用于功能保持的安全代码生成的在线强化学习框架。SecCoderX首先通过重新利用成熟的检测资源以两种方式弥合漏洞检测与安全代码生成之间的鸿沟:(i)合成多样且现实基础的漏洞诱导编码任务用于在线RL回放;(ii)训练一个基于推理的漏洞奖励模型,提供可扩展且可靠的安保监督。这些组件在在线RL循环中统一,以对齐代码LLMs生成安全且功能性的代码。广泛的实验表明,SecCoderX在性能上达到了最先进的水平,其有效安全性率(ESR)比未对齐的模型提高了约10%,而先前的方法通常会使ESR下降14-54%。我们在此发布我们的代码、数据集和模型检查点,网址为https://github.com/AndrewWTY/SecCoderX。

英文摘要:

Large language models (LLMs) are increasingly used in software development, yet their tendency to generate insecure code remains a major barrier to real-world deployment. Existing secure code alignment methods often suffer from a functionality--security paradox, improving security at the cost of substantial utility degradation. We propose SecCoderX, an online reinforcement learning framework for functionality-preserving secure code generation. SecCoderX first bridges vulnerability detection and secure code generation by repurposing mature detection resources in two ways: (i) synthesizing diverse, reality-grounded vulnerability-inducing coding tasks for online RL rollouts, and (ii) training a reasoning-based vulnerability reward model that provides scalable and reliable security supervision. Together, these components are unified in an online RL loop to align code LLMs to generate secure and functional code. Extensive experiments demonstrate that SecCoderX achieves state-of-the-art performance, improving Effective Safety Rate (ESR) by approximately 10% over unaligned models, whereas prior methods often degrade ESR by 14-54%. We release our code, dataset and model checkpoints at https://github.com/AndrewWTY/SecCoderX.

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

↑