Security teams should treat the embedding pipeline as a control point, not a passive data transfer. Raw inputs need sanitization before vectorization, with PII, IP, and malicious instructions redacted or blocked. In production, apply a real-time layer between the application and the model to inspect prompts and outputs, prevent prompt injection, and preserve a trusted record of what was stored.
Why This Matters for Security Teams
Retrieval-augmented generation, or RAG, changes the security boundary because enterprise data is no longer just stored and queried, it is also retrieved, re-ranked, embedded, and reintroduced into model context. That creates new exposure for sensitive records, hidden instructions, and poisoned content. Security teams need to think in terms of data provenance, prompt integrity, and access enforcement across every stage of the workflow, not only at the application perimeter. The NIST Cybersecurity Framework 2.0 remains useful here because it pushes organisations to define assets, protect data flows, and verify outcomes rather than assuming the model layer is trustworthy by default.
The most common mistake is treating the vector database as a neutral index. It is not. Embeddings can preserve enough semantic detail to expose confidential material, and retrieved snippets can carry instructions that alter model behaviour. In practice, many security teams discover this only after a sensitive document has already been surfaced in an answer, rather than through intentional review of the retrieval path.
How It Works in Practice
Securing RAG requires controls at ingestion, storage, retrieval, and response. At ingestion, content should be classified before it is embedded, with clear rules for what may enter the corpus. High-risk material such as secrets, regulated personal data, and untrusted user submissions should be excluded, masked, or segmented into restricted stores. At retrieval time, the application should enforce authorization before any chunk is passed to the model, so a user can only retrieve content they are entitled to see.
Between the retrieval layer and the model, inspect the selected context for prompt injection, policy violations, and content drift. This is where a trust boundary is usually needed. Current guidance suggests validating both the user prompt and the retrieved passages, because either can carry malicious instructions. Logging should preserve the source document, embedding version, retrieval score, and final output so investigators can trace why a specific answer was produced.
- Apply data classification before embedding, not after retrieval.
- Separate sensitive corpora by access tier or business function.
- Authenticate and authorize retrieval requests against enterprise identity controls.
- Scan retrieved passages for instructions that try to override system behaviour.
- Keep immutable records of corpus changes, embedding jobs, and answer generation.
Operationally, this also means treating the vector store as governed infrastructure. Index rebuilds, retention windows, and re-embedding schedules should be change-controlled, because stale or poisoned vectors can persist long after the source document has been removed. The same applies to downstream caches and export jobs, which can reintroduce data that policy would otherwise block. These controls tend to break down when multiple teams write to the same corpus without a shared approval path because provenance and authorization decisions become inconsistent.
Common Variations and Edge Cases
Tighter retrieval controls often increase latency and operational overhead, requiring organisations to balance user experience against confidentiality and auditability. That tradeoff is especially visible in high-volume assistants that query many documents per answer. In those environments, best practice is evolving rather than settled, particularly around how much contextual filtering should happen before versus after ranking.
Some RAG deployments rely on public or semi-public corpora, while others index internal policy, support tickets, contracts, or source code. The risk profile changes with each one. For example, code search assistants need strong protection against secrets leakage and dependency abuse, while customer support systems may need stronger PII redaction and retention controls. There is no universal standard for this yet, so control design should follow data sensitivity and retrieval scope rather than the model brand.
Agentic workflows add another layer of risk because an AI agent may not only retrieve data, but also act on it by opening tickets, sending messages, or changing records. That intersection matters for identity governance: the retrieval layer can become a privilege escalation path if the agent can access more data than the human requester or if tool permissions are broader than retrieval permissions. In those cases, apply the same discipline used for privileged identity paths: narrow access, verify intent, and keep strong audit trails.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Agentic AI Top 10 and MITRE ATLAS address the attack and risk surface, while NIST CSF 2.0, NIST AI RMF and NIST AI 600-1 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | PR.DS | RAG security centers on protecting sensitive data across ingestion, storage, and retrieval. |
| NIST AI RMF | GOV | RAG needs governance for provenance, accountability, and acceptable use of embedded data. |
| OWASP Agentic AI Top 10 | LLM01 | Prompt injection through retrieved context is a core agentic AI failure mode. |
| MITRE ATLAS | AML.T0058 | Poisoned or manipulated training and retrieval data map to adversarial ML threats. |
| NIST AI 600-1 | GenAI profiles address data handling, output validation, and secure deployment patterns. |
Classify and protect embedded data end-to-end, then verify retrieval paths preserve confidentiality.
Related resources from NHI Mgmt Group
- How should security teams use RAG in IAM workflows?
- How should security teams protect vector databases that contain sensitive AI data?
- How should security teams govern AI workflows that use multiple tools and data sources?
- How should security teams govern sensitive data use in browser-based workflows?