An internal AI assistant that can search every SharePoint site, Confluence space and shared drive is useful right up to the moment it quotes a salary band or a client's deal terms to someone never meant to see them. Nothing was hacked. The retrieval layer simply did not know who was asking.
RAG access control closes that gap: the assistant answers only from documents the person asking could already open in the source system. One leaked answer can expose personal data or breach a confidentiality clause, and "the AI did it" will not satisfy a regulator or a client.
This article is for CIOs, CISOs and heads of AI opening an assistant to all staff, and the engineers building it. The decision is not whether to enforce permissions but where - in the prompt, the search or the source - and how long a revoked user may keep access.
We cover permission extraction, identity resolution, pre- versus post-filtering, revocation, audit and leakage testing. Real leaks come from small gaps, such as an inherited folder permission or a shared cache, so the detail matters.
A retrieval-augmented generation (RAG) system searches chunks, short passages stored as embeddings (numerical representations of meaning), and passes the best matches to a model. Once restricted text is in context, nothing reliably stops it being repeated, so the OWASP RAG Security Cheat Sheet requires access control before content reaches the model and calls missing chunk-level permissions the most common compliance failure in enterprise RAG.
Source systems hold access control lists (ACLs), the record of who may read an item, often inherited rather than set on it. In SharePoint, permissions flow from site to library to folder to file unless inheritance is broken, so a connector computes the effective ACL per file, as Microsoft's
SharePoint indexer documentation describes. The same page admits its preview ignores organisation-wide sharing links and guest users; exclude whatever a connector cannot represent rather than guess.
Copy the effective ACL onto every chunk, since search filters chunks, not files. Store readers as immutable directory IDs such as Entra object IDs, never emails, plus document ID, client boundary, sensitivity label and when the ACL was last confirmed. Prefer groups to individual grants: the
Azure AI Search query-time enforcement guide caps SharePoint content at 1,000 permission entries per file, beyond which entries may not be enforced. Index a stricter section, such as an HR appendix, as its own document.
Resolving identity and group membership at query time Validate the sign-in token on the server, take its immutable user ID and resolve groups in the backend, transitively, so nested groups count. Never accept a group list from the browser or a model's tool call. Azure AI Search's native enforcement expands Entra membership through Microsoft Graph at query time, but not an Entra group nested inside a SharePoint site group, so those users silently lose results. Map these before launch.
A retrieval service or agent tool must act for the user, not under an all-powerful service account. In Azure's model a document needs both the application's role and the user's token; with no token only public documents return. Until November 2025, previews returned everything to a caller with a service key and no user token: test what your stack does when identity is missing.
Pre-filter vs post-filter retrieval: where the check runs Pre-Filter vs Post-Filter Retrieval in RAG Where the check runs decides what users can infer about hidden documents, and how good answers stay.
Pre-filtering inside the vector query: the user's groups join the search predicate, so restricted chunks never become candidates and every result is already permitted; OWASP rates this more secure because their similarity scores are never observed. But a query filter is not always applied during the index walk: the
pgvector documentation notes that approximate indexes filter after scanning, so if a condition matches 10% of rows a default HNSW search returns about 4 matches. Measure recall for narrow-access users; this stays the default control.
Post-filtering after retrieval: search everything, then drop what the user cannot read. Easy to add, it may leave too few results, its counts and scores can hint at restricted material, and unfiltered text has already passed through logs. Use it as an extra check only.
Separate indexes for hard boundaries: for clients or subsidiaries behind an information barrier, OWASP recommends separate namespaces or indexes, so a filter bug leaks within one boundary, not across all. It suits a few coarse lines only.
Live checks against the source: before the final five or so passages reach the model, ask the source whether the user can still open each. It catches changes since the last sync, at a latency cost. Reserve it for collections where a stale permission would be an incident.
Caches are the side door: one keyed on question text serves one person's answer to another, so OWASP says to scope them by user, tenant and permission, invalidate on permission changes and never cache highly sensitive data; summaries and chat history need the same care.
Revocation, failing closed and audit Sync needs incremental updates from change feeds plus a scheduled full reconciliation. Microsoft's SharePoint indexer catches item-level permission changes through change tokens, but a parent site or folder change needs an explicit resync. Update metadata without re-embedding, and reconcile with the discipline of
ETL migration testing . OWASP requires deletions to cascade to caches and derived indexes. Agree a staleness window per collection and monitor it.
Fail closed: a failed access check returns nothing, not a filtered subset, and Azure AI Search returns an error rather than partial results. Log each request's correlation ID, user ID, group set, chunk IDs returned or dropped and decision, but not raw text by default. Rule 6 of India's
Digital Personal Data Protection Rules, 2025 , effective eighteen months after their November 2025 publication, lists access controls, access logs with monitoring and one-year log retention among minimum safeguards.
A practical workflow for RAG access control Three stages, each signed off before the next.
Step 1: Map the sources and agree the targets List every source and how it decides who reads what: inheritance, sharing links, guests, deny rules and group types. Mark anything your connector cannot represent and decide whether to exclude it. Confirm the assistant uses the identity provider behind the documents, so chunk IDs match user IDs. Then agree three targets with security, compliance and business owners: the staleness window for revocations, which collections need a hard index boundary, and which need a live check. This map becomes the pipeline's specification and the test plan's starting point.
Step 2: Build the pipeline and prove there is no leakage Build a least-privilege connector per source, a permission store keyed by document ID, chunking that copies effective ACLs onto every chunk, filterable permission fields, group resolution with a short cache, and a retrieval API that builds the filter server-side and is the only path to the index. Ship permission sync with content sync. Then test on retrieved chunk IDs, not answers, which vary between runs: plant canary documents, fake files holding a unique marker, in each restricted area, create a test user per persona, and run in CI:
Ask each user direct and indirect questions aimed at the canaries, such as requests to summarise or translate. Check every returned chunk against the source system's own permission check. Revoke a membership and confirm content disappears within the staleness window. Ask one question as an authorised then an unauthorised user, and delete a canary, to test cache isolation and deletion. Call with no identity, then with a forged group list; nothing restricted may return.
Step 3: Roll out in rings, monitor and keep a rollback Launch to a pilot group on low-sensitivity collections, then add sensitive ones one at a time, each behind its tests. Monitor sync lag, chunks dropped by post-filters or live checks (a rising rate means sync is missing changes), recall for narrow personas, and users suddenly querying collections they never touch, which OWASP flags as probing. Review the permission map whenever a new source or group type appears. Keep a kill switch per collection, so a suspected leak means withdrawing one collection, not the whole assistant, while the index is corrected.
Two composite scenarios show the trade-offs.
A general insurer opening an HR and policy assistant Illustrative example: a general insurer in Mumbai with around 3,000 staff wants an assistant over HR policies, underwriting manuals and claims procedures in SharePoint. The pilot exposed the problem: the prototype indexed everything under one service account, so any employee could retrieve manager-only compensation guidelines. Constraints: several HR sites had broken inheritance at folder level, some access ran through SharePoint site groups containing Entra groups, and HR wanted revocations applied within the hour.
The team weighed a system prompt forbidding disclosure, post-filtering the top results, and native ACL ingestion with query-time enforcement. The prompt cannot remove text already in context, and post-filtering would give narrow-access staff thin answers. They chose native ingestion with pre-filtering, because it computes effective permissions per file and expands nested Entra groups at query time.
Implementation started with the permission map: users moved out of SharePoint groups containing Entra groups, compensation appendices became separate documents, hourly incremental sync was paired with a nightly permission resync for parent-folder changes, and canaries went into each HR library.
The expected outcome is full answers for frontline staff, compensation guidance only for managers, and an auditable record of what each person retrieved. The limitation is the nightly resync: a folder-level change can stay stale for a day, so HR makes sensitive changes at file level or triggers a manual resync. The lesson: most of the work sat in the permission map, not the model.
A wealth manager with deal rooms and conflicts Illustrative example: a wealth and advisory firm in Bengaluru wants analysts to query research notes in Confluence and client deal documents in shared drives. The problem is information barriers: when a conflict is declared, an analyst must lose access to a deal room at once, and compliance must be able to prove it. Constraints included two permission models, change feeds that did not report every group membership change, and API rate limits on the document store.
Options were frequent sync alone, which left too wide a window, and live checks on every candidate, which would breach rate limits. The firm chose a combination: research notes in a shared, pre-filtered index; each active mandate in its own index; and a live check on only the final five documents from a deal index, failing closed if the source does not answer.
Implementation added nightly reconciliation of stored against source readers on a sample, no caching for deal indexes, retrieval logs kept for one year with IDs and decisions but no content, and a "conflicted analyst" persona revoked mid-test in the leakage suite.
The expected outcome: a revoked analyst stops receiving deal content on the next question, and compliance can reconstruct who saw what. Limitations are added latency on deal queries, hypothetically a second or two, and refusals whenever the document store is down. The lesson: hard boundaries plus a narrow live check beat any sync frequency.
Common mistakes in RAG access control Treating the system prompt as a control. "Do not reveal confidential data" passes demos, but the model can still paraphrase restricted text already in context. Keep restricted chunks out of context.
Copying direct permissions instead of effective ones. Hurried connectors read file-level permissions and miss inheritance, exposing files by accident. Compute effective ACLs and compare a sample with the source.
Syncing content but not permissions. Parent-scope changes are assumed to flow through incremental runs, so revoked users keep retrieving for days. Add full reconciliation and alert on drift.
Leaving a fail-open path. An admin console, evaluation script or timeout fallback that skips the identity filter becomes the real policy. Route every query through one service that returns nothing when identity is missing.
Frequently asked questions Common questions from buyers and engineers.
What is permission-aware RAG? It is RAG access control applied end to end: it retrieves only content the asking user could open in the source, by carrying permissions onto every chunk and filtering each search by verified identity. Unlike broad role filters, it mirrors per-document permissions, inheritance and nested groups. The model never sees what the user cannot access, so it cannot reveal it.
Do vector databases support access control natively? Most support metadata filters and namespaces, but cannot know who is asking unless your application passes resolved groups. Some managed search services now validate a user token and resolve groups themselves. Either way, check whether filtering happens during or after the approximate index walk, which decides whether narrow-access users get full results.
How often should RAG permissions be synced? Set it from the staleness window the business agrees, not the connector default. Hourly incremental sync with nightly full reconciliation suits most internal content. Deal rooms and HR investigations need a live source check at question time, and removals should always be applied before additions, because a late removal is the only kind that leaks.
Does the DPDP Act apply to internal AI assistants? Where an assistant processes digital personal data of employees or customers, the organisation's data fiduciary obligations apply as for any system. The 2025 Rules name access controls, monitored access logs and one-year log retention among minimum safeguards. Permission-aware retrieval and structured logs demonstrate them, and cost far less to design in than to retrofit.
Design access in from the first index RAG access control works when permissions travel with the data: effective ACLs on every chunk, checked against a server-verified identity inside the search. The decision framework: pre-filter everything by default, add separate indexes only for a few hard boundaries such as clients or legal entities, add live source checks only where a stale permission would be an incident, and make every failure return nothing.
Havoc LLP builds retrieval pipelines that carry source permissions into the index, filter every query by verified identity, and ship with leakage tests and audit logging. Read about our LLM and RAG services , or talk to our engineering team .