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 — an attacker with read access to the vector database can use off-the-shelf tools to reconstruct sensitive content; "stored as vectors" does not mean "de-identified." 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; soft-deleted vectors can even be reconstructed. 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 — e.g., "Customer ___ 's account ___ was double-charged" becomes unreadable to the model with the blanks. 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. OWASP listed "Vector and Embedding Weaknesses" as a newly added standalone category in its 2025 edition1, and placed prompt injection as the number-one risk for LLM applications — and RAG is precisely the architecture with the largest attack surface.
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.
-
OWASP GenAI Security Project, OWASP Top 10 for LLM Applications 2025 — LLM08:2025 Vector and Embedding Weaknesses, a newly added standalone category relative to the 2023 edition. The list itself was published November 2024. https://genai.owasp.org/llm-top-10/ ↩