Skip to content

Interview question · LLM Application Security

How do you enforce tenant isolation and document-level permissions in RAG?

Similarity search has no idea who is asking. The answer that scores makes the index enforce the source system's rules, at query time and over time.

hardEssentialNewPreparation tags: Microsoft, Google, AmazonUpdated Nov 2026

TL;DR: Copy each document's tenant and access list into its chunks' metadata at ingestion, isolate tenants in the store itself (separate indexes or enforced namespaces), and filter every query by the asking user's tenant and principals inside the search, before ranking. Keep permissions and deletions in sync with the source with a known maximum lag, re-check against the source for sensitive results, scope caches by effective permissions, reauthorize or invalidate them after access changes, and test revocation and cross-tenant access continuously. The model never decides what the user may see.

How to approach it

Split the answer into tenant isolation (between customers) and document-level permissions (between users within a customer). Then cover time: permissions change. Interviewers want to hear that authorization is enforced in retrieval, in code, and that you know where it usually breaks.

A strong answer

FIG · RAG PERMISSIONS · FILTER BEFORE RANKING, NOT AFTER
Where the access check happens decides what leaks

Filter after search

Search all chunks

every tenant

Drop forbidden results

after ranking

Scores, counts, timing still leak

Outcome, unsafe: Leaks and misses

Top-k filled with forbidden docs

Filter inside the search

ACL in chunk metadata

copied at ingestion

Query scoped to user

tenant namespace enforced

Re-check source for sensitive hits

Outcome, safe: Only permitted chunks rank

Synced deletions, access-aware caches

Tenant isolation.

  • Strongest: a separate index per tenant, so a query physically cannot reach another tenant's vectors.
  • Common: a shared index with a tenant namespace enforced by the vector store's access controls or a mandatory filter applied in a single retrieval service that every caller must use.
  • Weak: tenant filter added in application code at each call site; one missed path exposes everyone.

Document-level permissions.

  • At ingestion, record the principals allowed to read each source document (users, groups, roles) on every chunk.
  • At query time, resolve the user's principals from the identity provider and pass them as a filter in the search, so ranking only considers allowed chunks.
  • For highly sensitive sources, re-check the final chunks against the source system's permission API before they enter the prompt (defence against stale metadata).

Time and change.

  • Subscribe to permission-change and deletion events from source systems, or re-sync on a schedule with a documented maximum lag.
  • Treat group membership changes too: removing a user from a group must remove their access.
  • Make deletion real: remove chunks, embeddings and cached answers.

Adjacent leaks.

  • Response and retrieval caches scoped to tenant and effective permissions, with a permission version or invalidation on ACL changes. Check current access to the cached source IDs before serving sensitive answers; a stable user ID does not capture a revoked document grant.
  • Conversation history scoped per user.
  • Logs that contain retrieved text treated as sensitive.

Tests. Automated checks that tenant A cannot retrieve tenant B's chunks, that a revoked user loses access within the agreed lag, and that deleted documents no longer appear.

What interviewers probe next

  • "Group lists are huge. How do you filter efficiently?" Index by group IDs and resolve the user's groups at query time; use the store's metadata filtering rather than post-filtering.
  • "The source system has complex inherited permissions." Compute effective permissions at ingestion, record their version, and re-check for sensitive sources at query time.
  • "Can the model be trusted to refuse restricted content?" No; if it is in the context it can be extracted. Restricted content must not be retrieved.

What if?

What if · interview follow-ups

Hold your answer as the constraints change

A multi-tenant SaaS adds a RAG assistant over customers' documents, which have per-document sharing settings.

  1. Start here

    Where must the permission check happen?

How it's scored

Weak: Puts permission rules in the system prompt or filters after generation.

Hire: Copies ACLs into metadata, filters by user before ranking and isolates tenants.

Strong Hire: Compares isolation strengths, handles change over time and deletion, re-checks sensitive results against the source, covers caches and history, and specifies tests.

Common mistakes

  • Post-filtering top-k results.
  • Syncing permissions only once at ingestion.
  • Shared caches across users.
  • Treating the index as less sensitive than the documents it was built from.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 10, and we keep track of how far you get in every topic.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in doubles your free answers, from 5 to 10 per topic, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

No comments yet. Share a correction or a different way to answer it.