Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model
Tianyi Wu, Mingzhe Du, Yue Liu, Chengran Yang, Terry Yue Zhuo, Jiaheng Zhang, See-Kiong Ng

TL;DR
SecCoderX is an online reinforcement learning framework that enhances large language models to generate secure, functional code by leveraging vulnerability detection and a specialized reward model, significantly improving security without utility loss.
Contribution
The paper introduces SecCoderX, a novel online RL approach that aligns code generation with security and functionality, overcoming the security-utility trade-off in prior methods.
Findings
Achieves approximately 10% higher Effective Safety Rate (ESR) than unaligned models.
Outperforms prior methods that degrade ESR by 14-54%.
Provides publicly available code, dataset, and model checkpoints.
Abstract
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
- SecCoderX/SecCoderX_Reward_Model_GRPO_datasetdataset· 12 dl12 dl
- SecCoderX/SecCoderX_CodeLlama_7b_GRPO_datasetdataset· 9 dl9 dl
- SecCoderX/SecCoderX_Qwen2.5_Coder_3B_GRPO_datasetdataset· 18 dl18 dl
- SecCoderX/SecCoderX_Qwen2.5_Coder_7B_GRPO_datasetdataset· 13 dl13 dl
- SecCoderX/SecCoderX_Reality_Grounded_Vulnerability_Inducing_Prompts_for_GRPOdataset· 26 dl26 dl
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsAdvanced Malware Detection Techniques · Software Engineering Research · Information and Cyber Security
