脆弱性報酬モデルを用いたオンライン強化学習による安全なコード生成
Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model
February 7, 2026
著者: Tianyi Wu, Mingzhe Du, Yue Liu, Chengran Yang, Terry Yue Zhuo, Jiaheng Zhang, See-Kiong Ng
cs.AI
要旨
大規模言語モデル(LLM)はソフトウェア開発においてますます利用が増えているが、安全でないコードを生成する傾向は、実世界での導入における主要な障壁となっている。既存の安全なコード整合性手法は、機能性とセキュリティのジレンマに悩まされることが多く、実用性を大幅に損なう代償としてセキュリティを向上させている。本研究では、機能性を維持した安全なコード生成のためのオンライン強化学習フレームワークであるSecCoderXを提案する。SecCoderXはまず、成熟した検出リソースを二つの方法で転用することで、脆弱性検出と安全なコード生成を橋渡しする:(i)オンラインRLロールアウトのための多様で現実に基づいた脆弱性誘発コーディングタスクの合成、(ii)スケーラブルで信頼性の高いセキュリティ監督を提供する推論ベースの脆弱性報酬モデルの訓練。これらのコンポーネントはオンラインRLループで統合され、コードLLMを整合させて安全かつ機能的なコードを生成する。大規模な実験により、SecCoderXが最先端の性能を達成し、非整合モデルに比べて有効安全率(ESR)を約10%向上させる一方、従来手法ではESRが14-54%低下することが多いことを実証した。コード、データセット、モデルチェックポイントはhttps://github.com/AndrewWTY/SecCoderX で公開している。
English
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.