The most damaging RAG failure is leaking one user's or customer's data to another. Prompts cannot prevent it; retrieval design can.
Principles
- Enforce outside the model. Filter what is retrieved, rather than asking the model to hide things.
- Use the end user's identity. Evaluate permissions per request.
- Default deny. Unlabelled content should not be retrievable.
Patterns
- Separate indexes per tenant: strongest isolation, simpler reasoning, more operational overhead.
- Shared index with tenant and ACL metadata filters: efficient, but filters must be applied on every query and tested.
- Sync source permissions: mirror document-level permissions from the source system and refresh them regularly.
Test for leaks
Write tests where one user asks about another tenant's data and confirm nothing is retrieved or cited. Re-run on every change. Include prompt-injection attempts; see AI agent security.
Log and review
Record which documents were retrieved for each answer to support audits and incident analysis.
Privacy link
Personal data in indexes also triggers DPDP and GDPR duties such as deletion. Design for deletion by source ID. See RAG development.
Frequently asked questions
How do I stop RAG leaking confidential documents?
Enforce permissions in the retrieval layer using tenant and access-control filters, default to deny and test for cross-tenant leaks.
Is a separate index per customer necessary?
Not always. Filtered shared indexes can work if filters are enforced on every query and tested, but separate indexes give stronger isolation.
Can the prompt enforce access control?
No. Prompts are not a security boundary.
Related: RAG development · Agent guardrails · Vector databases
Want a straight answer for your project?
Book a 30-minute call. I will tell you what I would do, and a fixed price if it makes sense.