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.
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.
A key contribution of LeakDojo is how it formalizes a RAG leakage attack as a two-part combination:
- 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.
- 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.
- 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."
- 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.
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