RAG (Retrieval-Augmented Generation: letting an AI search the organization's documents before it answers) lets a chatbot answer from internal data. It also puts internal documents into a new system that needs the same permission control as any other. If that system retrieves documents without asking whether the asker may read them, the AI's answer becomes a path for data to leak. This article explains in plain terms how RAG works, where data leaks, and which controls to put in place.
How RAG works
First the system splits documents into small pieces and turns each piece into an embedding (a list of numbers that represents the meaning of the text, used for search by meaning). These are stored in a vector database (a database built to store and search embeddings; the data kept for searching is called the index) together with the original text of the piece. When someone asks a question, the system finds the pieces closest in meaning, hands them to an LLM (large language model) to read, and the LLM writes the answer.
The point to remember is that the vector database also keeps a copy of the document text, not just numbers. Our observation is that this copy may not carry the access rights of the source document. OWASP (a nonprofit software security organization) lists LLM08:2025 Vector and Embedding Weaknesses in its OWASP Top 10 for LLM Applications 2025 (the ten leading risks for applications built on language models, per the OWASP web page checked in November 2026). It says flaws in how embeddings are generated, stored, or retrieved can be used to access sensitive information or inject harmful content.
Where data can leak
- Documents indexed without permission checks: the system pulls everything from a shared drive, so an asker may get answers from documents they normally cannot open. OWASP describes a scenario where data with different access restrictions is combined and leaks
- Vector stores holding sensitive text: embeddings and the stored original text must be treated at the same level as the documents. OWASP notes that attackers may use embedding inversion (reversing embeddings to recover the source) to recover a significant amount of source information
- Over-broad retrieval: if the system hands many pieces to the model, the answer can carry unrelated data or mix data from several users or customers (OWASP calls this a cross-context leak, where information leaks across contexts)
- Poisoned documents (data poisoning): an attacker puts text people cannot see, such as white text on a white background, into a document headed for the knowledge base. OWASP gives this example. The text can hide instructions that push the model to answer wrongly or reveal data
- Logs that keep too much content: recorded questions, retrieved pieces, and answers can become another store of sensitive data if access and retention are not limited
Our view: the most common gap is a pilot that connects RAG to a central drive for speed, using a service account that can read everything. The new system then bypasses permissions the organization built over years. Checking how answers look is not enough. Test with a low-privilege user account and see what a question reveals.
Risky
- Service account reads alleveryone sees what it sees
- One index for everythingdata classes get mixed
- Test only answer qualityno low-privilege test
Safer
- Filter by asker at query timebefore the model sees it
- Separate by class or tenantless cross-group mixing
- Test with low-privilege userssee what exceeds their rights
Controls to have
- Document-level access control at retrieval time: keep the list of who may read each piece with the data, then filter search results by the asker's identity before anything reaches the model. OWASP calls this a permission-aware vector store, together with partitioning datasets
- Classify data before indexing: decide which data classes may enter RAG and which may not, and label them clearly
- Isolate tenants: a tenant (each customer or unit sharing the system) should have a separate index or storage area, not one shared set protected only by a filter
- Redact before ingestion: redaction (removing or masking personal and secret data from text) limits the damage if the index leaks
- Check sources and monitor: validate every document before it enters the knowledge base, let only authorized people add documents, and keep detailed, tamper-resistant logs of retrieval, as OWASP recommends
These controls build on work many teams already do, such as Data Classification: how to classify data and DLP (Data Loss Prevention) explained. Set what retrieval logs contain and how long they are kept using Log Management: what to log and for how long. If indexed documents contain personal data (under Thailand's personal data protection law, the PDPA), see PDPA security measures as well (this is general information, not legal advice; confirm with legal counsel), and see the wider picture in AI Security and AI Governance.
Where to start
- Inventory your RAG systems: note which sources each one reads and which account it uses
- Test with a low-privilege account: ask questions that should be refused and see what the system reveals
- Classify data and choose sources: begin with documents that are fine to share internally
- Turn on retrieval logging and name an owner: with a retention period
- Assess overall readiness: use the assessment to start the conversation with the teams involved