Manuscript Offprint

arXiv:2609.37669

Retrieve, Reproduce, Reveal: Dissecting Retrieval-Augmented Software Vulnerability Detection

Sabrina Kaniewski, Tim Krämer, Julius Bächle, Markus Enzweiler, Michael Menth, Tobias Heer

SABRINA KANIEWSKI ✉^{✉}, Institute for Secure Networked Systems, Esslingen University, Germany

TIM KRÄMER, Esslingen University, Germany

JULIUS BÄCHLE, Institute for Intelligent Systems, Esslingen University, Germany

MARKUS ENZWEILER, Institute for Intelligent Systems, Esslingen University, Germany

MICHAEL MENTH, Chair of Communication Networks, University of Tübingen, Germany

TOBIAS HEER, Institute for Secure Networked Systems, Esslingen University, Germany

Retrieval-Augmented Generation (RAG) is increasingly used to enhance Large Language Model (LLM)-based software vulnerability detection by grounding predictions in retrieved vulnerability knowledge, such as vulnerability reports. However, existing RAG-based software vulnerability detection (RAG4SVD) systems are often evaluated using proprietary models, which challenges open science and reproducibility. Further, studies use different datasets, custom knowledge bases, different backbone models, and diverse metrics, which hinders meaningful cross-system comparison. In this work, we study six open-source RAG4SVD systems and address these reproducibility and comparability challenges through (i) reproduction of their experimental settings under an open-weight setting, and (ii) a unified benchmark using a common dataset, metric suite, and pool of open-weight models. Further, RAG4SVD systems typically consist of multiple components, yet are often evaluated only as a whole system, i.e., end-to-end. Therefore, we perform (iii) a component-level analysis that decomposes representative RAG4SVD pipelines into input abstraction, knowledge retrieval, and detection. Our results demonstrate that reproducibility varies substantially across systems. Under the presented unified benchmark, published RAG4SVD performance does not transfer under a controlled open-weight evaluation and depends strongly on the used model. The component analysis shows that effective RAG4SVD depends on the alignment between pipeline stages. For example, oracle knowledge raises retrieval to near-optimal, yet performance remains low (0.51 pairwise accuracy), demonstrating that retrieval effectiveness alone is insufficient for reliable detection. These findings motivate evaluating RAG4SVD not only end-to-end, but at the level of pipeline components, and provide a basis for more standardized, RAG-aware evaluation practices.

Additional Key Words and Phrases: software vulnerability detection, software security, retrieval-augmented generation, large language models, reproducibility, benchmark

1 Introduction

Large language models (LLMs) are increasingly applied to software vulnerability detection by leveraging their code-understanding and reasoning capabilities to discover insecure code [17]. However, an LLM's internal knowledge is inherently limited by its training data and respective cutoff date. Thus, newly disclosed vulnerabilities, emerging attack patterns, and project-specific security knowledge that were published after the training cutoff date may be unavailable to the model at inference time. Retrieval-Augmented Generation (RAG) [20] addresses this limitation by dynamically retrieving external vulnerability knowledge, e.g., Common Weakness Enumeration (CWE) descriptions, specific Common Vulnerabilities and Exposures (CVE) reports, or similar vulnerable code examples, from a knowledge base and incorporating it into the prompt [3]. Unlike costly retraining or fine-tuning, the knowledge base can be updated independently of the model to add more specific and up-to-date information and, thus, enhance detection performance.

The adoption of RAG for LLM-based software vulnerability detection (RAG4SVD) has grown rapidly, with proposed RAG systems reporting improvements over non-retrieval baselines [3, 8, 17]. RAG4SVD systems typically follow a common pipeline, cf. Fig. 1: The code under analysis is first transformed via input abstraction into the representation used to query the knowledge base, e.g., the raw code itself or a semantic summary of the code. This query is passed to a knowledge retrieval

Kaniewski et al.

mechanism, e.g., based on embedding similarity, lexical matching, structured lookup, or a hybrid combination thereof, which retrieves relevant entries. Finally, the retrieved knowledge is combined with the code under analysis and passed to the LLM for detection, producing a vulnerability prediction, e.g., a binary vulnerable/non-vulnerable label.

Yet, it remains unclear how generalizable reported gains are. First, results are rarely independently verified [18]. Incomplete public artifacts, undocumented preprocessing and dependencies, non-deterministic inference, and reliance on proprietary models or APIs further complicate reproducing LLM-based systems [14, 18, 33]. Model providers may discontinue or modify their models without notice, which renders experiments non-reproducible. Second, systems differ substantially in their datasets, knowledge bases, query representations, retrieval mechanisms, and backbone models [3, 17]. Consequently, results across individual studies do not provide a basis for comparing different systems. Third, despite the fact that these systems consist of multiple components, they are commonly evaluated only through their final detection accuracy, i.e., end-to-end. It is often unclear if improvements stem from the quality and coverage of the knowledge base, the abstraction used to formulate a retrieval query, the retrieval mechanism, or the capabilities of the detection model used. We summarize these observations as three evaluation gaps in the current literature:

Reproducibility Gap: The results of published RAG4SVD systems have rarely been independently reproduced. It remains uncertain whether reported performance can be recovered.

Comparability Gap: Systems are evaluated using different datasets, custom knowledge bases, different models, and diverse metrics, preventing meaningful cross-system comparison.

Attribution Gap: RAG systems are predominantly evaluated end-to-end; consequently, it remains unclear which pipeline components drive observed performance improvements.

To address these gaps, we present, to the best of our knowledge, the first study in RAG-based software vulnerability detection to jointly assess reproducibility, cross-system performance, and individual pipeline components. The contributions of this work are threefold: (i) Considering six open-source RAG4SVD systems, i.e., SVD-Bench [45], Llama-VD 1^{1} [27], GRACE [22], LLM4Vuln [37],

1^{1}We introduce the abbreviation Llama-VD in this work for brevity.

RQ1 Reproducibility

Unify & reproduce open-source systems

RQ2 Unified Benchmark: end-to-end detection performance

RQ3 Component Analysis: isolating each component

Input Abstraction

Section 4.3.1

Summary Quality

LLM-as-a-Judge Score

Summarization

Knowledge Retrieval

Section 4.3.2

Coverage & Retrieval

Effectiveness

MRR, Hit@k

CWE/CVE

Knowledge Base

top-k

Detection

Section 4.3.3

Detection Performance

using Oracle

Pairwise Accuracy

Detection

output

Vuln

None

Fig. 1. Overview of a typical RAG4SVD pipeline and the evaluation roadmap of this work.

Vul-RAG [8], and VulTriage [39], we first reproduce systems using open-weight models and quantify deviations from their reported results. (ii) Second, we analyze how the considered RAG4SVD systems compare when re-implemented under a common dataset, metric suite, and pool of heterogeneous open-weight models, enabling controlled comparison across independently proposed systems. (iii) Third, we move beyond end-to-end evaluation and dissect representative multi-stage RAG4SVD pipelines into input abstraction, knowledge retrieval, and detection, proposing a component-aware evaluation of RAG4SVD systems. Specifically, we evaluate whether generated abstractions preserve information useful for retrieval, whether relevant knowledge is actually retrieved, and whether oracle knowledge improves the detection performance. Together, these analyses provide a RAG-aware evaluation that examines not whether RAG improves vulnerability detection, but which components drive performance. The replication package for this study is publicly available at https://github.com/hs-esslingen-it-security/RAG4SVD.

The remainder of this work is structured as follows. Section 2 reviews related work. Section 3 describes the experimental setup, i.e., the selection of RAG4SVD systems, datasets, metrics, models, and implementation details. Section 4 presents the evaluation along the identified gaps and discusses the findings. We address threats to validity in Sect. 5 and conclude this work in Sect. 6.

References (33)