Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model

About

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.

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

Related benchmarks

TaskDatasetResultRank
Code GenerationHumanEval+
Pass@182.74
189
Code GenerationMBPP+
Pass@167.49
122
Vulnerability DetectionPrimeVul
F1 Score61.96
24
Secure Code GenerationCWEval
Safety42.02
17
Secure Code GenerationCyberSecEval SCG
Safety73.56
17
Vulnerability DetectionSVEN
F1 Score0.6855
14
Secure Code GenerationSecure Code Average
Safety Score55.36
12
Vulnerability DetectionR2Vul
Precision72.66
8
Vulnerability DetectionAverage
Precision59.37
8
Vulnerability DetectionProSec
Precision56.64
8
Showing 10 of 10 rows

Other info

GitHub

Follow for update