Secure RAG Is an Access-Control Problem Before It Is a Model Problem
- Secure RAG
- Data Access
- Identity
When a retrieval-augmented generation system leaks something it shouldn't, the postmortem almost always starts in the wrong place. Teams reach for the model: better system prompts, a stricter guardrail, a fine-tune to make it "refuse sensitive content." But the leak rarely originated in the model. It originated the moment a document the user was never authorized to see was placed into the context window. By then, the access-control decision had already been made — and made wrong.
Secure RAG is an access-control problem before it is a model problem. The model is the last component to touch the data, which makes it the easiest to blame and the least able to help.
The authorization model you already had
Before RAG, enterprise data lived behind decades of accumulated access control. A document in SharePoint inherited site and library permissions. A row in a database sat behind row-level security tied to the querying identity. An object in a data lake was governed by IAM policies, bucket ACLs, and tag-based rules. These systems are imperfect, but they share one property: the decision to return data is made with reference to who is asking.
Retrieval pipelines tend to throw that property away. The standard pattern looks like this:
- Ingest documents from many sources into a single corpus.
- Chunk and embed them into one vector index.
- At query time, embed the user's question and return the top-k nearest chunks.
- Stuff those chunks into the prompt and generate an answer.
Notice what is missing. Step 3 retrieves by semantic similarity, not by authorization. The index does not know that chunk 4,812 came from a board deck restricted to the executive team. The nearest-neighbor search will happily return it to anyone whose question is close enough in embedding space.
The RAG system has, in effect, minted a new data store — the vector index — and forgotten to bring the old permissions along.
Where the permissions actually go
There are only a few honest answers to "where is authorization enforced in this pipeline?" and most teams cannot point to one.
- At ingestion. You can choose what goes into the index, but ingestion is coarse. It is a publishing decision, not a per-query authorization decision, and it cannot model relationships that change after indexing.
- At retrieval. You can filter the candidate set by the caller's entitlements before — or during — the nearest-neighbor search. This is where enforcement belongs, and it is the part most architectures skip.
- At generation. You can ask the model to be careful. This is not access control. It is hope with a temperature setting.
- At the output. You can post-filter the answer. By then the sensitive content has already been read, embedded into reasoning, and possibly paraphrased past your filters.
The only durable place to enforce authorization is retrieval, because retrieval is the only step that still has both the data and the identity in hand at the same time.
Designing retrieval that respects identity
Concretely, secure retrieval means the index cannot be queried as an undifferentiated pool. Every chunk carries the access metadata of its source, and every query is scoped to the caller's entitlements before results are returned.
The guiding principle: a chunk should be unretrievable by a user who could not have opened the source document directly. Retrieval should never become a side channel around the permissions on the original.
In practice this pushes you toward a few decisions:
- Carry source ACLs into the index as filterable metadata — owners, groups, classification labels, tenant IDs — and apply them as hard pre-filters on every search, not as a re-ranking nudge.
- Resolve the caller's entitlements at query time, from the same identity provider the rest of the enterprise trusts, rather than caching a snapshot that drifts out of date the moment someone changes teams.
- Partition by trust boundary when a single shared index cannot safely represent the differences — per-tenant or per-classification indexes trade some efficiency for an enforcement boundary you can actually reason about.
- Treat permission changes as data changes. When access is revoked at the source, the index has to reflect it. A stale index is an open door.
None of this is exotic. It is the same authorization model the data already had, re-applied to the new store you created when you built the index.
Why this keeps getting skipped
If the fix is "enforce the existing permissions at retrieval," why is it so routinely missed? Because the easy version of RAG is genuinely easy, and the secure version is genuinely more work. A single flat index demos beautifully. Identity-aware retrieval requires you to model entitlements, propagate them through ingestion, and keep them fresh — work that lives at the unglamorous intersection of security engineering and data engineering, owned by neither team by default.
It is also a problem that hides. A flat-index RAG system behaves perfectly in every demo, every test with non-sensitive data, and every evaluation that does not specifically probe cross-user access. It fails only when a real user asks a real question that happens to retrieve something they were never meant to see — which is to say, it fails in production, quietly, in a way no one notices until it is an incident.
The reframe
The useful shift is to stop asking "is the model safe?" and start asking "can this user retrieve this chunk?" The first question has no satisfying answer. The second is the same authorization question your enterprise has been answering for years — and you already have the systems to answer it. The work of secure RAG is mostly the work of not throwing those answers away when you build the index.
Get retrieval right and most of the scary model-layer failures lose their teeth, because the dangerous content was never in the context window to begin with. Get it wrong and no amount of prompt engineering will save you, because by the time the model sees the data, the only mistake left to make has already been made.