Semantics-Aligned, Curriculum-Driven, and Reasoning-Enhanced Vulnerability Repair Framework

Chengran Yang, Ting Zhang, Jinfeng Jiang, Xin Zhou, Haoye Tian, Jieke Shi, Junkai Chen, Yikun Li, Eng Lieh Ouh, Lwin Khin Shar, David LoarXiv 2025 · DOI

Introduction

Automated Vulnerability Repair (AVR) has traditionally been framed as a neural machine translation task, where models learn to map vulnerable code snippets to their patched counterparts. While this approach has shown promise, it often results in models that memorize superficial lexical patterns rather than understanding the underlying security logic. This paper introduces SeCuRepair, a framework designed to move beyond token-level mimicry by integrating reasoning-based fine-tuning and semantics-aware reinforcement learning.

The Problem: Limitations of Current AVR Models

Current AVR models, typically trained via Supervised Fine-Tuning (SFT) on large datasets, suffer from three critical weaknesses:

  1. Cross-Repository Failure: Models perform well on test data from repositories seen during training but fail significantly on entirely new projects. This suggests they are overfitting to repository-specific naming conventions and coding styles.
  2. Syntactic Brittleness: Minor, non-functional changes to code (like variable renaming) can cause models to fail, indicating a lack of semantic understanding.
  3. Multi-Hunk Collapse: As the complexity of a repair increases—requiring edits across multiple "hunks" or regions—model performance drops precipitously.
Performance degradation of existing models when moving from random to repository-level data splits.

As shown in Figure 1, the transition from a random data split to a more rigorous repository-level split reveals a massive performance gap, highlighting the generalization crisis in existing AVR approaches.

The SeCuRepair Framework

To address these issues, SeCuRepair implements a two-stage training pipeline that prioritizes reasoning and functional correctness.

The two-stage SeCuRepair pipeline: Reasoning-Transferred SFT and Semantics-Aware Reinforcement Learning.

Stage 1: Reasoning-Transferred SFT

Instead of training the model to jump directly to a patch, SeCuRepair employs a "Reason-then-Edit" strategy. The model is first fine-tuned to generate a natural language explanation of the vulnerability and the logic behind the proposed fix. These reasoning traces are distilled from a powerful teacher model (GPT-5 mini) and refined through rejection sampling. By forcing the model to articulate its plan, the framework creates a semantic "anchor" that prevents blind token guessing.

Stage 2: Semantics-Aware Reinforcement Learning (RL)

The second stage utilizes Group Relative Policy Optimization (GRPO) to further refine the model. Unlike standard RL which might rely on simple text overlap (BLEU), SeCuRepair introduces a multi-faceted reward function:

  • Syntactic Agreement: Measured via Abstract Syntax Tree (AST) similarity.
  • Semantic Agreement: Measured via Data Flow Graph (DFG) similarity.

This approach ensures the model is rewarded for generating patches that are functionally equivalent to the ground truth, even if the exact wording differs.

Difficulty-Aware Curriculum

To tackle the multi-hunk collapse, the RL stage follows a curriculum. The model is initially trained on simple, single-hunk repairs and progressively moves toward complex vulnerabilities requiring coordinated edits across multiple regions. This prevents the model from being overwhelmed by complexity early in the learning process.

Evaluation and Results

The framework was evaluated using a strict repository-level split of the BigVul dataset and a new, out-of-distribution benchmark called PrimeVul_AVR.

Quantitative Performance

SeCuRepair demonstrated superior generalization capabilities:

  • Vs. Baselines: On the BigVul repository split, it outperformed the leading baseline, VulMaster, by 34.52% in CodeBLEU.
  • Vs. LLMs: On the unseen PrimeVul_AVR dataset, it surpassed GPT-4o by 31.52%.

Qualitative Human Evaluation

Security experts conducted a blind review of the generated patches. SeCuRepair produced 58.0% workable patches, significantly higher than GPT-4o (50.0%) and VulMaster (20.0%).

Ablation Insights

Ablation studies confirmed the value of each component. The addition of RL provided a ~15.9% boost, while the inclusion of semantic rewards (AST/DFG) added another ~7.7%. Notably, the curriculum learning strategy improved performance on highly complex repairs (10+ hunks) by ~9.5%.

Conclusion

SeCuRepair represents a shift in AVR from pattern matching to semantic reasoning. By combining reasoning-based SFT with semantics-aware RL and curriculum learning, the framework achieves state-of-the-art performance and robust generalization. Future work will focus on extending these language-agnostic principles to other programming languages beyond C/C++.

Summary updated

BibTeX
@misc{yang2025semantics,
  author = {Chengran Yang and Ting Zhang and Jinfeng Jiang and Xin Zhou and Haoye Tian and Jieke Shi and Junkai Chen and Yikun Li and Eng Lieh Ouh and Lwin Khin Shar and David Lo},
  title = {{Semantics-Aligned, Curriculum-Driven, and Reasoning-Enhanced Vulnerability Repair Framework}},
  year = {2025},
  eprint = {2510.01002},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.01002},
}
Figure