Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Wu, Tianyi, Du, Mingzhe, Liu, Yue, Yang, Chengran, Zhuo, Terry Yue, Zhang, Jiaheng, Ng, See-Kiong
Formato: Preprint
Publicado: 2026
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866915784080490496
author Wu, Tianyi
Du, Mingzhe
Liu, Yue
Yang, Chengran
Zhuo, Terry Yue
Zhang, Jiaheng
Ng, See-Kiong
author_facet Wu, Tianyi
Du, Mingzhe
Liu, Yue
Yang, Chengran
Zhuo, Terry Yue
Zhang, Jiaheng
Ng, See-Kiong
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2602_07422
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model
Wu, Tianyi
Du, Mingzhe
Liu, Yue
Yang, Chengran
Zhuo, Terry Yue
Zhang, Jiaheng
Ng, See-Kiong
Cryptography and Security
Artificial Intelligence
Computation and Language
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.
title Secure Code Generation via Online Reinforcement Learning with Vulnerability Reward Model
topic Cryptography and Security
Artificial Intelligence
Computation and Language
url https://arxiv.org/abs/2602.07422