RAG

Permission-aware RAG explained: how access control works in retrieval (2026)

Permission-aware RAG returns only what the person asking may open. How it works, how to test it, and how PipesHub does it.

Permission-aware RAG returns only what the person asking may open. How it works, how to test it, and how PipesHub does it.

Shekhar Kadyan

Co-founder

Permission-aware RAG is retrieval-augmented generation (a language model answering from passages that a search step fetches) where the search returns only what the person asking is allowed to open in the source app. For most teams, the simplest way to get it right is a platform built for it, such as PipesHub, which checks each source's own permissions for the named person on every query, treats agents as named users, fails closed, and cites the exact block behind every answer.


PipesHub publishes this article, and we use PipesHub as the worked example of permission-aware retrieval done well. Every outside page cited was checked on 20 Nov 2026.


Key takeaways

  • The filter should run before or during the search, so restricted text never leaves the index.

  • The hard part in a company is copying access rules from many apps that each define access differently.

  • Groups and identity matching cause many real failures, especially nested groups and email addresses that do not match.

  • Every system that copies permissions lags behind changes at the source, so measure that delay yourself.

  • A safe system fails closed, returning nothing when it cannot check access, and runs every question as a named user, never as a shared service account.

  • PipesHub follows this pattern, with per-person checks at query time, agents as named users, a 503 error when the check cannot run, and block-level citations.


What permission-aware RAG is, and what it is not


A plain RAG pipeline splits documents into passages, stores them in a search index, and hands the best matches to a language model. If the index holds the whole company's documents, that pipeline can quote a salary review to an intern. The OWASP Top 10 for LLM applications recommends "permission-aware vector and embedding stores", which are the databases that hold text in searchable form, as a defence (OWASP LLM08:2025).


Permission-aware RAG adds three things. It stores an access control list (ACL), which is the list of users and groups allowed to open an item, with every passage. It knows who is asking, and it checks that person against the list on every query. It is not a prompt that tells the model to keep secrets, because a model that holds restricted text can be talked into repeating it.


In PipesHub, the caller's own token decides whose permissions apply, and the Retrieval API filters passages exactly as PipesHub search does.


Diagram: access rules are copied from source apps into the index, a named user asks, the search is filtered to that user, and the model answers from allowed text.

The filter runs before any text reaches the language model, and returns nothing when the check cannot run. PipesHub follows this pattern.


Four places to enforce access


The access check can run at four points in a query.


Where the check runs

How it works

Strength

Weak point

Before the search

The system lists everything the user may open, then searches only those items.

Every result is allowed.

The list is very large for people with broad access.

During the search

Each passage carries its allowed users and groups, and the index filters on them.

It is fast and returns full results.

The stored rules are a copy, so they can be out of date.

After the search

The system searches everything, then drops what the user may not open.

It is easy to add to an existing pipeline.

Results can come up short, and restricted text has already left the index.

At the source, at question time

The system asks the source app whether this user can open each candidate.

It reflects the source's current rules.

It adds a call per candidate and needs the source to be reachable.


Filtering before or during the search is pre-filtering, and filtering afterwards is post-filtering. The OpenFGA documentation notes that post-filtering "may return fewer than K after filtering", where K is the number of results requested (OpenFGA). The restricted passages have also already been fetched, so one bug in application code can expose them.


Two products show the range. Microsoft's Foundry IQ (Azure AI Search) stores permission metadata with each indexed document, and compares it during the query with the user's sign-in token, which proves who the user is (Microsoft Learn). Amazon Bedrock Managed Knowledge Base filters on the SharePoint ACLs synced at the last crawl, then verifies each candidate against SharePoint at query time (AWS).


Copying access rules from the source apps


A company has to copy rules from apps that each define access differently.


App

What decides who can read

What a copy must get right

Confluence

Space permissions grant access, and page restrictions narrow it.

A view restriction on a parent page is inherited by the pages under it.

Jira

Space permissions grant access (Jira Cloud now calls projects spaces), and security schemes can hide single work items.

A person can open a space and still be barred from some work items in it.

Slack

Members can open any public channel, and only its members can open a private one.

Private channel messages appear in search only for people in the channel, and guests cannot open every public channel.

Google Drive

Each file or folder is shared with people or groups, or opened by link.

Link sharing, group sharing and sharing inherited from a folder must be copied as well as named people.

SharePoint

Permissions pass down from site to library to folder to item.

Any level can break inheritance and hold its own rules.


These rows come from each vendor's help pages, listed under Sources. A connector, which is the component that syncs one app into the index, has to copy the structure as well as the names. If it reads only space-level permissions in Confluence, every restricted page becomes visible to the whole space. It also has to notice when a rule changes on a document whose text has not changed. PipesHub checks access against each source's own permissions for exactly this reason.


Identity and groups: where many failures start


The index has to recognise the person asking as the same person in every source. Many systems match on email address, and that match can break, because people have aliases and some apps let users hide their email. Ask each vendor what happens when the email does not match.


Nested groups, which are groups that contain other groups, are the second trap. If a folder is shared with "Engineering" and "Platform team" is a member of that group, a system that reads only direct members will hide the folder from the platform team. Foundry IQ resolves nested groups for SharePoint up to five levels and denies access when the only path is deeper (Microsoft Learn). AWS says its SharePoint crawl resolves nested group memberships (AWS).


How a removed permission takes effect


This is the weak point of every system that copies permissions, because a change at the source has to be detected, processed and written to the index before queries respect it. A Microsoft engineering post about copying SharePoint permissions into a search index notes that a user whose access is revoked "may still see the document's content in the search index or RAG pipeline until the next ingestion run" (Microsoft, 30 Apr 2026).


The Foundry IQ documentation adds that permission refresh "doesn't provide immediate revocation" (Microsoft Learn).


A live check at the source narrows the gap without closing it. AWS says its query-time SharePoint check reflects a recent access change after a delay, "typically within about two minutes" (AWS).


Ask a vendor about three changes separately: a document being unshared, a person leaving a group, and an account being deactivated. Ask also whether answers are cached, meaning stored and reused, because a cached answer can outlive the permission behind it.


Failing closed


Failing closed means that when the system cannot check access, it shows nothing. A system that fails open returns unfiltered results when its permission service is down, which turns an outage into a data leak.


Our Retrieval API fails closed. It returns a 503 error, which means the service is unavailable, when the permission check cannot run, rather than returning unfiltered passages. AWS documents the same principle: when its SharePoint access check is misconfigured, retrieval "fails closed: affected documents are silently omitted" (AWS).


The rule also applies during sync, where a failed read of a document's permissions must never widen access. In PipesHub's Confluence connector, a failed read never opens a page to its whole space and never removes access (our Confluence guide).


Service accounts versus acting as the user


The crawler that copies content needs wide read access, usually through a service account, which is a non-human account owned by the organisation. It should still be limited to the sites and spaces being indexed.


The query must run as the named person asking. If a chatbot or agent searches through a shared account, everyone inherits that account's view. In PipesHub, agents connect as a named user, not as a shared service account, so an agent sees only what its user can see. WorkOS, quoting Databricks' guidance, advises that an app with no user token should refuse the request and never fall back to its own service identity (WorkOS, 12 Oct 2026).


The identity must also come from a verified sign-in, not from a field the calling app can fill in. AWS says its SharePoint filter does not authenticate end users, so the application must do that first (AWS).


How to test for leaks with two test users


The test needs two ordinary accounts. User A has access to the restricted places, and user B is the control who does not. Each planted document contains a made-up phrase that appears nowhere else. Glean recommends a similar two-user pattern (Glean, updated 26 Oct 2026).

  1. Plant a document in a restricted page, a private channel and an unshared file. As B, ask for the phrase. B must get no answer, title, snippet or citation.

  2. Share a document with a group that contains A. A must find it and B must not.

  3. Remove A from that group and add A to a group nested inside it. A must still find it.

  4. Put a page under a restricted parent page that A can open. A must find it and B must not.

  5. Remove A's access, note the time, and ask again at intervals until the document disappears. That gap is your revocation delay.

  6. Repeat step 5 by removing A from a group, and again by deactivating A's account.

  7. As B, ask indirectly for a summary of the topic or a list of documents that mention it. B must learn nothing from the planted documents.

  8. Have A ask a question, then have B ask the same one. B must not receive a cached answer.

  9. Repeat the checks through the chat screen, the API, bots and agent connections.

  10. In a test environment, break the connector's credentials or the permission check. Queries must return nothing or an error.


Run the list again after every connector upgrade. Because every PipesHub answer cites the exact block it came from, a leaked phrase is easy to spot.


Where PipesHub fits


PipesHub does permission-aware retrieval for you. Access is checked when the query runs, against each source's own permissions, for the specific person asking, across 50+ connectors, including Slack, Google Drive, Jira, Confluence, SharePoint and GitHub. If the permission check cannot run, the Retrieval API fails closed.


Agents connect as a named user, not as a shared service account. They use a remote MCP server (MCP is the Model Context Protocol, a standard way for agents to reach tools), the Retrieval API, or SDKs. Answers cite the exact block of the source document. PipesHub ranked #1 on the public EnterpriseRAG-Bench leaderboard (Hugging Face) as of 14 Nov 2026, with 93.24 overall (95.0% answer correctness) among 43 entries (leaderboard). Onyx runs that leaderboard.


PipesHub comes in three editions: the Community edition, open source under Apache 2.0 and free to self-host; Pro on PipesHub Cloud at $20 per user per month, billed yearly; and the Enterprise edition, under our Enterprise licence, which runs in your own cloud, your virtual private cloud (VPC) or fully offline (PipesHub pricing).


Permission-aware answers are in Pro and Enterprise. The Enterprise edition also adds single sign-on, SCIM, audit logs and real-time sync for some connectors. A team building one application with its own permission model may be better served by an authorisation service such as OpenFGA with a vector database.


To get started, sign up for PipesHub Cloud, where every new workspace starts with a 14-day Pro trial. To run PipesHub on your own servers with permission-aware answers, choose the Enterprise edition (pricing). Our docs cover connectors, the Retrieval API and the MCP server.


Watch: how permission-aware RAG keeps every AI answer inside what the person asking may open (4 minutes 54 seconds).


FAQ


What is permission-aware RAG?


It is retrieval-augmented generation that retrieves only documents the person asking may open in the source app. It applies each source's access rules to every query, as PipesHub does when each query runs.


Is it better to filter before or after retrieval?


Filtering before or during the search is safer, because restricted text never leaves the index. Filtering afterwards can return too few results, so it works best as a second check.


Can I tell the model not to reveal restricted content?


A prompt instruction is not an access control, because a model that holds restricted text can be led into repeating it. Keep that text out of the model's input instead.


How quickly does a removed permission take effect?


It depends on the product and the type of change. Systems that copy permissions apply a removal only after they detect and process it, so ask each vendor how that works and measure the delay with a test user.


Should an AI agent use a service account to search company documents?


An agent should search as the person it is working for, using that person's own sign-in. A shared service account gives every user the same view, which removes the permission filter in practice. This is why PipesHub agents connect as a named user.


Related reading


Sources

No headings found on page

Check out more blogs