Refinement-Integrated Reasoning Elicits Better Generalization of LLM-Based Code Vulnerability Detection

Xianda Du, Pei Ke, Enping Hu, Guannan Li, Jinyu Guo, Ke Qin


Abstract
Existing code vulnerability detection (CVD) methods face severe challenges in terms of generalization. Most of these methods directly map the source code to a binary vulnerability label or a vulnerability explanation, struggling to capture the deep features within the complex relationship between them. Thus, these works fail to generalize to out-of-distribution data well. To address this issue, we propose a simple yet effective training framework called refinement-integrated reasoning (RIRE), leveraging refinements that indicate the patched code in the CVD task. Firstly, RIRE introduces the refinement as a guiding signal to help LLMs synthesize reasoning chains as explanations, which align with the vulnerability label, and uses these data for supervised fine-tuning. Secondly, refinement is utilized through a hierarchical preference optimization framework to help determine which reasoning-enhanced detection result is of higher quality, further mining essential features for fine-grained distinguishability and detection capability. Experimental results across five benchmark datasets demonstrate that our proposed RIRE framework achieves superior performance over strong baselines, especially being more generalizable to unseen datasets during training.
Anthology ID:
2026.findings-emnlp.1933
Volume:
Findings of the Association for Computational Linguistics: EMNLP 2026
Month:
October
Year:
2026
Address:
Budapest, Hungary
Editors:
Hung-Yi Lee, Sunipa Dev, Jessy Li, Desmond Elliott
Venue:
Findings
SIG:
SIGDAT
Publisher:
Association for Computational Linguistics
Note:
Pages:
41215–41233
Language:
URL:
https://aclanthology.org/2026.findings-emnlp.1933/
DOI:
Bibkey:
Cite (ACL):
Xianda Du, Pei Ke, Enping Hu, Guannan Li, Jinyu Guo, and Ke Qin. 2026. Refinement-Integrated Reasoning Elicits Better Generalization of LLM-Based Code Vulnerability Detection. In Findings of the Association for Computational Linguistics: EMNLP 2026, pages 41215–41233, Budapest, Hungary. Association for Computational Linguistics.
Cite (Informal):
Refinement-Integrated Reasoning Elicits Better Generalization of LLM-Based Code Vulnerability Detection (Du et al., Findings 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.findings-emnlp.1933.pdf