[Paper Review] Follow My Instruction and Spill the Beans: Scalable Data Extraction from Retrieval-Augmented Generation Systems
This paper reveals that instruction-tuned retrieval-augmented generation (RAG) models are vulnerable to prompt-injection attacks that extract verbatim text from their external datastores. The authors demonstrate scalable, high-success-rate data leakage—up to 41% verbatim extraction from a 77k-word book—using only 100 self-generated queries, even in production GPTs with 100% success on 25 customized GPTs.
Retrieval-Augmented Generation (RAG) improves pre-trained models by incorporating external knowledge at test time to enable customized adaptation. We study the risk of datastore leakage in Retrieval-In-Context RAG Language Models (LMs). We show that an adversary can exploit LMs' instruction-following capabilities to easily extract text data verbatim from the datastore of RAG systems built with instruction-tuned LMs via prompt injection. The vulnerability exists for a wide range of modern LMs that span Llama2, Mistral/Mixtral, Vicuna, SOLAR, WizardLM, Qwen1.5, and Platypus2, and the exploitability exacerbates as the model size scales up. We also study multiple effects of RAG setup on the extractability of data, indicating that following unexpected instructions to regurgitate data can be an outcome of failure in effectively utilizing contexts for modern LMs, and further show that such vulnerability can be greatly mitigated by position bias elimination strategies. Extending our study to production RAG models GPTs, we design an attack that can cause datastore leakage with a 100% success rate on 25 randomly selected customized GPTs with at most 2 queries, and we extract text data verbatim at a rate of 41% from a book of 77,000 words and 3% from a corpus of 1,569,000 words by prompting the GPTs with only 100 queries generated by themselves.
Motivation & Objective
- To investigate the risk of data leakage from retrieval-augmented generation (RAG) systems, particularly via prompt injection attacks.
- To assess whether instruction-tuned large language models (LLMs) can be exploited to extract verbatim content from their non-parametric datastores.
- To evaluate the exploitability of this vulnerability across diverse open-source and production LLMs, including Llama2, Mistral, Vicuna, and GPTs.
- To examine how model size and instruction tuning affect the likelihood of context disclosure through adversarial prompting.
- To highlight the implications for privacy and data stewardship in sensitive domains like healthcare, finance, and legal applications.
Proposed method
- Developed adversarial prompts that exploit instruction-following capabilities of LLMs to explicitly instruct them to repeat retrieved context.
- Built RAG systems using Retrieval-in-Context (RIC) method, where retrieved chunks are prepended to user queries before input to the LLM.
- Used black-box API access to query models, generating domain-specific queries iteratively to maximize data extraction efficiency.
- Evaluated extraction performance using ROUGE, BLEU, F1, and BERTScore metrics to measure verbatim text reconstruction accuracy.
- Conducted ablation studies comparing base and instruction-tuned LLMs (e.g., Llama2, Mistral) on the same datastore to isolate the impact of instruction tuning.
- Extended analysis to production GPTs, testing data leakage on 25 customized GPTs using minimal, self-generated queries.

Experimental results
Research questions
- RQ1Can instruction-tuned LLMs be coerced into revealing verbatim content from their RAG datastore via prompt injection?
- RQ2How does model size (e.g., 7B vs. 70B) affect the success rate of data extraction attacks in RAG systems?
- RQ3To what extent does instruction tuning increase the vulnerability of LLMs to context disclosure attacks?
- RQ4Can data leakage be achieved at scale in production RAG systems like GPTs with minimal query overhead?
- RQ5Does prior exposure to the datastore content during pre-training amplify the risk of verbatim data extraction?
Key findings
- Instruction-tuned LLMs exhibit significantly higher vulnerability to prompt-injected data extraction, with average ROUGE score increases of 65.76 points compared to base models.
- The attack achieved 100% success rate in extracting system prompts and operations from 25 randomly selected customized GPTs using at most two queries.
- Verbatim extraction reached 41% accuracy from a copyrighted book of 77,000 words using only 100 self-generated queries on GPTs.
- Extraction from a larger Wikipedia corpus (1.569M words) achieved 3% verbatim accuracy with the same 100-query limit, demonstrating scalability.
- Instruction tuning was found to substantially increase exploitability, as models with stronger instruction-following behavior were more likely to repeat context verbatim.
- Ablation studies suggest that if the datastore content was seen during pre-training (e.g., Harry Potter), extraction performance improves further, indicating potential contamination effects.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.