By NHI Mgmt Group Editorial TeamPublished 2026-06-09Domain: Agentic AI & NHIsSource: Lasso Security

TL;DR: RAG security extends beyond model output quality because retrieval pipelines can expose documents, vector stores, logs, and context to prompt injection, data leakage, and excessive access, according to Lasso Security. The real issue is that existing IAM and data controls were not designed to govern what language models retrieve, trust, and transform at runtime.


At a glance

What this is: RAG security is the discipline of protecting retrieval-augmented generation pipelines, with the key finding that retrieval, storage, and generation each introduce distinct exposure paths for sensitive data and malicious instructions.

Why it matters: It matters because IAM, NHI, and AI governance teams have to control what model-mediated systems can retrieve and use, not just who can log in to the application.

By the numbers:

👉 Read Lasso Security's analysis of RAG security risks and mitigation strategies


Context

RAG security is the control problem created when retrieval systems pull documents, embeddings, and knowledge-base content into model responses. The application can be technically correct and still be unsafe if the model trusts poisoned content, over-broad retrieval paths, or sensitive logs that should never have been exposed in the first place. For identity teams, the issue is not only model quality but also which identities, contexts, and permissions are allowed to shape what the model can see.

That makes RAG a governance problem across IAM, NHI, and AI controls. A retrieval pipeline can amplify a weak service account, an over-shared data source, or a poorly bounded automation path into a data exposure event. The right question is not whether the model is accurate enough, but whether the access path feeding the model is defensible under least privilege and data minimisation principles.


Key questions

Q: How should security teams control access in a RAG pipeline?

A: Security teams should control access at the retrieval layer, not only at the application layer. That means scoping who can query which collections, which service accounts can write to vector stores, and which data sources are eligible for retrieval. Context-based access control is the right pattern because it ties access to the request context rather than assuming all retrieved content is equally safe.

Q: Why do RAG systems create more data exposure risk than standard chatbots?

A: RAG systems can expose more data because they connect live repositories, embeddings, and documents directly into the generation process. If those sources contain sensitive or poorly classified content, the model can surface it in responses or workflows. The risk is not just incorrect output, but unsafe retrieval from systems that were never designed for model consumption.

Q: What breaks when prompt injection reaches a RAG retrieval layer?

A: When prompt injection reaches the retrieval layer, the system can treat malicious text as trusted context because semantic similarity is mistaken for legitimacy. That breaks the assumption that retrieval only returns safe evidence. The practical result is that the model may follow attacker-supplied instructions, leak data, or summarize harmful content as if it were approved material.

Q: How do security teams decide whether to use validation or retrieval controls first?

A: Security teams should prioritise retrieval controls first because validation cannot reliably fix unsafe context after it has entered the prompt window. Output checks are still useful, but they work best as a second layer. If the pipeline can retrieve sensitive or malicious content in the first place, the downstream validator is already working against a compromised input set.


Technical breakdown

Why retrieval layers create a new trust boundary

A RAG pipeline is only as trustworthy as the data it retrieves. The retrieval layer searches vector databases or knowledge bases, then passes matched content into the generation layer. That means security decisions happen before the LLM even speaks: if a document is poisoned, over-permissioned, or over-classified, the model may treat it as legitimate context. This is why prompt injection in RAG is so effective. The system is not just reading text, it is operationalising retrieved text as if it were approved instruction or evidence.

Practical implication: treat retrieval sources as security-bound inputs and review who can write to them, not just who can query them.

Vector databases as identity and data exposure surfaces

Vector databases hold embeddings that represent source material in machine-readable form. That abstraction improves retrieval, but it also creates privacy and integrity risks. Embeddings can be inverted, reconstructed, or exposed through weak access control, and the data they reference may be sensitive even when the vector itself looks innocuous. In practice, the vector store becomes both a data asset and an identity boundary because the accounts, tokens, and APIs that access it determine what the model can surface. Poorly scoped credentials here are not a minor implementation detail, they are the control plane for model context.

Practical implication: classify vector-store credentials and API access as high-value NHI privileges and govern them accordingly.

Why generation-stage validation cannot compensate for bad retrieval

Output filters and validators can reduce obvious harm, but they do not solve the root problem if the model was fed malicious or sensitive context in the first place. Once retrieved content enters the prompt window, the model may summarise, combine, or expose it in ways that bypass simple post-generation checks. This is why RAG security has to span the full path from source data to generated output. The control objective is not merely to block bad answers, but to stop unsafe context from entering the reasoning process.

Practical implication: pair output validation with input controls, provenance checks, and retrieval allowlisting.



NHI Mgmt Group analysis

RAG security is really an identity problem disguised as a model problem. Retrieval systems only work safely when the identities that populate the knowledge base, access the vector store, and feed the prompt are tightly bounded. If those identities are over-privileged, the model becomes a fast amplifier for existing access mistakes rather than a new source of intelligence. Practitioners should treat retrieval paths as governed access paths, not as neutral plumbing.

Prompt injection works in RAG because the system over-trusts retrieved content. The control failure is not just that malicious text exists, but that the pipeline often lacks a strong distinction between approved source material and content that merely matches semantically. That collapses the assumption that relevance equals trust. The implication is that semantic similarity without provenance is an unsafe basis for automation.

Context-based access control is the right lens, but only if it is enforced at the retrieval layer. RAG changes the problem from document access to context access, which means the governing unit is the specific request, user, and data combination. That aligns with modern zero trust thinking and with NIST Cybersecurity Framework 2.0 style governance, where access is continuously evaluated rather than presumed. Practitioners should stop treating AI as an application wrapper and start treating it as a policy-enforced decision path.

Malicious or stale knowledge becomes a governance issue when the model can act on it at runtime. The highest-risk failure mode is not a hallucination in isolation, but a generated answer that triggers a workflow, reveals a secret, or informs a human decision as if it were verified fact. RAG therefore sits at the intersection of data governance, IAM, and operational trust. Security teams should evaluate whether the system can distinguish between retrieved evidence, untrusted instructions, and policy-approved action.

RAG expands the blast radius of weak secrets hygiene across AI workflows. If API keys, backend credentials, or internal documents are reachable through the retrieval path, the model can surface them faster than traditional controls can react. The issue is not limited to model safety. It is a governance exposure that crosses NHI, data security, and automation boundaries, so practitioners need one control model that spans all three.

From our research:

  • 72% of organisations have experienced or suspect they have experienced a breach of non-human identities, 46% confirmed and 26% suspected, according to The 2024 ESG Report: Managing Non-Human Identities.
  • Enterprises that have experienced a compromised NHI averaged 2.7 separate incidents in the past 12 months, according to the same report.
  • For a wider view of breach patterns, see The 52 NHI breaches Report for recurring compromise patterns across machine identities.

What this signals

Identity blast radius: RAG makes context the unit of risk, which means the next governance shift is from protecting documents to protecting the identities and scopes that can surface them. If your pipeline can retrieve sensitive content through a service account or token with standing privilege, the model will inherit that access path. In practice, this pushes IAM and data teams toward tighter context scoping, better provenance, and stronger separation between read and write identities.

With 72% of organisations already reporting or suspecting NHI breaches, the control gap around machine identities is no longer abstract. RAG systems intensify that gap because the same service accounts and API keys that power retrieval can also expose confidential source material if they are over-scoped or poorly monitored.

RAG governance will increasingly look like a blend of NHI lifecycle management and zero trust policy enforcement. Teams that can map which identities feed the retrieval layer, which sources they can reach, and which outputs they are allowed to influence will have a materially better chance of containing prompt injection and accidental disclosure.


For practitioners

  • Restrict retrieval sources by context Apply context-based access control to the knowledge bases and document sets feeding RAG so retrieval only occurs for approved users, roles, and request contexts.
  • Lock down vector-store identities Inventory the service accounts, API keys, and tokens that can read or write vector databases, then remove unnecessary write access and monitor for standing privilege.
  • Add provenance checks before generation Tag source documents with ownership, sensitivity, and freshness metadata so the pipeline can exclude stale or untrusted content before it reaches the prompt window.
  • Validate model outputs against policy Use rule-based validation and approval gates for outputs that could expose secrets, trigger automation, or influence regulated decisions.

Key takeaways

  • RAG security is a governance problem because retrieval systems can turn over-privileged data sources into unsafe model context.
  • The evidence is consistent across NHI research: machine identities and exposed secrets create fast-moving breach paths that AI pipelines can amplify.
  • Practitioners need retrieval-layer access control, provenance checks, and output validation if they want RAG to be safe at scale.

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 OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Agentic AI Top 10A2RAG prompt injection and unsafe tool-context boundaries map directly to agentic AI input risks.
OWASP Non-Human Identity Top 10NHI-01RAG pipelines rely on machine identities that can overreach into sensitive stores.
NIST Zero Trust (SP 800-207)PR.AC-4Context-based authorization is a zero trust problem because access must be evaluated per request.

Apply continuous access decisions to retrieval requests and do not assume model-mediated access is inherently safe.


Key terms

  • Retrieval-Augmented Generation: A design pattern that combines search or retrieval with language-model generation so the model can answer using external content. In security terms, it creates a new trust boundary because the model may act on retrieved data as if it were approved context, even when the source system was never designed for that use.
  • Context-Based Access Control: An access model that grants or denies access based on the request context, such as identity, data sensitivity, purpose, and environment. In RAG systems, it helps govern which documents, collections, or embeddings a user or service account may retrieve for a given interaction.
  • Vector Database: A database that stores embeddings, which are machine-readable representations of content used for semantic search. Security teams should treat it as both a data store and an identity-controlled asset because the credentials that access it determine which context a model can surface or infer.
  • Prompt Injection: A technique where malicious instructions are embedded in content that a model later reads or retrieves. In RAG, the attack works because the system may confuse attacker-authored text with trusted source material, allowing harmful instructions to influence model output or downstream actions.

Deepen your knowledge

NHI governance, agentic AI identity, and machine identity security are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are responsible for identity security strategy or identity lifecycle management in your organisation, it is worth exploring.

This post draws on content published by Lasso Security: RAG security risks and mitigation strategies. Read the original.

NHIMG Editorial Note
Published by the NHIMG editorial team on 2026-06-09.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org