RAG Data Leakage: When the AI Reads Files It Shouldn't Quote
RAG data leakage happens when an AI assistant retrieves documents the user was never allowed to see and quotes them in its answer. Here is how to prevent it.
4 min readIntermediate Oct 30, 2026
Explain Like I'm Not a Hacker
A research assistant who searches every filing cabinet in the company for you, including the locked ones, because nobody told them which drawers you may open.
The 30-second explanation
Many company assistants use a technique called retrieval-augmented generation, or RAG. When you ask a question, the system first searches a pile of documents, then hands the best matches to the AI so it can answer from them. The leak happens when that search never checks who is asking. If the index holds every file in the company, the assistant can quote a confidential one to anyone, because the search found it relevant and nothing asked whether you were allowed to read it.
How it works
- 1
1. Ingest
Documents from file shares, wikis and mailboxes are split into chunks and stored in a searchable index, often without their original permissions.
- 2
2. Ask
A user asks the assistant a question.
- 3
3. Retrieve
The system searches the whole index for the closest matches, whether or not this user may read them.
- 4
4. Answer
The model writes a reply from those passages, including text the user was never allowed to see.
A language model only knows what it was trained on, so companies connect it to their own documents with retrieval-augmented generation. The documents are cut into chunks and stored in a searchable index. When someone asks a question, the system finds the chunks closest to it and puts them in front of the model, which writes an answer from them. The model has no idea which of those chunks are confidential. It uses what it is given. That means the permission check has to happen earlier, at the moment of retrieval, and it has to use the asker's real access rights from the source system. In many first versions it does not. Every document goes into one big index, the original permissions stay behind in the shared drive, and anyone who can talk to the assistant can reach everything in it. Other leaks come from the index drifting out of date, where a file is locked down or deleted but its chunks live on. An instruction hidden in a retrieved document can also try to steer the assistant, which is the prompt injection problem again. A line in the system prompt asking the model to keep secrets is not access control, because the model can be talked out of it.
Real-world example
A team shares a draft acquisition plan in a project folder, and the company assistant indexes it. Later the folder is locked down to three people, but the index is only refreshed once a month. For weeks, anyone who asks the assistant about the project gets a summary of the plan. Nobody broke in. The source permissions changed, and the copy inside the index never found out.
How to spot it
Search that ignores who is asking
The index mixes everyone's documents, with no per-user or per-group filtering at query time.
Permissions copied once
Access rights captured at ingestion and never refreshed, so removed access keeps working through the assistant.
Answers that cite files the user cannot open
Quotes or citations from documents the person has no access to in the source system.
Access control left to the prompt
A system prompt telling the model not to reveal confidential information is the only barrier.
What to do
- 1Enforce access at retrieval time: filter results using the asker's permissions from the source system before any text reaches the model.
- 2Keep permissions in sync, refreshing the index when access changes and deleting chunks when a document is removed or locked down.
- 3Test with real accounts. Ask as a low-privilege user for things only an admin should see, and log which documents were retrieved for each question.
Stay curious. Stay safer.
This is one piece of a bigger picture. Explore more real-world examples, concepts and tips to build your cybersecurity awareness.
Keep reading
- LLM Threats
LLM Data Leakage: What an AI Might Reveal by Accident
2 min read - LLM Threats
Prompt Injection: How a Few Hidden Words Can Hijack an AI
5 min read - AI Security
Securing AI Systems: The Attack Surface Nobody Draws
2 min read - Insider Threats
Least Privilege: Why Nobody Should Have More Access Than They Need
2 min read