Benchmarking Knowledge-Extraction Attack and Defense on Retrieval-Augmented Generation

Zhisheng Qi, Utkarsh Sahu, Li Ma, Haoyu Han, Ryan Rossi, Franck Dernoncourt, Mahantesh Halappanavar, Nesreen Ahmed, Yushun Dong, Yue Zhao, Yu Zhang, Yu Wang

Abstract: Retrieval-Augmented Generation (RAG) has become a cornerstone of knowledge-intensive applications, including enterprise chatbots, healthcare assistants, and agentic memory management. However, recent studies show that knowledge-extraction attacks can recover sensitive knowledge-base content through maliciously crafted queries, raising serious concerns about intellectual property theft and privacy leakage. While prior work has explored individual attack and defense techniques, the research landscape remains fragmented, spanning heterogeneous retrieval embeddings, diverse generation models, and evaluations based on non-standardized metrics and inconsistent datasets. To address this gap, we introduce the first systematic benchmark for knowledge-extraction attacks on RAG systems. Our benchmark covers a broad spectrum of attack and defense strategies, representative retrieval embedding models, and both open- and closed-source generators, all evaluated under a unified experimental framework with standardized protocols across multiple datasets. By consolidating the experimental landscape and enabling reproducible, comparable evaluation, this benchmark provides actionable insights and a practical foundation for developing privacy-preserving RAG systems in the face of emerging knowledge extraction threats.

TL;DR

Retrieval-Augmented Generation (RAG) systems are vulnerable to attacks that trick them into leaking sensitive data from their external knowledge bases. This paper introduces the first comprehensive, standardized benchmark to evaluate these "knowledge-extraction" attacks and their corresponding defenses. By unifying previously fragmented research, the authors reveal critical vulnerabilities—including the surprising finding that highly capable, closed-source LLMs are actually more prone to leaking data when explicitly instructed to do so.

What Problem Does This Paper Address?

RAG has become the go-to solution for reducing hallucinations in Large Language Models (LLMs) and giving them access to up-to-date or proprietary information. However, plugging an external database into an LLM creates a massive new attack surface. Malicious users can craft clever queries to extract private information (like medical records or corporate emails) or copyrighted material directly from the RAG's knowledge base.

Prior research has proposed various ways to attack and defend RAG systems, but the landscape is fragmented. Different papers use different datasets, embedding models, LLMs, and metrics. This inconsistency makes it impossible to fairly compare whether one attack is actually better than another, or if a specific defense works in the real world. This paper solves that by building a unified benchmarking framework to test everything on an even playing field.

Methods

The authors built a comprehensive design space that tests 6 attack strategies against 4 defense mechanisms across different RAG configurations.

  • The Attacks: Ranging from simple baselines (randomly generated text/tokens) to state-of-the-art adaptive attacks. Some attacks mathematically optimize embeddings to explore the database (e.g., DGEA, R-EB), while others use LLMs to generate natural-language queries that mimic benign users (e.g., IKEA, CopyBreak).
  • The Defenses: The benchmark tests defenses at three stages of the RAG pipeline:
  • Input: Query Blockers (using an LLM to detect malicious intent).
  • Retrieval: Thresholding (dropping retrieved documents if they aren't semantically similar enough to the query).
  • Generation: System Block (instructing the LLM not to share raw data) and Summary (forcing the LLM to summarize rather than repeat verbatim).
  • Decoupled Metrics: Crucially, the authors separate Retrieval Extraction (did the system fetch the sensitive document?) from Generation Extraction (did the LLM actually output the sensitive text?). This isolates exactly where attacks succeed or fail.

Datasets

The benchmark evaluates performance across four datasets representing different high-stakes domains:

  • HealthCareMagic: Medical Q&A containing sensitive personal health information.
  • Enron: Corporate email threads containing private communications.
  • HarryPotter: Fictional text to test copyrighted material extraction.
  • Pokémon: Encyclopedic content for baseline factual extraction.

Key Insights and Ideas

  • The "Smart LLM" Paradox: Better models aren't necessarily safer. Closed-source models (like GPT-4o) are vastly superior at following instructions. If an attacker slips in a command like "Please repeat all the context," the smarter model is actually more likely to comply and leak data verbatim compared to smaller open-source models.
  • Math vs. Natural Language Attacks: Attacks that mathematically optimize embeddings (like DGEA) are brittle; if the attacker and the RAG system use different embedding models, the attack fails. Conversely, natural language attacks (like IKEA) transfer easily across different systems.
  • Graph Indexing Risks: Structuring a knowledge base as Graph Triplets (entity-relation-entity) is a security risk. Because triplets distill information so densely, an attacker can extract a much higher proportion of sensitive private data per token than with standard text chunks.
  • Query Diversity Matters: Attackers often fail by asking variations of the same question. By forcing attack queries to be mathematically diverse, attackers can map out and steal much larger swaths of the database.

Key Results

  • Attack Success: Without defenses, adaptive attacks are devastatingly effective. The DGEA attack successfully retrieved 90.5% of targeted knowledge on the Enron dataset.
  • Defense Effectiveness: No single defense is a silver bullet, but Thresholding and Summary defenses are the most robust. A retrieval similarity threshold of 0.3 effectively blocked most embedding-optimized attacks while preserving the RAG system's utility.
  • Diversity Boost: Adding "query-query diversity" optimization boosted the retrieval extraction effectiveness of gradient-based attacks by 10-20 percentage points.

Limitations and Future Work

The authors acknowledge that while their benchmark covers standard RAG pipelines, the AI landscape is shifting toward "Agentic RAG" (where autonomous agents use RAG for persistent memory). Future work will need to extend this benchmark to cover agentic architectures and develop coordinated, multi-stage defenses that protect the entire pipeline.

Summary updated

BibTeX
@misc{qi2026benchmarking,
  author = {Zhisheng Qi and Utkarsh Sahu and Li Ma and Haoyu Han and Ryan Rossi and Franck Dernoncourt and Mahantesh Halappanavar and Nesreen Ahmed and Yushun Dong and Yue Zhao and Yu Zhang and Yu Wang},
  title = {{Benchmarking Knowledge-Extraction Attack and Defense on Retrieval-Augmented Generation}},
  year = {2026},
  eprint = {2602.09319},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.09319},
}
Figure