LeakDojo: Decoding the Leakage Threats of RAG Systems

Maosen Zhang, Jianshuo Dong, Boting Lu, Wenyue Li, Xiaoping Zhang, Tianwei Zhang, Han QiuarXiv 2026

TL;DR

Retrieval-Augmented Generation (RAG) systems protect against LLM hallucinations but expose proprietary databases to malicious data extraction attacks. This paper introduces LeakDojo, a modular framework that systematically evaluates RAG leakage risks across various models, datasets, and system architectures. Crucially, the study uncovers a troubling paradox: smarter, more instruction-compliant LLMs and highly "faithful" RAG configurations are actually the most vulnerable to data leakage.

What Problem Does This Paper Address?

Building and maintaining a high-quality knowledge database for a RAG system is an expensive, domain-specific endeavor, making these databases highly valuable digital assets. Unfortunately, they are susceptible to "RAG leakage attacks"—prompt injection techniques where an adversary crafts queries to trick the LLM into printing the retrieved source text verbatim.

While early RAG setups were simple, modern implementations have evolved into complex pipelines featuring query rewriters, rerankers, and summarizers.

Figure 2: Modern RAG systems are increasingly com- plex in their structural designs. In this paper, we study how the integration of a reranker, rewriter, and summa- rizer impacts leakage risks.

Until now, existing security research evaluated these attacks in ad-hoc, isolated environments. We lacked a systematic understanding of how advanced model capabilities, complex RAG architectures, and different attack strategies interact to influence overall data privacy.

Methods

The authors present LeakDojo, an open-source, highly programmable evaluation framework that decouples RAG systems into independently configurable components: the RAG pipeline itself, the attack strategy, and the defense mechanisms.

Figure 3: Architectural overview of LeakDojo. It models RAG leakage as an adversarial interaction between attacker and RAG: (1) Attacker (left) iteratively refines anchor queries based on previous responses to expand retrieval coverage. Simultaneously, it employs adversarial instructions to trigger leakage. (2) Defensive RAG (right) system processes the incoming query through a pipeline of optional modules and retrieves relevant chunks from the knowledge database to augment the responses. Defense modules are deployed at both input and output stages.

A key contribution of LeakDojo is how it formalizes a RAG leakage attack as a two-part combination:

  1. The Query Generator ($A_i$): Responsible for generating the "anchor query" to maximize the diversity and coverage of the chunks retrieved from the vector database.
  2. The Adversarial Instruction ($I$): The malicious prompt injection designed to force the LLM to output the retrieved context verbatim.

The final adversarial query is simply represented as $Q^{adv}_i = A_i \oplus I$. LeakDojo also supports modular defenses, such as input intent detectors and output content filters.

Datasets

The framework benchmarks leakage risks using four diverse datasets spanning different domains from the standard BEIR benchmark and public repositories:

  • SCIFACT: Scientific claims verification.
  • NFCORPUS: Medical information retrieval.
  • FIQA: Financial question answering.
  • ENRON EMAIL: Corporate email communications (representing sensitive corporate data).

Key Insights and Ideas

  • The Orthogonal Nature of Attacks: The authors discovered that a RAG attack's overall success—measured as Chunk Cumulative Leakage (CCL)—is almost perfectly predicted by multiplying its retrieval coverage (ARC) by its success in triggering a leak (SLT). Query generation and prompt injection operate as independent, orthogonal forces.
Figure 5: Statistical correlation between CCL, SLT, and ARC. The results are aggregated over multiple datasets and RAG configurations in Table 2.
  • The Capability Paradox: There is a strong positive correlation ($r = 0.578$) between an LLM's instruction-following ability (measured via IFEval) and its leakage risk. Because premier models are highly trained to follow user instructions precisely, they are ironically the most compliant when an adversary commands them to "repeat the context verbatim."
Figure 1: Stronger instruction-following ability may imply higher leakage risk of RAG systems.
  • The Privacy-Utility Trade-off: System configurations that optimize for RAG "faithfulness" (how accurately the model sticks to the retrieved context) inherently increase data leakage risks. For instance, adding a query rewriter stabilizes retrieval but lowers the barrier for attackers. Conversely, adding a summarizer reduces leakage but degrades the system's overall utility and truthfulness.
Figure 4: Impact of RAG configurations on leakage risk and RAG system performance. (a) Ablation study of RAG modules: T0 denotes vanilla RAG (with only retriever); T1 adds a reranker to T0; T2 further incorporates a rewriter; and T3 represents the full pipeline. (b) Correlation analysis reveals a consistently positive relationship between faithfulness and CCL across multiple datasets (FIQA, SCIFACT, and NFCORPUS).

Key Results

The authors benchmarked 6 prominent attacks across 14 LLMs. They found that existing attacks are highly unstable; an attack that achieves an 88.3% leakage rate on Gemini-3-flash can plummet to just 6.8% when switched to DeepSeek-V3, highlighting the need for a standardized benchmark like LeakDojo.

Furthermore, the authors demonstrated that standard security defenses are brittle. While a basic GPT-4-based intent detector successfully mitigated default attacks (reducing leakage to under 1%), the authors developed two new attack variants—RankerSet and CodeClaim—that use logical masking to disguise the theft. By framing the injection as a benign coding or ranking task, they bypassed the defenses entirely, clawing back up to a 59.6% leakage rate in defended environments.

Limitations and Future Work

While comprehensive, the paper notes a few limitations:

  • Efficiency Metrics: The benchmark focuses primarily on attack success rates rather than computational efficiency (e.g., token consumption or generation latency).
  • Fixed Budgets: The evaluation restricts the interaction budget to $N = 200$ rounds.
  • Language Constraints: The evaluation was performed exclusively on English-language corpora. Future work is required to explore how multilingual pretraining biases and tokenization dynamics affect RAG leakage vulnerabilities in non-English systems.

Summary updated

BibTeX
@misc{zhang2026leakdojo,
  author = {Maosen Zhang and Jianshuo Dong and Boting Lu and Wenyue Li and Xiaoping Zhang and Tianwei Zhang and Han Qiu},
  title = {{LeakDojo: Decoding the Leakage Threats of RAG Systems}},
  year = {2026},
  eprint = {2605.05818},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.05818},
}
Figure