Detecting Vulnerability-Inducing Commits via Multi-Stage Reasoning with LLM-Based Agents


Abstract

Detecting vulnerability-inducing commits (VICs) at submission time is critical for improving the security and reliability of software systems. However, this task is highly challenging because it requires reasoning about the semantic impact of code changes from heterogeneous information sources, including code diffs, commit messages, and the surrounding contextual code. Existing approaches often struggle to fully capture these complex interactions, resulting in limited detection performance. In this paper, we propose VIC-RAGENT, an LLM-based multi-agent framework for effective and explainable vulnerability detection. VIC-RAGENT leverages multiple specialized agents to provide complementary perspectives, including structural analysis, intent understanding, and vulnerability inspection. To further improve detection reliability, the framework employs a multi-stage reasoning process that progressively refines candidate vulnerabilities through preliminary inspection, reanalysis, and a final decision stage. Experimental results on a real-world dataset across multiple LLMs demonstrate that VIC-RAGENT consistently outperforms baselines, including Direct, CoT, and CodeAgent. Compared to the strongest baseline, VIC-RAGENT achieves 1.2–1.7× higher F1-scores across different models. Overall, VIC-RAGENT offers a robust, explainable, and practical solution for detecting VICs in modern software development workflows.

1 Introduction↩︎

Open source software (OSS) has become fundamental infrastructure for modern software systems [1], [2], but its collaborative development model enlarges the software supply chain attack surface [3]. In large-scale projects with continuous integration, even minor code changes may unintentionally introduce exploitable weaknesses [4]. Prior studies [4], [5] show that many vulnerabilities originate from vulnerability-inducing commits (VICs) [6], which introduce security flaws during routine development activities such as feature additions and refactoring [7], [8].

Detecting whether a newly submitted commit introduces a vulnerability—known as Just-In-Time Vulnerability Detection (JIT-VD) [9]—remains a challenging task. JIT-VD aims to detect whether a commit introduces vulnerabilities based on code changes and contextual information. Existing approaches include feature-based methods and deep learning models [10], [11], but they struggle to capture commit semantics and developer intent. To address these limitations, deep learning approaches have been proposed to learn representations from code and diffs, including neural vulnerability detection systems [12], [13], graph-based models [14], [15], and transformer-based models [16]. More recently, JIT-specific models [9], [17] attempt to capture the semantics of code changes.

Recent advances in LLMs have demonstrated strong capabilities in code understanding and reasoning [18][20]. LLM-based approaches have been applied to vulnerability detection and software security analysis [21][23], including prompt-based methods and retrieval-augmented methods [24]. In addition, agent-based frameworks such as CodeAgent [25] explore automated code review. However, these approaches are primarily designed for general vulnerability detection or code review tasks, and lack specialized mechanisms for reasoning about VICs in evolving codebases. The ReAct Agent [26] introduces an iterative reasoning process based on a thought–action–observation loop, enabling LLMs to dynamically acquire additional context during analysis. This design may lead to the accumulation and propagation of errors across reasoning steps, while lacking explicit mechanisms for result verification. Such a design may make intermediate results difficult to independently verify and limit the transparency of the reasoning process. In contrast, role-specialized multi-agent systems have been shown to improve modularity and reasoning reliability by explicitly separating different reasoning objectives [27], [28].

To address these limitations, we propose VIC-RAGENT, an LLM-based multi-agent framework with a multi-stage reasoning process for detecting of VICs. VIC-RAGENT introduces a structured multi-stage reasoning pipeline with role-specialized components, enabling explicit decomposition of commit semantics, intent understanding, and vulnerability verification. VIC-RAGENT analyzes each commit by integrating multiple sources of information, including code diffs, commit messages, and file-level context. The framework adopts a multi-agent analysis workflow. Specifically, a Code Analyst agent extracts structural information, and a Target Analyst agent interprets commit intent. Vulnerability Inspector agents perform multi-stage reasoning to identify potential vulnerabilities. When a vulnerability is confirmed, a Document Specialist agent generates a security report that is stored in the knowledge base, enabling future analyzes to leverage historical vulnerability cases.

We evaluate VIC-RAGENT on the V-SZZ dataset [6] across multiple LLMs. Experiments show that VIC-RAGENT consistently improves recall and F1-score across all evaluated LLMs, achieving up to 2× recall improvement over the strongest baseline.

Our main contributions are summarized as follows:

A multi-agent framework for JIT-VD. We propose VIC-RAGENT, a multi-agent framework that analyzes potential vulnerabilities introduced by commit.

A multi-stage reasoning process. We introduce a structured inspection workflow consisting of preliminary analysis, reanalysis, and final decision, enabling coarse-to-fine reasoning for improved vulnerability detection.

Knowledge-augmented vulnerability reasoning. We design a vulnerability knowledge base that stores security reports organized by vulnerability types, allowing VIC-RAGENT to leverage historical vulnerability cases through retrieval-augmented reasoning.

Empirical evaluation on a real-world dataset. We conduct experiments on a real-world dataset, demonstrating strong detection performance across three LLMs.

The implementation of VIC-RAGENT and the dataset are available at: https://github.com/KeLeXueBi/VIC-RAGRENT.

2 Multi-Agent Analysis Framework↩︎

2.1 Framework Overview↩︎

Figure 1: The overall framework of VIC-RAGENT.
Table 1: Agents in .
Agent Input Output Responsibility
Code Analyst (CA) Diff + Context Structural summary Structural analysis
Target Analyst (TA) Diff + Message Intent summary Intent understanding
Vulnerability Inspector (VI)(stage 1) CA + TA Candidate vulnerabilities Security inspection
Vulnerability Inspector (VI)(stage 2) VI (stage 1) + Knowledge Base Refined vulnerabilities Knowledge-augmented verification
Vulnerability Inspector (VI)(stage 3) VI (stage 2) Prediction result Final decision
Document Specialist (DS) Verified VIC Security report Knowledge construction
Audit Supervisor (AS) Agent outputs Validation feedback Process verification

Fig. 1 illustrates the overall architecture of VIC-RAGENT, a multi-stage reasoning framework for detecting VICs. Table 1 summarizes the responsibilities of each agent in the framework. VIC-RAGENT performs a structured analysis through four sequential stages: preparation, preliminary inspection, reanalysis, and final decision. The output of each stage is progressively refined and passed to subsequent stages.

2.2 Stage 0: Preparation↩︎

Given a commit input, the preparation stage performs contextual analysis using two agents. The goal of this stage is to construct structured intermediate representations that capture both structural and semantic aspects of the code changes. The structural representation is constructed by the Code Analyst (CA), which extracts structural information from commit changes to help other agents understand how modified code interacts with the existing system. Given the code diff together with the file-level context, the CA summarizes structural relationships among components, including simplified call graphs and potential data flow patterns.

The intent representation is derived by the Target Analyst (TA), which interprets the intentions behind commit changes and aligns the goals described in the commit message with the modified files. The TA extracts the goals described in the commit message and categorizes them into common modification types (e.g., bug fixes, feature additions, refactoring, performance optimizations, or security patches). Inconsistencies between intended goals and implemented changes—such as incomplete implementation or unclear scope—may indicate potential risks.

Together, the structural representation and intent representation provide complementary structural and semantic views of the commit. This dual-view representation reduces ambiguity in subsequent reasoning stages and helps the Vulnerability Inspector better interpret the intent and impact of code changes.

2.3 Stage 1: Preliminary Inspection↩︎

The preliminary inspection stage can be viewed as a high-recall candidate generation step that approximates an over-complete set of potential vulnerability hypotheses. Instead of making definitive decisions, this stage intentionally relaxes verification constraints and constructs a superset of plausible vulnerability-inducing fragments.

Based on the structural information extracted by CA and the change intentions identified by TA, the Vulnerability Inspector (VI) examines modified code fragments and analyzes potential vulnerability-inducing patterns across several vulnerability categories. The analysis is not limited to the modified lines; when a change affects function behavior, variable usage, or call flow, the inspector further examines relevant surrounding code to assess potential risks.

The inspection follows a category-driven analysis strategy based on common vulnerability types observed in real-world systems. Specifically, VI evaluates code changes with respect to six vulnerability types: I/O Validation, Memory Safety, Web Security, Authentication and Authorization, Resource Management, and File/Path Handling. If suspicious code fragments are identified, VI records the relevant code segments together with their associated vulnerability type and an explanation of the potential risk. These preliminary findings are then passed to the next inspection stage for further verification and refinement. This design is particularly important for VIC detection, where vulnerabilities are often subtle and may not exhibit explicit security violations at the time of introduction. By allowing the model to flag potentially risky patterns with incomplete evidence, this stage prioritizes recall and ensures that suspicious candidates are not prematurely discarded.

2.4 Stage 2: Reanalysis↩︎

While the preliminary inspection may produce uncertain or weakly supported candidates, this stage refines them through constrained reasoning over the hypothesis space. Each hypothesis is re-evaluated under additional constraints, including its predicted vulnerability type and contextual consistency with the commit. Compared to Stage 1, which prioritizes coverage, this stage focuses on improving the reliability of hypotheses by enforcing structured constraints.

In practice, the Vulnerability Inspector (VI) performs type-guided reanalysis on each candidate fragment based on its predicted vulnerability category. In addition, the system may retrieve similar historical cases from the vulnerability knowledge base using a retrieval-augmented generation (RAG) mechanism. When available, similar historical cases are retrieved from the vulnerability knowledge base and incorporated as additional evidence. If no sufficiently similar cases are found, the analysis proceeds using only the available contextual information. This design enables case-based reasoning while avoiding over-dependence on the knowledge base. The output of this stage is a refined set of fragment-level hypotheses, which are passed to the final decision stage.

2.5 Stage 3: Final Decision↩︎

Although the reanalysis stage refines candidate hypotheses, uncertainty in LLM reasoning may still affect the final assessment. This stage produces a commit-level vulnerability decision through structured verification and aggregation.

Given the refined hypothesis set, each hypothesis is independently verified under a more conservative reasoning setting. A global decision is then derived by aggregating fragment-level results.

In practice, VI performs fragment-level verification under a low-temperature configuration to produce more deterministic and conservative judgments. A commit is classified as vulnerability-inducing if at least one fragment is confirmed as vulnerable; otherwise, it is classified as non-vulnerable.

If the commit is determined to be vulnerable, the Document Specialist (DS) generates a security report summarizing the detected issues, which is stored in the vulnerability knowledge base for future retrieval. Throughout the process, the Audit Supervisor (AS) monitors agent outputs and verifies whether they satisfy predefined requirements, ensuring consistency of the multi-stage reasoning process.

2.6 Vulnerability Knowledge Base↩︎

To support knowledge-augmented vulnerability reasoning, VIC-RAGENT maintains a vulnerability knowledge base that stores historical vulnerability analysis results generated during previous inspections. This knowledge base enables the system to reuse prior vulnerability cases during the reanalysis stage. The knowledge base is organized using a two-level structure. At the top level, reports are grouped by high-level vulnerability categories, and at the second level, each entry contains a security report describing a VIC. To enable efficient retrieval, VIC-RAGENT maintains a vector index over the stored cases. Each commit is encoded into a fixed-length embedding using a pretrained code model (e.g., CodeBERT [29]), and the embeddings are associated with the corresponding reports for similarity-based retrieval.

During the reanalysis, the system retrieves similar historical cases based on embedding similarity. The retrieved cases provide reference examples that support case-based reasoning, helping the model assess whether the current commit exhibits similar vulnerability patterns. Whenever a commit is confirmed to be vulnerable by VIC-RAGENT, its security report and embedding are added to the knowledge base, enabling continuous expansion. To mitigate this issue, the system periodically removes reports corresponding to FP cases, retaining only reliable vulnerability instances and preventing error propagation.

3 Implementation↩︎

3.1 LLM Configuration↩︎

Table 2: Temperature configuration for different agent roles / Stages.
Role / Stage Temperature
CA 0.2
TA 0.2
VI (Stage 1) 0.4
VI (Stage 2) 0.4
VI (Stage 3) 0.1
DS 0.3
AS 0.1

VIC-RAGENT relies on LLMs to perform reasoning tasks across different agent roles. We evaluate the framework using three LLMs: DeepSeek-V3.2 [30], Qwen-Plus [31], and GPT-4o-mini [32]. Each agent role is implemented with the same LLM per experiment. VIC-RAGENT is evaluated using three LLMs: DeepSeek-V3.2 [30], Qwen-Plus [31], and GPT-4o-mini [32]. All agent roles use the same underlying LLM within each experiment. Table 2 summarizes the temperature settings adopted for different stages and agent roles. The same prompts and workflows are used across all LLMs. To ensure a fair comparison, all experiments use the same prompts and agent workflows across all LLMs.

3.2 Agent Prompt Design↩︎

VIC-RAGENT uses role-specific prompt templates with JSON outputs for intermediate communication; full prompts and implementation details are publicly available.

3.3 Embedding and Retrieval↩︎

Commit diffs are encoded using CodeBERT [29] and stored in a vector index. During Stage 2, the current commit is encoded with the same model and matched against historical cases using cosine similarity. Only the most similar case is retrieved and used when similarity exceeds 0.85.

Knowledge base maintenance. Since the knowledge base is incrementally updated using model-generated reports, it may be affected by false positive (FP) predictions. To mitigate this issue, we periodically remove reports corresponding to FP cases, retaining only reliable vulnerability instances. For example, if a commit is predicted as vulnerable by the preliminary analysis but the ground truth label indicates it is not, it is considered an FP and removed.

4 Experimental Setup↩︎

4.1 Research Questions↩︎

To evaluate the effectiveness of VIC-RAGENT for detecting VICs, we design a series of experiments to answer the following research questions.

RQ1: How effective is VIC-RAGENT in detecting VICs compared with existing approaches?

RQ2: How does the multi-agent collaboration contribute to vulnerability detection performance?

RQ3: What is the computational cost of VIC-RAGENT, and how does it compare with baseline methods?

RQ4: Can VIC-RAGENT generalize to unseen vulnerabilities without relying on memorized knowledge?

4.2 Dataset↩︎

We evaluate VIC-RAGENT on the V-SZZ dataset [6], which contains manually curated vulnerability-inducing commits (VICs) and vulnerability-fixing commits (VFCs). Following the original evaluation protocol, we start from 360 commits (172 VICs and 188 VFCs).

To construct a binary classification dataset for VIC detection, commits labeled as both VIC and VFC are treated as VICs. We further remove commits that exceed the LLM context window, cannot be decoded, cannot be retrieved from the original repositories, or fail during framework execution.

After preprocessing, the final dataset contains 241 commits, including 106 VICs and 135 VFCs. Among these commits, approximately 80% belong to paired vulnerability records, meaning that a VFC is associated with one or more corresponding VICs.

4.3 Baselines↩︎

We compare VIC-RAGENT with three representative baselines based on LLMs.

Direct LLM. In this baseline, the commit information (including the commit message, code diff, and file context) is directly provided to the LLM, which produces a binary prediction indicating whether the commit introduces a vulnerability. This setting represents a vanilla prompting approach without structured reasoning or agent-based decomposition.

Chain-of-Thought (CoT). This baseline extends direct prompting by instructing a single LLM to perform explicit step-by-step reasoning before producing the final binary decision. The model is asked to summarize the commit changes, identify security-relevant code fragments, analyze whether the changes may introduce a new vulnerability, and then output a commit-level yes/no prediction.

CodeAgent. CodeAgent [25] is an LLM-based agent framework designed for automated code review. In CodeAgent, security analysis is treated as one of the code review subtasks. The framework requires the LLM agent to evaluate the security of a commit based on a predefined set of 25 vulnerability factors proposed by the authors. These factors capture common vulnerability patterns and risky coding practices, guiding the agent to assess whether a commit may introduce security risks.

4.4 Evaluation Metrics↩︎

Following prior work, we evaluate commit-level classification performance using Precision, Recall, and F1-score.

5 Experimental Results↩︎

5.1 Overall Performance↩︎

Table 3: Performance comparison.
LLM Method Precision Recall F1-score
DeepSeek-V3.2 Direct 67% 9% 16%
CoT 86% 6% 11%
CodeAgent 64% 22% 33%
70% 48% 57%
GPT-4o-mini Direct 18% 8% 11%
CoT 57% 15% 24%
CodeAgent 41% 60% 49%
50% 75% 60%
Qwen-Plus Direct 75% 28% 41%
CoT 77% 19% 31%
CodeAgent 52% 58% 55%
76% 58% 66%

Table 3 presents the performance comparison between VIC-RAGENT and baseline methods across three LLMs.

Substantial improvement in recall. Across all evaluated LLMs, VIC-RAGENT consistently achieves significantly higher recall than Direct and CoT baselines. This demonstrates that VIC-RAGENT is substantially more effective in identifying VICs, which is critical in security scenarios where missed vulnerabilities can lead to severe consequences [33].

Limitations of Direct and CoT baselines. Direct and CoT generally achieve high precision but extremely low recall. For instance, CoT with DeepSeek-V3.2 achieves a precision of 86% but only 6% recall indicating that these methods are overly conservative.

Comparison with CodeAgent. Although CodeAgent improves recall compared to Direct and CoT, it remains inferior to VIC-RAGENT across all LLMs. For example, under DeepSeek-V3.2, CodeAgent achieves an F1-score of 33%, whereas VIC-RAGENT reaches 57%. Similar trends are observed for GPT-4o-mini and QWen-Plus. These results suggest that simply introducing agent-based reasoning is insufficient; instead, the structured multi-stage design of VIC-RAGENT plays a crucial role in improving effectiveness.

5.2 Ablation Study↩︎

We conduct an ablation study using DeepSeek-V3.2 to evaluate the contribution of each component in VIC-RAGENT. Specifically, we evaluate the following variants:

w/o Code Analyst (w/o CA): The CA is removed, and the VI directly analyzes the commit without structural information extracted from code changes.

w/o Target Analyst (w/o TA): The TA is removed, and the VI performs vulnerability analysis without explicit guidance on commit intent and goal-file alignment.

w/o Stage 2: The reanalysis stage is removed, and the VI makes final decisions solely based on the preliminary inspection without refinement.

w/o Stage 3: The final decision stage is removed. The refined results from Stage 2 are directly used as the final prediction, without the additional fragment-level verification and commit-level aggregation performed in Stage 3.

Table 4: Ablation results of .
Method Precision Recall F1-score
w/o CA 65% 35% 46%
w/o TA 64% 45% 53%
w/o Stage 2 72% 43% 54%
w/o Stage 3 67% 57% 62%
70% 48% 57%
Table 5: Confusion matrix comparison of ablation variants.
Method TP FP TN FN
w/o CA 37 20 115 69
w/o TA 48 24 111 58
w/o Stage 2 46 18 117 60
w/o Stage 3 60 30 105 46
51 22 113 55

These variants allow us to evaluate the impact of structural context (CA), intent understanding (TA), Stage 2 reanalysis, and Stage 3 final decision on the overall performance of VIC-RAGENT. Table 4 and Table 5 present the results of the ablation study.

Impact of Stage 2 reanalysis. Removing Stage 2 increase precision but reduces recall and F1-score. The confusion matrix shows a decrease in TP (51→46) and an increase in FN (55→60), indicating that more vulnerabilities are missed. This suggests that Stage 2 plays an important role in improving coverage. Given candidate fragments and their predicted vulnerability categories, the model can perform more targeted and type-guided reasoning under a narrowed search space. This refinement step primarily serves to re-examine and disambiguate the suspicious fragments identified in Stage 1, allowing the model to make more informed decisions on borderline or uncertain cases. As a result, more potential vulnerabilities are retained as positive predictions, which improves recall but may also introduce additional false positives. Therefore, Stage 2 is a key component in the coarse-to-fine reasoning process, improving coverage while introducing a moderate trade-off between recall and precision, and contributing to better overall detection effectiveness.

Impact of Stage 3 final decision. Removing Stage 3 increase recall and F1-score. However, the confusion matrix shows that this gain is accompanied by lower prediction reliability. Specifically, when Stage 3 is removed, FP increases from 22 to 30, while TN decreases from 113 to 105. This provides direct evidence that Stage 3 filters out a subset of false positives that remain after Stage 2. At the same time, TP decreases from 60 to 51 and FN increases from 46 to 55 after Stage 3 is enabled, showing that the additional verification step also filters out some true positives. Therefore, Stage 3 introduces a clear trade-off: it sacrifices some recall in exchange for stricter confirmation and improved robustness. Overall, these results show that Stage 3 acts as a conservative filtering mechanism over the refined candidates produced by Stage 2. Its primary role is not to maximize F1-score, but to improve the trustworthiness of final predictions by reducing unreliable positive decisions. In practical vulnerability detection scenarios, this behavior can be desirable because excessive false positives may lead to unnecessary security alerts and increased manual inspection effort.

5.3 Efficiency and Cost Analysis↩︎

Table 6: Average cost per commit evaluated with DeepSeek-V3.2.
Method Query Time (s) Cost in USD
Direct 5 0.0079
Cot 17 0.0083
CodeAgent 80 0.0217
103 0.0487

We evaluate the computational efficiency of VIC-RAGENT by comparing its query latency and monetary cost with baseline methods. Table 6 reports the average cost per commit using DeepSeek-V3.2. The reported cost is calculated based on the cache miss pricing, which provides a conservative upper-bound estimate of the actual cost.

Higher cost due to multi-stage reasoning. Compared to Direct and CoT, which require only a single LLM call, VIC-RAGENT incurs a higher cost due to multiple agent interactions across different reasoning stages. This increase is expected, as VIC-RAGENT performs structured multi-stage reasoning instead of single-pass inference.

Cost-effectiveness compared to CodeAgent. Compared with CodeAgent, VIC-RAGENT exhibits a moderate increase in cost, while achieving substantially higher recall and F1-score. This suggests that the additional cost is justified by improved detection effectiveness. Although VIC-RAGENT introduces additional LLM calls across multiple stages, the design is suitable for offline or CI-integrated security auditing scenarios, where accuracy is prioritized over latency. The modular structure also allows early-stage filtering to reduce unnecessary downstream analysis.

5.4 Generalization on Recent Vulnerabilities.↩︎

To evaluate the generalization ability of VIC-RAGENT under realistic conditions, we conduct experiments on a set of commits associated with recently disclosed vulnerabilities. The evaluation dataset consist of 20 commits collected from 11 CVEs, including 11 VICs and 9 VFCs. Importantly, the selected CVEs are published between March 2025 and March 2026, with the majority (10 CVEs) released after November 2025. These vulnerabilities are likely to be beyond the training cutoff of DeepSeek-V3.2, making it unlikely that the model has prior exposure to these specific cases. Table 7 presents the performance of different methods on commits associated with recently disclosed vulnerabilities using DeepSeek-V3.2.

Table 7: Performance on recent CVEs (DeepSeek-V3.2).
Method Precision Recall F1-score
Direct 80% 36% 50%
CoT 100% 18% 31%
CodeAgent 63% 45% 53%
67% 55% 60%

Strong generalization to unseen vulnerabilities. VIC-RAGENT achieves the best overall performance, with the highest recall, outperforming all baselines. This indicates that VIC-RAGENT is more effective in identifying VICs even when vulnerabilities are newly disclosed.

Effectiveness of multi-stage reasoning. Compared to CodeAgent, VIC-RAGENT improves recall and F1-score, demonstrating the benefit of the proposed multi-stage reasoning process. This suggests that structured candidate generation and refinement are essential for detecting vulnerabilities in previously unseen scenarios.

6 Discussion↩︎

Effect of Multi-Stage Reasoning. The multi-stage reasoning process follows a coarse-to-fine paradigm. The preliminary inspection stage prioritizes recall by generating candidate vulnerability hypotheses, while the reanalysis stage improves reliability through type-guided verification. Together, these stages balance exploration and verification, contributing to improved detection performance.

Limitations. Despite its effectiveness, VIC-RAGENT has several limitations. First, it relies on LLM reasoning, which may still produce inconsistent results in complex scenarios. Second, the effectiveness of the reanalysis stage depends on the availability and relevance of retrieved cases. Third, the final decision stage introduces a conservative bias that may reduce recall for subtle vulnerabilities. Finally, the framework focuses on commit-level detection and does not address fine-grained tasks such as vulnerability localization or patch generation.

7 Threats to Validity↩︎

We discuss internal and external validity threats for VIC-RAGENT. Internally, although the multi-stage design improves reliability, LLMs may produce inconsistent or incorrect judgments. Prompt design and temperature settings can also affect outcomes. Iterative refinement mitigates but does not fully eliminate errors. Externally, our evaluation on the V-SZZ dataset may not generalize to all projects, programming languages, or real-world environments, and performance could vary across different codebases or vulnerability patterns.

8 Related Work↩︎

Just-In-Time Vulnerability Detection. Early JIT vulnerability detection approaches rely on handcrafted features and traditional machine learning models [10], [11], [34], [35]. More recent studies has explored deep learning techniques to learn representations from source code and commit diffs, including DeepJIT [36], CodeJIT [9], and HgtJIT [17]. Although these approaches improve semantic modeling, they still struggle to capture developer intent and broader contextual information associated with commits.

Code Vulnerability Detection. Code vulnerability detection has evolved from role-based and static-analysis approaches to learning-based methods. Deep learning models such as VulDeePecker [12] and VulDeeLocator [13] learn vulnerability patterns from code representations, while graph-based approaches (e.g., Devign [14], BGNN4VD [15], COCA [37]) model structural dependencies in programs. More recently, transformer-based models such as LineVul [16] leverage pretrained language models for vulnerability prediction. However, these methods primarily focus on static code snippets and are not designed for commit-level vulnerability reasoning.

LLM-based Vulnerability Analysis. Recent advances in LLMs have demonstrated strong capabilities in code understanding and vulnerability analysis [18], [21], [22], [38][40]. Existing approaches include prompt-based methods, retrieval-augmented methods [24], and agent-based framework such as CodeAgent [25].

ReAct-style agents [26] further introduce iterative reasoning through thought–action–observation loops. However, existing LLM-based approaches primarily focus on source-code vulnerability analysis or general code review, and often rely on single-agent or single-pass reasoning. As summarized by recent surveys [22], current approaches remain sensitive to prompt design and may produce unstable reasoning results. These limitations motivate our work, which focuses on commit-level vulnerability detection and employs structured role decomposition together with multi-stage verification.

9 Conclusion↩︎

In this paper, we propose VIC-RAGENT, an LLM-based multi-agent framework for detecting vulnerability-inducing commits. The framework formulates vulnerability detection as a structured multi-stage reasoning process that integrates code diffs, commit messages, and contextual information. Experimental results show that VIC-RAGENT consistently outperforms baseline methods across multiple LLMs, achieving up to 2\(\times\) higher recall and 1.2–1.7\(\times\) higher F1-scores compared to the strongest baseline. These results demonstrate the effectiveness of coarse-to-fine reasoning for commit-level vulnerability detection, enabling improved coverage while maintaining reliable decision making. In future work, we plan to explore more adaptive decision strategies and extend the framework to support fine-grained vulnerability classification.

9.0.1 ↩︎

This work was supported by the National Key R&D Program of China No 2024YFB4506200.

References↩︎

[1]
M. Oriol, C. Müller, J. Marco, P. Fernandez, X. Franch, and A. Ruiz-Cortés, “Comprehensive assessment of open source software ecosystem health,” Internet of Things, vol. 22, p. 100808, 2023.
[2]
L. Chen, H. Sun, X. Gao, L. Shi, Y. Yang, and Y. Xu, “Vulnerability identification by harnessing inter-connected multi-source information,” Journal of Systems and Software, vol. 241, p. 113001, 2026.
[3]
Y. Shen, X. Gao, H. Sun, and Y. Guo, “Understanding vulnerabilities in software supply chains,” Empirical Software Engineering, vol. 30, no. 1, p. 20, 2025.
[4]
M. Jiang, J. Jiang, T. Wu, Z. Ma, X. Luo, and Y. Zhou, “Understanding vulnerability inducing commits of the linux kernel,” ACM Transactions on Software Engineering and Methodology, vol. 33, no. 7, pp. 1–28, 2024.
[5]
R. K. Saha, S. Khurshid, and D. E. Perry, “An empirical study of long lived bugs,” in 2014 software evolution week - IEEE conference on software maintenance, reengineering, and reverse engineering (CSMR-WCRE), 2014, pp. 144–153, doi: 10.1109/CSMR-WCRE.2014.6747164.
[6]
L. Bao, X. Xia, A. E. Hassan, and X. Yang, “V-szz: Automatic identification of version ranges affected by cve vulnerabilities,” in Proceedings of the 44th international conference on software engineering, 2022, pp. 2352–2364.
[7]
E. Iannone, R. Guadagni, F. Ferrucci, A. De Lucia, and F. Palomba, “The secret life of software vulnerabilities: A large-scale empirical study,” IEEE Transactions on Software Engineering, vol. 49, no. 1, pp. 44–63, 2022.
[8]
S. Woo, E. Choi, and H. Lee, “A large-scale analysis of the effectiveness of publicly reported security patches,” Computers & Security, vol. 148, p. 104181, 2025.
[9]
S. Nguyen, T.-T. Nguyen, T. T. Vu, T.-D. Do, K.-T. Ngo, and H. D. Vo, “Code-centric learning-based just-in-time vulnerability detection,” Journal of Systems and Software, vol. 214, p. 112014, 2024.
[10]
C. Pornprasit and C. K. Tantithamthavorn, “Jitline: A simpler, better, faster, finer-grained just-in-time defect prediction,” in 2021 IEEE/ACM 18th international conference on mining software repositories (MSR), 2021, pp. 369–379.
[11]
L. Yang, X. Li, and Y. Yu, “Vuldigger: A just-in-time and cost-aware tool for digging vulnerability-contributing changes,” in GLOBECOM 2017-2017 IEEE global communications conference, 2017, pp. 1–7.
[12]
Z. Li et al., “Vuldeepecker: A deep learning-based system for vulnerability detection,” arXiv preprint arXiv:1801.01681, 2018.
[13]
Z. Li, D. Zou, S. Xu, Z. Chen, Y. Zhu, and H. Jin, “Vuldeelocator: A deep learning-based fine-grained vulnerability detector,” IEEE Transactions on Dependable and Secure Computing, vol. 19, no. 4, pp. 2821–2837, 2021.
[14]
Y. Zhou, S. Liu, J. Siow, X. Du, and Y. Liu, “Devign: Effective vulnerability identification by learning comprehensive program semantics via graph neural networks,” Advances in neural information processing systems, vol. 32, 2019.
[15]
S. Cao, X. Sun, L. Bo, Y. Wei, and B. Li, “Bgnn4vd: Constructing bidirectional graph neural-network for vulnerability detection,” Information and Software Technology, vol. 136, p. 106576, 2021.
[16]
M. Fu and C. Tantithamthavorn, “Linevul: A transformer-based line-level vulnerability prediction,” in Proceedings of the 19th international conference on mining software repositories, 2022, pp. 608–620.
[17]
X. Sun et al., “HgtJIT: Just-in-time vulnerability detection based on heterogeneous graph transformer,” IEEE Transactions on Dependable and Secure Computing, 2025.
[18]
J. Wang, T. Ni, W.-B. Lee, and Q. Zhao, “A contemporary survey of large language model assisted program analysis,” arXiv preprint arXiv:2502.18474, 2025.
[19]
C. Ni, X. Yin, L. Shen, and S. Wang, “Learning-based models for vulnerability detection: An extensive study,” Empirical Software Engineering, vol. 31, no. 1, p. 18, 2026.
[20]
Y. Yang, B. Xu, X. Gao, and H. Sun, “Context-enhanced vulnerability detection based on large language models,” ACM Transactions on Software Engineering and Methodology, 2025.
[21]
G. Lu, X. Ju, X. Chen, W. Pei, and Z. Cai, “GRACE: Empowering LLM-based software vulnerability detection with graph structure and in-context learning,” Journal of Systems and Software, vol. 212, p. 112031, 2024.
[22]
X. Zhou, S. Cao, X. Sun, and D. Lo, “Large language model for vulnerability detection and repair: Literature review and the road ahead,” ACM Transactions on Software Engineering and Methodology, vol. 34, no. 5, pp. 1–31, 2025.
[23]
W. Tian, Y. Lin, X. Gao, and H. Sun, “Enhanced vulnerability localization: Harmonizing task-specific tuning and general LLM prompting,” in 2025 IEEE international conference on software maintenance and evolution (ICSME), 2025, pp. 110–122.
[24]
X. Du et al., “Vul-rag: Enhancing llm-based vulnerability detection via knowledge-level rag,” ACM Transactions on Software Engineering and Methodology, 2024.
[25]
X. Tang et al., “Codeagent: Autonomous communicative agents for code review,” in Proceedings of the 2024 conference on empirical methods in natural language processing, 2024, pp. 11279–11313.
[26]
A. Yildiz, S. G. Teo, Y. Lou, et al., “Benchmarking LLMs and LLM-based agents in practical vulnerability detection for code repositories,” in Proceedings of the 63rd annual meeting of the association for computational linguistics (volume 1: Long papers), 2025, pp. 30848–30865.
[27]
S. R. Motwani et al., “MALT: Improving reasoning with multi-agent LLM training,” arXiv preprint arXiv:2412.01928, 2024.
[28]
X. Li, S. Wang, S. Zeng, Y. Wu, and Y. Yang, “A survey on LLM-based multi-agent systems: Workflow, infrastructure, and challenges,” Vicinagearth, vol. 1, no. 1, pp. 1–43, 2024.
[29]
Z. Feng et al., “Codebert: A pre-trained model for programming and natural languages,” in Findings of the association for computational linguistics: EMNLP 2020, 2020, pp. 1536–1547.
[30]
A. Liu et al., “Deepseek-v3 technical report,” arXiv preprint arXiv:2412.19437, 2024.
[31]
J. Bai et al., “Qwen technical report,” arXiv preprint arXiv:2309.16609, 2023.
[32]
OpenAI, “GPT-4o mini: Advancing cost-efficient intelligence.” https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/, 2024.
[33]
B. Steenhoek, M. M. Rahman, R. Jiles, and W. Le, “An empirical study of deep learning models for vulnerability detection,” in 2023 IEEE/ACM 45th international conference on software engineering (ICSE), 2023, pp. 2237–2248, doi: 10.1109/ICSE48619.2023.00188.
[34]
C. Ni, W. Wang, K. Yang, X. Xia, K. Liu, and D. Lo, “The best of both worlds: Integrating semantic features with expert features for defect prediction and localization,” in Proceedings of the 30th ACM joint european software engineering conference and symposium on the foundations of software engineering, 2022, pp. 672–683.
[35]
T. Riom, A. Sawadogo, K. Allix, T. F. Bissyandé, N. Moha, and J. Klein, “Revisiting the VCCFinder approach for the identification of vulnerability-contributing commits,” Empirical Software Engineering, vol. 26, no. 3, p. 46, 2021.
[36]
T. Hoang, H. K. Dam, Y. Kamei, D. Lo, and N. Ubayashi, “Deepjit: An end-to-end deep learning framework for just-in-time defect prediction,” in 2019 IEEE/ACM 16th international conference on mining software repositories (MSR), 2019, pp. 34–45.
[37]
S. Cao et al., “Coca: Improving and explaining graph neural network-based vulnerability detection systems,” in Proceedings of the IEEE/ACM 46th international conference on software engineering, 2024, pp. 1–13.
[38]
J. Jiang, F. Wang, J. Shen, S. Kim, and S. Kim, “A survey on large language models for code generation,” ACM Transactions on Software Engineering and Methodology, vol. 35, no. 2, pp. 1–72, 2026.
[39]
B. Li et al., “Prompting large language models to tackle the full software development lifecycle: A case study,” in Proceedings of the 31st international conference on computational linguistics, 2025, pp. 7511–7531.
[40]
J. Lin, D. Mohaisen, et al., “From large to mammoth: A comparative evaluation of large language models in vulnerability detection.” in NDSS, 2025.

  1. Corresponding authors↩︎