Join our Newsletter — 33% off our NHI Course

LLM RAG

LLM RAG, or retrieval augmented generation, is a method for helping a large language model answer using external information instead of memory alone. The system retrieves relevant documents or data at query time, then feeds them into the model so outputs are more current, grounded, and easier to govern in enterprise and NHI workflows.

What RAG Changes in an LLM Workflow

Retrieval augmented generation changes the model from a purely parametric system into one that can consult external sources at query time. That makes the answer path more current, more auditable, and more dependent on the quality, freshness, and permissioning of the retrieved material.

For practitioners, the key shift is that the model is no longer the only source of truth. The retrieval layer becomes part of the trust boundary, because whatever it fetches can shape the final answer as strongly as the prompt itself.

How Retrieval Becomes Part of the Security Boundary

RAG is not just an architecture pattern for better answers, it is also a control point. If retrieval is broad, stale, or poorly scoped, the system can surface sensitive documents, over-rank the wrong corpus, or reproduce content that should never have been available to the user in the first place.

That is why the retrieval layer needs the same scrutiny as any other access path. In enterprise settings, the documents, indexes, embeddings, and vector stores behind RAG often carry the same sensitivity as the source systems they mirror, and they can expose data even when the base model is well governed.

Permission-aware retrieval is especially important when RAG is used for enterprise search or knowledge assistants, as shown in NHIMG’s Permission-Aware RAG Guide.

Why RAG Is Useful for Current and Governed Answers

RAG is popular because it helps reduce hallucination, improves grounding, and lets organisations answer from governed sources instead of asking the model to improvise. It is especially valuable where policy documents, tickets, incident records, product data, or internal knowledge change faster than a model can be retrained.

That same benefit is also what makes RAG operationally attractive in security-sensitive workflows. Teams can constrain the model to approved repositories, attach provenance to responses, and make retrieval decisions visible enough to review after the fact.

When used well, RAG supports a cleaner separation between the model’s generation role and the organisation’s knowledge governance role. The model reasons over supplied context, while the organisation retains ownership of what may be retrieved, shown, and retained.

Where RAG Fails in Practice

RAG fails when retrieval is treated as harmless plumbing. Over-sharing from indexes, weak document-level permissions, malicious or poisoned source data, and poor isolation between tenants or users can turn retrieval into a data-exposure mechanism rather than a control.

It also fails when teams assume that grounding alone makes the output trustworthy. A well-grounded answer can still be wrong, incomplete, or unsafe if the retrieved source set is stale, polluted, or selected through a biased ranking path.

In other words, the model may be generating text, but the risk often originates earlier in the pipeline, in how the corpus is collected, indexed, filtered, and exposed to the retrieval layer.

Risk and Threat Considerations

RAG expands the attack surface by introducing a retrieval layer that can be abused for over-sharing, prompt injection through retrieved content, source poisoning, and unintended disclosure of indexed material. The threat is not only bad answers, but also the exposure of documents, secrets, or internal context that should never have entered the retrieved set.

Failure mechanism: If an attacker can influence the corpus, the ranking path, or the access controls on the retrieval store, they can steer the model toward unsafe context or extract information through a query path that appears ordinary.

Impact: The result can be data leakage, policy bypass, unauthorized disclosure across users or tenants, and compromised trust in the assistant’s output and provenance.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5, OWASP ASVS and CSA Cloud Controls Matrix set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
NIST SP 800-53 Rev 5 AC-6 — Least Privilege RAG retrieval should limit what context each user can reach.
IA-5 — Authenticator Management RAG deployments often rely on service credentials for connectors, indexing, and search backends.
Recommendation — Restrict retrieval scope so each query can access only approved context. Rotate and protect credentials used by retrieval connectors and indexes.
OWASP ASVS V14 — Data Protection RAG exposes sensitive content handling, storage, and disclosure risks in the application path.
Recommendation — Classify retrieved content and enforce disclosure controls around sensitive data.
OWASP Non-Human Identity Top 10 NHI-02 — Secret Leakage RAG workflows can surface API keys, tokens, and other secrets from source material.
Recommendation — Scan source corpora and indexes for secrets before they can be retrieved.
CSA Cloud Controls Matrix IAM — Identity and Access Management Cloud-hosted RAG systems depend on access control for data sources, vector stores, and connectors.
Recommendation — Apply IAM controls to the data sources and services that feed retrieval.

Practitioner Guidance

Why practitioners should care: RAG security starts with the retrieval boundary, not the model prompt. Treat the index, vector store, document pipeline, and source permissions as first-class security components, because they determine what the model can know at all.

Common misunderstanding: Many teams secure the LLM endpoint and assume the system is safe. In reality, retrieval scope, document filtering, and source hygiene often determine whether RAG is useful or dangerous.

Practitioner takeaway: If the retrieved context would be unacceptable to show a user directly, it is not safe to let RAG feed it to the model either.