External Data Extraction Attacks Against Retrieval-Augmented Large Language Models

Yu He, Yifei Chen, Yiming Li, Shuo Shao, Leyi Qi, Boheng Li, Dacheng Tao, Zhan Qin

TL;DR

This paper provides the first comprehensive formalization of External Data Extraction Attacks (EDEAs) against Retrieval-Augmented Generation (RAG) systems, where adversaries attempt to extract sensitive knowledge base documents verbatim. The authors introduce SECRET, an advanced attack framework that leverages automated LLM optimization to generate tailored jailbreak prompts and an adaptive "cluster-focused triggering" strategy to systematically mine the database. SECRET successfully extracts up to 35% of private data from state-of-the-art, heavily aligned models like Claude 3.7 Sonnet, exposing severe vulnerabilities in current RAG defenses.

What Problem Does This Paper Address?

Retrieval-Augmented Generation (RAG) has become the standard paradigm for grounding Large Language Models (LLMs) in up-to-date, domain-specific, or private data (such as enterprise documents or medical records). However, this architecture introduces a critical security risk: External Data Extraction Attacks (EDEAs), where a malicious user crafts prompts designed to force the system to retrieve and output the underlying documents verbatim.

While preliminary studies have noted this risk, they often rely on ad-hoc, non-adaptive strategies that fail against modern, safety-aligned models or simple system-prompt defenses (e.g., instructing the model "do not disclose the knowledge base"). This paper addresses the lack of a formalized framework for EDEAs and investigates whether these attacks pose a realistic threat to state-of-the-art commercial RAG deployments.

The standard pipeline of Retrieval-Augmented Generation (RAG).

Methods

The authors unify prior work by decomposing an EDEA query into three functional components: an extraction instruction ($p_e$), a jailbreak operator ($\mathcal{J}(\cdot)$), and a retrieval trigger ($t_i$).

Taxonomy of prior EDEAs within the proposed unified framework.

Building on this framework, they propose SECRET (Scalable and EffeCtive exteRnal data Extraction aTtack), which operates in two distinct phases:

  1. Jailbreak Prompt Generation: Instead of relying on manual templates, SECRET uses an automated, reward-based optimization loop powered by an LLM Optimizer and Evaluator. To bypass highly aligned models like Claude 3.7 Sonnet, they employ curriculum learning, first optimizing the prompt against a weaker model (Gemini 2.0 Flash) and using the successful prompt as a seed for the stronger target.
  2. Adaptive Extraction via Cluster-Focused Triggering (CFT): To efficiently navigate the high-dimensional embedding space of the retriever without direct database access, SECRET alternates between two modes:
  3. Global Exploration (GE): Sampling random natural-text chunks from external corpora to discover initial "seed" documents in new clusters.
  4. Local Exploitation (LE): Once a document is leaked, an LLM generates "semantic shifts"—fusing the leaked content with external text—to probe the local neighborhood and extract nearby unseen documents.
The overall two-phase attack pipeline of SECRET.

Datasets

The authors constructed external RAG knowledge bases (1,000 documents each) using two sensitive datasets:

  • Enron Email Dataset: Representing corporate internal communications and confidential business data.
  • HealthcareMagic-101: Representing highly sensitive medical records and patient-doctor dialogues.

For the global exploration phase and semantic shifting, external corpora like Wikipedia and WikiText-103 were utilized.

Key Insights and Ideas

  • The "Cold Start" Problem in Jailbreaking: Directly optimizing jailbreak prompts against top-tier aligned models often yields zero reward initially because the model rejects everything. Curriculum learning (transferring prompts optimized on weaker models) is crucial to kickstart the optimization process.
  • The Failure of Distance Maximization: An intuitive strategy to find new documents would be to maximize the embedding distance from already seen documents. However, due to the curse of dimensionality, this pushes queries into empty, sparse regions of the embedding space. Instead, navigating local structures (clusters) via semantic shifts is far more query-efficient.
  • System Prompts are Fragile Guardrails: Adding simple defensive instructions (e.g., "do not repeat input") to the system prompt completely stops naive baseline attacks, but is easily bypassed by SECRET's adaptive optimization.

Key Results

  • Bypassing Claude 3.7 Sonnet: SECRET achieved a 34.0% to 36.5% Maximum Extraction Rate (MER) against a defended Claude 3.7 Sonnet on the tested datasets, while all five baseline attacks failed completely (0% extraction, ~100% refusal rate).
  • High Efficiency: Under the strict "Theoretical Minimum Queries" (ER-TMQ) metric, SECRET extracted 25.5% to 30.4% of the database across all tested models (Claude 3.7, Gemini 2.0 Flash, GPT-4o mini, DeepSeek-V3), roughly doubling the efficiency of prior adaptive methods.
  • Defense Resilience: The authors tested several advanced defenses, including retrieval similarity thresholds, mixing private data with public data, context rephrasing/summarization, and output obfuscation (e.g., instructing the LLM to output text with spaces between letters). SECRET consistently bypassed or adapted to these defenses, highlighting a severe lack of robust countermeasures.

Limitations and Future Work

  • Text-Only Focus: The current framework and SECRET attack are limited to traditional text-only RAG systems. It does not account for multimodal RAG architectures that retrieve both text and images.
  • The Efficiency Gap: While SECRET significantly outperforms existing baselines, a gap still remains between its empirical extraction rate and the theoretical optimum of 100% non-redundant database coverage within a minimal query budget.
  • Black-Box Optimization Cost: Although relatively low (~16 queries on average), the initial jailbreak prompt optimization phase still requires active probing of the target system or a suitable surrogate.

Summary updated

BibTeX
@article{he2026external,
  author = {Yu He and Yifei Chen and Yiming Li and Shuo Shao and Leyi Qi and Boheng Li and Dacheng Tao and Zhan Qin},
  title = {{External Data Extraction Attacks Against Retrieval-Augmented Large Language Models}},
  journal = {IEEE Trans. Inf. Forensics Secur.},
  year = {2026},
  doi = {10.1109/tifs.2026.3705326},
}
Figure