ProSec: Fortifying Code LLMs with Proactive Security Alignment

Xiangzhe Xu, Zian Su, Jinyao Guo, Kaiyuan Zhang, Zhenting Wang +1 more
2/12/2026

No official code found. Best implementation: PurCL/ProSec (18 stars, last commit 2026-02-26).

Abstract

While recent code-specific large language models (LLMs) have greatly enhanced their code generation capabilities, the safety of these models remains under-explored, posing potential risks as insecure code generated by these models may introduce vulnerabilities into real-world systems. Existing methods collect security-focused datasets from real-world vulnerabilities for instruction tuning in order to mitigate such issues. However, they are largely constrained by the data sparsity of vulnerable code, and have limited applicability in the multi-stage post-training workflows of modern LLMs. In this paper, we propose ProSec, a novel proactive security alignment approach designed to align code LLMs with secure coding practices. ProSec systematically exposes the vulnerabilities in a code LLM by synthesizing vulnerability-inducing coding scenarios from Common Weakness Enumerations (CWEs) and generates fixes to vulnerable code snippets, allowing the model to learn secure practices through preference learning objectives. The scenarios synthesized by ProSec trigger 25x more vulnerable code than a normal instruction-tuning dataset, resulting in a security-focused alignment dataset 7x larger than the previous work. Experiments show that models trained with ProSec are 25.2% to 35.4% more secure compared to previous work without degrading models' utility.

View on arXivView PDF

Code Implementations(1)

PurCL/ProSecCommunity100%

Official repo for "ProSec: Fortifying Code LLMs with Proactive Security Alignment"

181Shell, PythonNov 17, 20247 months ago
alignmentcode-generationcode-language-modellarge-language-modelspost-training

Similar Papers

Cite this paper

@article{xu2026prosec,
  title  = {ProSec: Fortifying Code LLMs with Proactive Security Alignment},
  author = {Xiangzhe Xu and Zian Su and Jinyao Guo and Kaiyuan Zhang and Zhenting Wang and Xiangyu Zhang},
  year   = {2026},
  eprint = {2411.12882},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2411.12882},
  journal = {ICML 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2411.12882.svg)](https://codeofpaper.com/paper/2411.12882)

Discussion