ChangeGamer

← All guides · RAG in production

Permission-Aware Retrieval: Multi-Tenant RAG Without Leaks

Part 8 of RAG in production · 906 words · ~4 min read · published 2026-08-23 · updated 2026-08-23 · Markdown variant

How to enforce access control inside retrieval for multi-tenant RAG: authorization as mandatory pre-filters derived from the authenticated principal, tenant isolation mechanics, permission-negative testing, and the post-filter trap that produces empty answers.

In short

  • Access control in RAG must be enforced inside retrieval — as mandatory query-time filters derived from the authenticated principal — not around it. A prompt instruction telling the model to 'only use documents the user may see' is not access control; by the time the model speaks, the retriever has already fetched what it fetched.
  • Pre-filter before ranking, never post-filter after. Post-filtering a merged candidate list produces the classic empty-answer failure: every top hit came from one channel, every one fails the filter, and the system answers from nothing.
  • Tenant isolation is a security boundary with security-boundary testing: maintain permission-negative cases (queries that must return nothing for unauthorized principals) in the eval suite and run them continuously, so leakage surfaces as red builds instead of incidents.
  • Privacy obligations attach to chunks like they attach to records anywhere: data residency, retention schedules and deletion requests must propagate into index metadata and ingestion, or your RAG system becomes the part of the stack that quietly violates them.

Part of the Agentic RAG in Production: The Complete Operator Guide guide.


Multi-tenant RAG fails differently from single-tenant RAG: the dangerous failure is not a wrong answer but an answer someone was never allowed to see. The pillar guide groups permissions with freshness as correctness requirements; this article specifies the enforcement architecture.

Where does authorization actually happen?

The safe pattern derives filters from the authenticated principal and applies them inside every retrieval channel, before ranking:

  1. Request arrives with verified identity (token, session, API key) — never with a claimed identity in the payload
  2. The authorization layer resolves that identity to concrete filter predicates: tenant equals X, group in Y, clearance at least Z
  3. Every retrieval channel — lexical, dense, fused — runs its query with those predicates attached
  4. Fusion, reranking and assembly operate exclusively on already-authorized evidence

Anything the principal cannot see never enters a candidate list, so no downstream stage needs to remember the rules. The alternative architectures all fail recognizably: post-filters empty out results; two-pass retrieve-then-reauthorize wastes the leak window; prompt instructions are negotiation targets, not boundaries.

What does good tenant isolation require mechanically?

Four properties, checked rather than assumed:

Namespace-per-tenant versus shared-index-with-filters is the main architectural fork: separate namespaces give blast-radius isolation and simpler deletion but multiply operational overhead; shared indexes with mandatory filters are cheaper to run but depend entirely on filter discipline. Both are defensible; unenforced either is a leak.

How do permission changes propagate?

Permissions change on different clocks than documents do — roles shift, users leave, groups reorganize — and none of it touches source documents. Propagation therefore needs its own pipeline: policy changes emit events that update ACL metadata on affected chunks within a declared bound, exactly like document freshness (the freshness guide describes the same contract shape). Revocation lag is exposure time; measure it.

What about privacy obligations beyond tenants?

Residency, retention and subject-deletion duties apply to chunks because chunks contain the personal data. Concretely: deletion requests must reach tombstones inside SLA; regional commitments constrain where embedding stores run; retention expiry should sweep indexes, not just databases. The data privacy reference maps the obligations; the RAG-specific point is that ingestion multiplied copies of everything, so your compliance surface grew at ingest time too.

How should filters be represented in practice?

Three representations dominate, each with trade-offs worth naming:

Hybrids are common: namespace isolation for the hard boundary plus ACL filters inside a tenant for fine-grained sharing. Whichever representation you choose, derive it from one authorization source of truth so policy lives in exactly one place.

What do agents change about permissioning?

Agents request data with delegated authority — acting for a user or a workspace — so the principal your filters see must be the effective principal (the delegating user's scope), not the agent's own service identity. Delegation chains need careful propagation: an agent authorized to act for Alice inherits Alice's retrieval scope for this action, nothing more. Conflating the service identity with the delegating user is how agents accidentally become global readers; keep the mapping explicit in every retrieval call, and log both identities so audits can tell them apart.

What does done look like?

A multi-tenant RAG system is permission-done when: filters derive from authentication and run pre-ranking on every channel; the eval suite contains permission-negative cases that run in CI and production probes; revocation propagation is measured against a bound; privacy deletion propagates to chunks; and the security review covers the retriever with the same seriousness as the login page (security checklist). None of that is exotic — it is ordinary access-control engineering applied at the retrieval layer, which is precisely where skipping it costs the most.

The economics argue for doing this early: retrofitting permission metadata onto a large indexed corpus means reprocessing everything, while building filters in at ingest time costs almost nothing. Of all the production RAG investments, permission-aware retrieval has the worst retrofit-to-advance cost ratio — which is why the multi-tenant teams who skipped it end up rebuilding their indexes exactly once, on the day a customer asks the question every enterprise buyer eventually asks: prove my data cannot leak to your other customers.

The proof they want is exactly the artifact list from this article: filter-derived-from-authentication architecture, permission-negative test evidence, revocation-lag measurements, and a privacy story that includes chunks. Teams with those four artifacts pass enterprise security review in days; teams without them discover which of the two RAG failure modes matters most — not the wrong answer, but the answer someone else was entitled to.

Frequently asked questions

Why is prompt-level access control insufficient?
Because retrieval has already happened before generation begins. Whatever the prompt says, the candidate passages were selected by filters that either enforced permissions or did not; the model can only choose among what it was handed, and it may quote any of it. Enforcement belongs where selection happens — as filters applied to every channel before ranking and fusion — with the principal identity taken from verified authentication, never from anything the request text claims.
What is the post-filter trap?
Retrieving globally first, then removing results the user cannot see. When most top candidates come from content the filter removes, the visible result list empties out and the system generates an answer from nothing or hallucinates around the gap. Pre-filtering restricts each retrieval channel to the allowed subset up front, so ranking always operates on legitimate evidence.
How do I test for cross-tenant leakage?
Add permission-negative cases to your evaluation set: questions whose answers exist in the corpus but must return nothing (or an explicit denial) when asked under a principal lacking access. Run them continuously alongside quality metrics, and treat any retrieved-and-cited leak as a severity-one defect. Positive tests alone can never catch this class, because they only check that allowed content is found.
Do privacy rules really apply to chunk-level data?
Yes — chunks are personal data if their source documents are. Deletion requests must propagate to tombstones within your stated SLA; residency commitments constrain where indexes live; retention schedules apply to embeddings just as to documents. Because chunks are derived copies, teams routinely forget they multiplied the surface area of compliance obligations at ingestion time.

#rag #security #multi-tenancy #permissions #production

Put this corpus inside your own agents

This guide is free and stays free. The reference corpus behind it — machine-readable contracts, verified primary sources, continuously refreshed — is the paid product: a €5 starter key unlocks every premium reference for one agent via API; a €25 corpus license delivers the full corpus as RAG / fine-tuning data with an explicit AI-use grant; the €150 enterprise license adds commercial redistribution rights.

Agents: this page as Markdown · JSON · offers at /api/pricing.json · payment methods at /api/payment.json · single-resource access via HTTP 402 (how that works)