When a company's confidential data is processed by an AI system, what risks does that data face at every stop along the pipeline, and how can those risks be mitigated?
Compliance for RAG is thornier than for traditional databases because RAG inherently lacks an audit trail. A single query reads, retrieves, and summarizes across multiple sources within seconds, while regulations like GDPR and HIPAA require companies to account for where personal data is stored and how it's used. Once the system surfaces personal data in an answer where it shouldn't appear, demonstrating compliance after the fact is often extremely difficult. The following breakdown examines risks by the four "states" of data — these four states (at rest, in transit, in use, and residency) reflect generally accepted security concepts, though organizing them as a four-item checklist is this guide's framing, not an official classification from any compliance standard (such as ISO 27001 or SOC 2).
| Data State | Where It Appears | Primary Risks | Mitigations |
|---|---|---|---|
| ① At Rest (data stored and not moving) | Vectors and original-text chunks in the vector database; model weights after fine-tuning; logs; backups | Original text often sits in plaintext scattered across multiple locations; vectors have been demonstrated to be reversible back to original text: short text fragments can be recovered at a high success rate, and newer methods don't even require training specifically against the target embedding model; OWASP explicitly recommends treating a vector-only leak the same as a plaintext leak — "stored as vectors" does not mean "de-identified"12. Weights memorize training data and are difficult to selectively delete | Encryption at rest + customer-managed keys, strict access controls, ensure data can be fully deleted |
| ② In Transit (data moving over the network) | Every transmission within the system. RAG is inherently distributed — a single query triggers multiple internal transfers (query sent to vector database, document chunks retrieved, chunks forwarded to model); the most critical of these is the complete prompt being sent to a cloud-hosted model | TLS (the padlock in the browser bar) only prevents third-party eavesdropping mid-transit — it does not keep the content confidential from the recipient. Using a public cloud-hosted model means the confidential original text genuinely leaves the company's boundary and is processed by another company | Self-host or use inference services meeting data sovereignty requirements; redact before sending; clearly define which data must never leave the boundary |
| ③ In Use + Logs (data being processed or being recorded) | The KV cache held temporarily during inference; the complete prompt and response recorded by the logging platform | The most easily overlooked yet highly risky: logs are a persistent plaintext copy of confidential content; if the contract permits, they may also be used for training or retained long-term | Redact before logging; set maximum retention periods (e.g., 30 days); contractually specify usage restrictions |
| ④ Residency + Access (where data lives, who can see it) | The physical location of each storage and inference component (which country, which legal jurisdiction); access controls when RAG retrieves original documents | Cross-border transfers may violate local regulations; unauthorized retrieval — the moment a document is converted into vectors and indexed, its original access permissions are stripped away; without explicitly re-attaching them, the system will retrieve and include content the user has no right to view | Ensure storage locations are compliant; bind every chunk to the source document's permission list (ACL) at indexing time; filter by querying user's identity in real time during retrieval |
Three points in the table are worth calling out separately, because they are the most counterintuitive and the most likely to become buried risks:
"Deletion" is often an illusion. For performance reasons, vector databases default to "soft deletion" at the metadata layer — an API returning no error is taken as successful deletion, but the data may still physically exist. This is the same pain point as "weights are difficult to selectively delete," manifesting at a different storage layer — and GDPR Article 17 requires true, complete deletion.
Redaction isn't as simple as blacking things out. Naive redaction destroys semantics: if you simply strip out names or account numbers, the model also loses the information it needs to produce a useful answer. For example, "Customer ___ 's account ___ was double-charged" leaves the model with a broken sentence it can't properly process. The correct approach is context-preserving tokenization rather than brute-force removal: replace "John Smith" with [NAME_1] and the specific account number with [ACCOUNT_1], producing "Customer [NAME_1]'s account [ACCOUNT_1] was double-charged." The sensitive values are hidden from the model, but the role information — "there is a name here," "there is an account number here" — is preserved, so the model can still follow the sentence structure and produce a useful answer, instead of staring at a bunch of blanks.
Permissions are lost by default. Documents from Confluence, SharePoint, or an internal wiki — once converted into vectors, their original access controls no longer travel with them. This is precisely why "binding ACLs" must be done as an explicit additional step — it does not happen automatically.
None of this is alarmist. The next chapter switches to the attacker's perspective and walks through these risks again.
Two conclusions most worth remembering:
- The single most sensitive action across the entire pipeline is the moment confidential content is assembled into a complete prompt and sent to a cloud-hosted model — this is the point at which data truly leaves the company's control.
- The single most easily overlooked risk point is the logging system — all the attention goes to "is the database secure," while forgetting that the logs also contain a complete plaintext copy of every conversation.
Further reading: what does a managed cloud model (MaaS) actually retain?
MaaS (Model-as-a-Service) refers to cloud-hosted models accessed via network calls, as opposed to self-hosted deployments. What it actually retains is a key compliance question:
- Weights are read-only: the content of your queries does not get written into the model's parameters or change the model itself. "The model has its own storage" is a common misconception — unless the provider deliberately uses conversations for subsequent training, which is a separate matter.
- Prompt caching is an easily overlooked short-term landing point: if the provider enables cross-request prompt caching (see Section 3.3), a portion of the request content resides briefly in their infrastructure in the form of KV cache. This is not the same as training or long-term retention, but strictly speaking, inference is not entirely stateless.
- What is actually retained long-term is logs (complete Q&A plaintext), abuse-detection records, and (when the contract allows) data used for training — whether it's retained, and for how long, depends on contract terms and technical settings.
- ZDR (Zero Data Retention): a contract clause that, once signed, disables the persistent retention described above. But you should verify whether it covers infrastructure-level short-term residency like prompt caching, to avoid leaving a gap. OpenAI's documentation notes that, at least for some models, organizations with ZDR enabled default to keeping the cache in memory only, without the extended 24-hour retention option.3
Take OpenAI as an example: its API has defaulted to not training on customer data since March 2023, but every API call still generates "abuse-monitoring logs" that may include prompts and responses, retained for up to 30 days; excluding this requires applying for Zero Data Retention and getting OpenAI's advance approval.4 So "won't train on your data" and "won't retain your data" are two separate questions — ask about them separately when evaluating a provider.
-
Morris et al., Text Embeddings Reveal (Almost) As Much As Text, EMNLP 2023. On the GTR model, 32-token text is recovered exactly 92% of the time; on OpenAI's text-embedding-ada-002, 32-token recovery is 60.9%, dropping to 8.0% at 128 tokens; 89% of patient full names could be recovered from clinical-note fragments. https://arxiv.org/abs/2310.06816 ↩
-
OWASP GenAI Security Project, OWASP Top 10 for LLM Applications 2026, LLM09:2026 Vector and Embedding Weaknesses. https://genai.owasp.org/resource/owasp-genai-llm-top-10-2026/ (original text in the GenAI Security Project's GenAI-LLM-Top10 repository, 2026/final directory) ↩
-
OpenAI, Prompt caching. https://developers.openai.com/api/docs/guides/prompt-caching ↩
-
OpenAI, Data controls in the OpenAI platform (official documentation). https://developers.openai.com/api/docs/guides/your-data ↩