Home / Insights / Generative AI and LLMs
Generative AI and LLMs
Permission-Aware Enterprise Search: Keeping RAG Answers Inside Each User’s Access Rights
An AI assistant that answers from company documents is only safe if it answers each person from the documents that person may open. This guide explains how to design, build and test that boundary.
Key takeaways
- A RAG assistant inherits every permission mistake in its index: if a restricted chunk is retrieved, the model will summarise it.
- Enforce access at retrieval time, on the server, on every query, with deny-by-default behaviour. Prompt instructions are not an access control.
- Mirror source-system permissions as stable group or principal IDs on every chunk, and treat permission sync lag as a measurable risk with a target.
- Most leaks come from the edges: summaries and caches shared across users, aggregations, connectors with admin-level service accounts, and stale groups.
- Test leakage explicitly with persona-based test users and a red-team question set before launch, and re-run those tests whenever connectors or group mappings change.
On this page
- Why RAG assistants leak information in the first place
- What are the main architectural options?
- How do you decide which model fits your organisation?
- How do you implement a permission-aware pipeline?
- Which edge cases cause most real-world leaks?
- How do you test that answers stay inside access rights?
- What does it cost, and what should be on your launch checklist?
- Frequently asked questions
- Sources and methodology
Most enterprise search pilots aim to let staff ask questions in plain language and get sourced answers instead of hunting through SharePoint, Drive and Confluence. Retrieval-augmented generation (RAG) makes that quick to achieve. The uncomfortable discovery comes later, when someone asks about bonuses and the assistant quotes a document only HR was meant to see.
This is not a model problem. The model does not know who is asking; it summarises whatever retrieval hands it. Permission-aware search is therefore an engineering and governance problem that sits squarely in the retrieval layer.
This article is for CTOs, heads of IT and product leads who are planning or already running an internal knowledge assistant. It covers where leaks happen, the architectural options, how to choose, how to implement and test the permission pipeline, and what it costs. If you are still deciding whether to use RAG at all, start with our comparison of RAG and fine-tuning.
Why RAG assistants leak information in the first place
A conventional document management system checks permissions when a user opens a file. A RAG system changes the access pattern: content is copied out of its source system, split into chunks, converted to embeddings and stored in a search index. At question time, the system retrieves the most relevant chunks and passes them to a model, which writes a new piece of text. The source system’s permission check never runs.
Every access rule you rely on today therefore has to be copied faithfully into the search pipeline, or the assistant becomes a convenient way around your controls. The OWASP Top 10 for Large Language Model Applications lists sensitive information disclosure (LLM06) as one of the ten main risks for LLM applications, and an over-broad retrieval index is one of the most common ways it happens in practice.
The four places permissions get lost
- Ingestion. Connectors often run under a service account with broad read access. If they copy content without also copying its access control list (ACL), the index has the data but not the rules.
- Chunking and enrichment. When a document is split, each chunk must carry the parent document’s permissions. Generated artefacts such as summaries, extracted entities or “document cards” must carry them too, and this is frequently forgotten.
- Retrieval. If the query is not filtered by the caller’s identity, nearest-neighbour search simply returns the closest vectors, regardless of who owns them.
- Answer and cache layers. Semantic caches, conversation memory and pre-computed FAQ answers can serve one user’s answer to another user who asked a similar question.
Why “tell the model not to reveal it” does not work
Some teams retrieve everything and instruct the model to ignore documents the user should not see. This is not access control: the restricted text has already reached the model, the instruction can be overridden by a crafted question or prompt injection, and you cannot prove to an auditor that it holds. The rule we apply on every project is simple: content a user may not read must never be placed in that user’s prompt.
What are the main architectural options?
There are three broad ways to keep answers within access rights. They differ in where the permission check happens and how fresh it is.
Option 1: Separate indexes per audience
One index per security domain, such as “all staff”, “HR” and “finance”, with each user routed to the indexes they are entitled to. Simple and hard to get wrong at query time, but it breaks down when permissions are granular, as in most SharePoint or Google Drive estates.
Option 2: Early binding with query-time filters
Each chunk is stored with a list of the principals (users and groups) allowed to read it. At query time the application resolves the caller’s identity and group memberships and adds a filter so that only matching chunks are eligible. This is the pattern most search engines document. Microsoft’s guidance for Azure AI Search, for example, describes indexing a filterable group_ids field and applying a search.in filter on every query, and is explicit that the principal is “just a string”: the search service does not authenticate anyone, so the application must resolve identity and build the filter correctly. Elasticsearch offers a similar capability as document level security, where a role carries a query, optionally templated with user attributes, that restricts which documents that role can read.
Option 3: Late binding with a live permission check
Retrieval runs over a broader candidate set, then each candidate is checked against the source system or a central authorisation service before reaching the model. Permissions are fully fresh, at the cost of latency, source API rate limits and the risk that heavy filtering leaves too few results.
Comparison
| Criterion | Separate indexes | Early binding (filter) | Late binding (live check) |
|---|---|---|---|
| Granularity | Coarse (per audience) | Fine (per document or chunk) | Fine, matches source exactly |
| Freshness of permissions | As fresh as the index build | As fresh as the last ACL sync | Real time |
| Query latency | Low | Low to moderate (large group lists cost more) | Higher, depends on source APIs |
| Implementation effort | Low | Moderate (ACL extraction and sync) | High (per-source checks, rate limits) |
| Main failure mode | Wrong document in wrong index | Stale or missing ACLs | Too few results after filtering; source outages |
| Best fit | Few, clear audiences | Most internal assistants | Highly sensitive, fast-changing content |
In practice most production systems we design use early binding as the main mechanism, with a late-binding re-check reserved for the small number of collections where sensitivity and change frequency justify the cost, such as HR case files or legal matters.
How do you decide which model fits your organisation?
The choice depends mostly on how your organisation already manages access. Four questions settle most decisions.
1. How are permissions expressed today?
If access is mostly granted through identity-provider groups (Microsoft Entra ID or Google Workspace, for example), early binding works well. If it is mostly ad hoc sharing with individuals, ACLs become long and volatile, so expect more sync work or consider late binding for those sources.
2. How quickly must revocation take effect?
Ask each content owner: “If someone is removed from this folder, how long can the assistant keep answering them from it?” A day may suit a policy library; an M&A data room needs minutes or less. That number is your permission freshness target.
3. What is the blast radius of a leak?
A leaked lunch menu is harmless; a leaked salary review or patient note is a reportable incident. High-impact sources justify stricter mechanisms or exclusion from the first release.
4. Which sources can expose their ACLs?
Some connectors expose full ACLs; others only show what the service account can see. A source without trustworthy permission data should get a dedicated audience index or stay out.
For example, a 300-person professional services firm might put its intranet and policy library into an all-staff collection, index project folders with group-based ACLs, and leave HR case files out of phase one entirely. That is an illustrative pattern, not a rule, but it shows how the decision is made source by source rather than once for the whole estate.
How do you implement a permission-aware pipeline?
Each of the five parts is ordinary engineering; the risk comes from skipping one.
Step 1: Build a permission model, not just a connector
Define a canonical representation of who may read what, independent of any single source. At minimum, each indexed item needs: a stable document ID, the source system, a list of allowed principals (user and group IDs from your identity provider), optional deny entries, a sensitivity label, and the timestamp of the last ACL sync. Use stable identifiers such as directory object IDs rather than display names or email addresses, which change. Our guide to designing roles and permissions for enterprise software covers the wider RBAC and attribute model this sits inside.
Step 2: Propagate permissions to every derived artefact
Every chunk inherits its parent document’s ACL. Every generated artefact (summaries, extracted tables, question-answer pairs) inherits the most restrictive ACL of the documents it was built from. Enrichment jobs written before anyone thought about access frequently break this rule.
Step 3: Enforce on the server, on every query, deny by default
The OWASP Authorization Cheat Sheet recommends denying by default and validating permissions on every request through application-wide mechanisms rather than scattered checks. In a RAG system, that means a single retrieval service that:
- authenticates the caller from a verified token, never from a user ID passed in the request body;
- resolves the caller’s groups (cached for a short, defined period);
- adds the permission filter to every search call, including keyword, vector and hybrid queries and any re-ranking candidate fetch;
- returns nothing if the identity or group resolution fails, rather than falling back to an unfiltered query.
No other component, including the chat front end or an agent framework, should be able to call the index directly.
Step 4: Keep permissions in sync
Run permission sync as its own job, separate from content re-indexing, so a revoked share can be applied without re-embedding. Microsoft’s guidance notes that Azure AI Search provides no feature for populating the security field and that keeping it in sync with the source is your responsibility. Track sync lag per source as a metric and alert when it exceeds the freshness target agreed in the previous section.
Step 5: Make the answer layer identity-aware
- Scope semantic caches and pre-computed answers by permission set, or do not share them across users.
- Keep conversation history strictly per user.
- Link citations to the source system, so access is re-checked on click-through.
- When nothing permitted is found, say so rather than implying a document exists.
Our checklist on preparing company documents for AI knowledge search covers connectors and freshness in more depth.
Which edge cases cause most real-world leaks?
With query-time filtering in place, the remaining risk sits in less obvious places worth listing in your design review.
Side channels in the search engine
Other features may still reveal information. Elastic’s documentation notes that, under document level security, aggregations can still reveal field names and term counts that exist only in restricted documents, and that relevance scoring statistics are not calculated from the restricted set alone. Check whether facets, autocomplete and result counts are computed after the permission filter.
Multiple roles combining unexpectedly
In Elasticsearch, a user’s document level security queries from several roles are combined with OR, so one unrestricted role removes the restriction. Check your engine’s equivalent rule before assigning roles.
Service accounts and agents
If the assistant can call tools, such as searching a ticket system or reading a mailbox through an API, those tools must act with the end user’s delegated permissions, not with a powerful service account. OWASP lists excessive agency (LLM08) alongside sensitive information disclosure for exactly this reason. We cover the approval side of this in AI agent permissions and approvals.
Documents that should never have been shared
RAG exposes existing over-sharing. A salary spreadsheet shared with “Everyone” years ago stayed hidden because nobody knew where to look; an assistant finds it in seconds. Scan broadly shared content before launch and fix source permissions rather than adding index exceptions.
How do you test that answers stay inside access rights?
Permission bugs are silent, so you need tests that actively look for leaks. The OWASP Authorization Cheat Sheet recommends unit and integration tests that confirm deny-by-default behaviour and correct policy enforcement, while noting they do not replace dedicated security testing. For RAG, we add three layers.
Persona-based test users
Create test identities mirroring real roles (new starter, team lead, HR partner, contractor). Seed “canary” documents with distinctive phrases, each restricted to one persona, run the same questions as every persona, and assert each phrase appears only for its permitted persona.
A leakage question set
Alongside your normal quality test set (see building a test set for enterprise knowledge search), maintain direct, indirect and prompt-injection questions designed to pull restricted content. Unauthorised personas should get a clear “nothing you have access to” response.
Revocation tests
Grant a test user access, confirm the assistant answers from the document, revoke access at source, and measure how long until it stops. Report this alongside latency and quality.
What to measure
| Metric | What it tells you | Suggested target |
|---|---|---|
| Canary leakage rate | Restricted content appearing for the wrong persona | Zero, as a release blocker |
| Revocation lag (p95) | Time from revoke in source to no longer retrievable | Agreed per source in the design phase |
| Unfiltered query count | Search calls made without a permission filter | Zero, enforced in code and monitored in logs |
Re-run the suite whenever connectors, group mappings, chunking or the search engine change.
What does it cost, and what should be on your launch checklist?
Permission awareness is far cheaper to design in than to retrofit after an incident.
Where the extra effort goes
- Connector work. Extracting and normalising ACLs per source is usually the largest item.
- Sync infrastructure. A separate permission sync job with lag monitoring.
- Query cost. Users in many groups produce large filters (Microsoft recommends
search.infor this); test latency with realistic group counts. - Testing. Persona users, canaries and leakage questions, maintained like any test suite.
- Governance. Content owners must agree freshness targets and clean up over-shared content; this people time is often the critical path.
Launch checklist
- Every content source has an owner, a sensitivity classification and an agreed permission freshness target.
- Every indexed chunk and derived artefact carries an ACL and a last-synced timestamp; items without one are rejected.
- A single server-side retrieval service applies the permission filter to every query and fails closed.
- Caches, conversation memory and pre-computed answers are scoped per user or per permission set.
- Tools and connectors used by the assistant act with delegated user permissions, not broad service accounts.
- Facets, counts and autocomplete are checked for side-channel leakage.
- Persona tests, canary documents and the leakage question set pass with zero leaks.
- Revocation lag has been measured per source and meets the agreed target.
- Logs record who asked what and which documents were retrieved, with retention agreed with your privacy lead.
At PoliteTech we build enterprise knowledge search with permission-aware retrieval that filters by user, group or document label at query time, together with evaluation runs that check retrieval and answer quality. Our work on platforms for Australian healthcare and care providers involves information where access boundaries matter, and this checklist reflects that experience.
Frequently asked questions
Can we just give the assistant read access to everything and rely on the model to be discreet?
No. Once restricted text reaches the prompt it can appear in an answer, either by mistake or through a crafted question or prompt injection. Access control has to happen before retrieval results reach the model, on the server, for every query.
Does permission filtering make answers worse?
Sometimes, because restricted content is correctly excluded. Investigate cases where permitted content was missed, but treat exclusion of restricted content as the system working.
How fresh do permissions need to be?
It depends on the source. Agree a target with each content owner, for example within a day for a policy library and within minutes for HR or legal material, then measure revocation lag against it. Sources that cannot meet their target should fail closed or stay out of the index.
Which search technologies support permission-aware retrieval?
Most mainstream search engines and vector databases support filtering on a security field, and some, such as Elasticsearch, offer built-in document-level security. The engine matters less than the ACL extraction, sync and testing around it; our vector database comparison covers engine choice in more detail.
Who should own permission decisions for the assistant?
The owners of the source systems. The assistant should mirror existing access rather than create a separate permission model. Engineering owns the mechanism and tests; content owners own who may see what.
Sources and methodology
Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.
- Microsoft Learn: Security filters for trimming results in Azure AI Search — accessed 9 November 2026. The group-ID filter pattern, search.in recommendation, and the point that the service neither authenticates principals nor populates or syncs the security field.
- Elastic: Document level security (Elasticsearch reference) — accessed 9 November 2026. Role-based and templated document filtering, OR-combination of multiple roles, and side channels such as aggregations and scoring statistics.
- OWASP Cheat Sheet Series: Authorization Cheat Sheet — accessed 9 November 2026. Deny by default, validate permissions on every request, least privilege, and testing authorisation logic.
- OWASP Top 10 for Large Language Model Applications (v1.1) — accessed 9 November 2026. Sensitive information disclosure (LLM06) and excessive agency (LLM08) as recognised LLM application risks.
Related reading
Continue your research
Is your knowledge assistant answering only from what each user may open?
We can review your connectors, permission model and leakage tests, or design a permission-aware search pipeline from the start.
