From SFT to RL: Demystifying the Post-Training Pipeline for LLM-based Vulnerability Detection
On the map: LLM alignment / RLHF / preference optimisation → Safety alignment and jailbreak attacks
Abstract (arXiv)
The integration of LLMs into vulnerability detection (VD) has shifted the field toward more interpretable and context-aware analysis. While post-training techniques have shown promise in general coding tasks, their systematic application to VD remains underexplored. In this paper, we present the first comprehensive investigation into the post-training pipeline for LLM-based VD, demonstrating that on-policy RL with GRPO consistently outperforms SFT, off-policy preference optimization methods, and specialized VD LLMs. Our study further reveals VD-specific post-training guidelines and insights beyond common practices: (1) For data curation, contrary to the widespread use of rationalization-based supervision in prior VD work, SFT based on rejection sampling proves more effective, as rationalization can introduce hallucinations; in RL training, the inherently skewed difficulty distribution of vulnerabilities leads difficulty-aware data filtering to drastically reduce data coverage, causing non-negligible performance loss, and undermines curriculum learning, while pair-based data scheduling can partially mitigate this. (2) For stage interactions, unlike preference optimization typically applied to lightly trained SFT models, increasing SFT epochs consistently benefits off-policy preference optimization in VD tasks; however, excessive SFT suppresses self-exploration in on-policy RL, limiting its gains. (3) For reward mechanisms, naively treating vulnerability classification correctness as reward signals leads to reward hacking, whereas fine-grained root-cause judgments provide more reliable credit assignment; specification-based rewards further improve efficiency at the cost of additional design and generation effort. (4) For evaluation protocols, LLM-as-a-Judge based on root-cause analysis offers a more robust alternative, albeit with variability across judge models.
Key facts. Cited by 4 papers in the map (data through 7 Oct 2026). Placed in Safety alignment and jailbreak attacks, one of 10 directions in LLM alignment / RLHF / preference optimisation. Builds on 65 of its 85 references that are in the map. First posted on arXiv 15 Feb 2026.
Builds on
65 of 85 references.
Closest ancestors · 3
Same direction, newest first
- 2025Smart-LLaMA-DPO: Reinforced Large Language Model for Explainable Smart Contract Vulnerability Detection23 Jun
- 2025Boosting Vulnerability Detection of LLMs via Curriculum Preference Optimization with Synthetic Reasoning Data9 Jun
- 2025R2Vul: Learning to Reason about Software Vulnerabilities with Reinforcement Learning and Structured Reasoning Distillation7 Apr
Other references · 62
- 2017Proximal Policy Optimization Algorithmscited by 14,441
- 2024DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Modelscited by 8,851
- 2023Direct Preference Optimization: Your Language Model is Secretly a Reward Modelcited by 7,916
- 2025DAPO: An Open-Source LLM Reinforcement Learning System at Scalecited by 2,678
- 2024SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineeringcited by 1,628
- 2025Understanding R1-Zero-Like Training: A Critical Perspectivecited by 1,276
- 2025Kimi k1.5: Scaling Reinforcement Learning with LLMscited by 1,193
- 2024Qwen2.5-Math Technical Report: Toward Mathematical Expert Model via Self-Improvementcited by 1,057
- 2024SimPO: Simple Preference Optimization with a Reference-Free Rewardcited by 951
- 2024ORPO: Monolithic Preference Optimization without Reference Modelcited by 556
- 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 266
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 149
38 more
- 2020Deep Learning based Vulnerability Detection: Are We There Yet?cited by 142
- 2024Vulnerability Detection with Code Language Models: How Far Are We?cited by 133
- 2023DiverseVul: A New Vulnerable Source Code Dataset for Deep Learning Based Vulnerability Detectioncited by 98
- 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 94
- 2021CVEfixes: Automated Collection of Vulnerabilities and Their Fixes from Open-Source Softwarecited by 89
- 2025AceReason-Nemotron 1.1: Advancing Math and Code Reasoning through SFT and RL Synergycited by 75
- 2025SEC-bench: Automated Benchmarking of LLM Agents on Real-World Software Security Taskscited by 69
- 2024Vul-RAG: Enhancing LLM-based Vulnerability Detection via Knowledge-level RAGcited by 67
- 2023Understanding the Effectiveness of Large Language Models in Detecting Security Vulnerabilitiescited by 58
- 2024LLM4Vuln: A Unified Evaluation Framework for Decoupling and Enhancing LLMs' Vulnerability Reasoningcited by 57
- 2025Magistralcited by 57
- 2023Prompt-Enhanced Software Vulnerability Detection Using ChatGPTcited by 51
- 2024EnIGMA: Interactive Tools Substantially Assist LM Agents in Finding Security Vulnerabilitiescited by 51
- 2023Large Language Model-Powered Smart Contract Vulnerability Detection: New Perspectivescited by 48
- 2023ChatGPT for Vulnerability Detection, Classification, and Repair: How Far Are We?cited by 44
- 2024Finetuning Large Language Models for Vulnerability Detectioncited by 39
- 2024ReposVul: A Repository-Level High-Quality Vulnerability Datasetcited by 35
- 2024Generalization-Enhanced Code Vulnerability Detection via Multi-Task Instruction Fine-Tuningcited by 30
- 2025Benchmarking LLMs and LLM-based Agents in Practical Vulnerability Detection for Code Repositoriescited by 29
- 2023How Far Have We Gone in Vulnerability Detection Using Large Language Modelscited by 27
- 2024MegaVul: A C/C++ Vulnerability Dataset with Comprehensive Code Representationcited by 27
- 2024Top Score on the Wrong Exam: On Benchmarking in Machine Learning for Vulnerability Detectioncited by 27
- 2025Quagmires in SFT-RL Post-Training: When High SFT Scores Mislead and What to Use Insteadcited by 24
- 2024Multitask-based Evaluation of Open-Source LLM on Software Vulnerabilitycited by 23
- 2025PatchPilot: A Cost-Efficient Software Engineering Agent with Early Attempts on Formal Verificationcited by 22
- 2025Let the Trial Begin: A Mock-Court Approach to Vulnerability Detection using LLM-Based Agentscited by 20
- 2025SecVulEval: Benchmarking LLMs for Real-World C/C++ Vulnerability Detectioncited by 19
- 2024VulEval: Towards Repository-Level Evaluation of Software Vulnerability Detectioncited by 18
- 2024APPATCH: Automated Adaptive Prompting Large Language Models for Real-World Software Vulnerability Patchingcited by 18
- 2025PurpCode: Reasoning for Safer Code Generationcited by 17
- 2024Outside the Comfort Zone: Analysing LLM Capabilities in Software Vulnerability Detectioncited by 16
- 2025Everything You Wanted to Know About LLM-based Vulnerability Detection But Were Afraid to Askcited by 15
- 2024Security Vulnerability Detection with Multitask Self-Instructed Fine-Tuning of Large Language Modelscited by 14
- 2023SecureFalcon: Are We There Yet in Automated Software Vulnerability Detection with LLMs?cited by 13
- 2025Training Language Models to Generate Quality Code with Program Analysis Feedbackcited by 11
- 2025VulnLLM-R: Specialized Reasoning LLM with Agent Scaffold for Vulnerability Detectioncited by 11
- 2024On the Effectiveness of Function-Level Vulnerability Detectors for Inter-Procedural Vulnerabilitiescited by 10
- 2025SV-TrustEval-C: Evaluating Structure and Semantic Reasoning in Large Language Models for Source Code Vulnerability Analysiscited by 8
50 most cited of 62 All 62 (JSON)
Built on by
Citing papers per year: 2026: 4.
4 papers.
- 2026TOSSS: a CVE-based Software Security Benchmark for Large Language Modelscited by 1
- 2026ALIBI: Adaptive Agentic Attacks on LLM-Based Vulnerability Detectors via Adversarial Code Commentscited by 0
- 2026A Function-Level Vulnerability Score Measures Flag Rate More Than the Model: Protocol Effects on Paired Benchmarkscited by 0
- 2026Retrieve, Reproduce, Reveal: Dissecting Retrieval-Augmented Software Vulnerability Detectioncited by 0
- 2026Retrieve, Reproduce, Reveal: Dissecting Retrieval-Augmented Software Vulnerability Detection29 Sep 2026
- 2026A Function-Level Vulnerability Score Measures Flag Rate More Than the Model: Protocol Effects on Paired Benchmarks26 Sep 2026
- 2026ALIBI: Adaptive Agentic Attacks on LLM-Based Vulnerability Detectors via Adversarial Code Comments27 Jul 2026
- 2026TOSSS: a CVE-based Software Security Benchmark for Large Language Models11 Mar 2026
Similar, not cited
Close in wording, no citation either way
- 2026VulTriage: Triple-Path Context Augmentation for LLM-Based Vulnerability Detection
- 2025VULPO: Context-Aware Vulnerability Detection via On-Policy LLM Optimization
- 2026VulWeaver: Weaving Broken Semantics for Grounded Vulnerability Detection
- 2025VulInstruct: Teaching LLMs Root-Cause Reasoning for Vulnerability Detection via Security Specifications
- 2024VulScribeR: Exploring RAG-based Vulnerability Augmentation with LLMs
- 2024To Err is Machine: Vulnerability Detection Challenges LLM Reasoning
- 2026Do Fine-Tuned LLMs Understand Vulnerabilities? An Investigation into the Semantic Trap
- 2026Calibration Without Comprehension: Diagnosing the Limits of Fine-Tuning LLMs for Vulnerability Detection in Systems Software