RAG security: what changes when the AI can read your files
Retrieval is the feature that makes AI useful on company knowledge. It is also the feature that turns every indexed document into model input, and every permission mistake into a disclosure.
Retrieval-augmented generation (RAG) does not rely on what the model learned in training: the system finds relevant documents and puts them in front of the model as context. That makes it a new application, built on top of the company's document permissions, and it inherits every flaw in them.
The RAG pipeline: six stages, all inside the security boundary
A RAG pipeline has six stages: documents, indexing, an embedding and vector store, retrieval, the model and the answer. Someone decides which documents are in scope, and what happens when one changes classification. The index is a second copy of the content, and the embeddings are derived from the text; OWASP lists vector and embedding weaknesses at LLM08. In front of the model, retrieved content has to stay structurally distinct from instructions. The logs of an answer need the same protection as the source document.
Permissions belong at retrieval, not in the prompt
The assistant can search everything the company holds, and an employee asks it for the chief executive's employment contract. A refusal written into a prompt is the wrong fix: retrieval should never return a document the person could not open themselves.
RAG therefore needs document-level access control enforced during retrieval. A shared index with a model instructed to be discreet is not access control, because a model can be persuaded.
Every indexed document is untrusted input
Some of the documents in a corporate index were written by people outside the company: a supplier's invoice, a contract draft from the other side's lawyers, a candidate's CV, an inbound email.
That is the exact condition prompt injection needs, and it has produced a real vulnerability in a shipped product. CVE-2025-32711, disclosed in June 2025, was described as “a zero-click prompt injection vulnerability in Microsoft 365 Copilot that enabled remote, unauthenticated data exfiltration via a single crafted email”, and it scored 9.3. Microsoft fixed it server-side in May 2025.
Local retrieval, and what it does and does not fix
A private deployment can keep the documents, the embeddings, the retrieval step and the inference inside the organisation. For sensitive material that is an advantage, and it also settles where the second copy lives.
A cloud service can avoid duplicating the store too. Microsoft's documentation of its "on your data" feature states that “The data remains stored in the data source and location you designate; Azure OpenAI does not create a duplicate data store.”
The local advantage is therefore one of administration: the permission model, the index and the network path sit under one administration rather than three.
Seven questions before go-live
- Who can access each document today, outside the AI system?
- Are those permissions enforced during retrieval, for every query?
- Can a user obtain, through the assistant, content they could not open directly?
- Which indexed documents were written by someone outside the organisation?
- Where do the embeddings live, and who can read them?
- Are prompt and answer logs protected like the documents they quote?
- What tools can the model reach, and what is the worst a misled model could do with them?
With Bastion
What Bastion changes
Bastion is a private AI system delivered as one sealed box that runs inside your building. One monthly fee covers the hardware, the model, the hardened operating system and support, and nothing your team types leaves the building.
With Bastion, the documents, the index and the inference all stay on the site the customer chooses. The second copy never leaves it, and the retrieval path has one owner. The permission model is still the customer's to define.
Questions this article answers
- What are the security risks of retrieval augmented generation?
- Retrieval can return documents the user could not open themselves, which is a disclosure, and indexed documents written by outsiders become model input, which is the condition prompt injection needs. OWASP also lists vector and embedding weaknesses at LLM08.
- How do you enforce permissions in a RAG system?
- At retrieval, using the user's own access rights, so a document the person cannot open is never returned. A shared index with a model instructed to be discreet is not access control, because a model can be persuaded and an access control cannot.
- Can a document attack an AI assistant?
- Yes: CVE-2025-32711, disclosed in June 2025 and scored 9.3, was a zero-click prompt injection in Microsoft 365 Copilot in which one crafted email caused data exfiltration with no user interaction. Microsoft patched it and reported no exploitation in the wild.
On the record
- 1
- 2
- 3
The Hacker News
Zero-Click AI Vulnerability Exposes Microsoft 365 Copilot Data Without User Interactionread 2026-11-17
- 4
- 5
Microsoft Learn
Data, privacy, and security for Foundry Models sold by Azure in Microsoft Foundryread 2026-09-22
Read next
- Prompt injection: the attack that needs no clickLanguage models do not separate instructions from content, so any text the model reads can behave like a command. What EchoLeak showed, why retrieval makes it worse, and why running the model locally does not fix it.
- The OWASP Top 10 for LLM applications, read as a buyer's checklistThe ten risks in plain business language, which of them an on-premise deployment touches, which it does not, and the minimum an organisation of thirty people should do about them.