azyware
Technology

Permission-aware retrieval: keeping AI answers inside access rights

EZ
Eazyware
· 7 min read
Quick answer

What should you know about permission-aware RAG, and how do you keep AI answers inside a user's access rights?

Permission-aware retrieval enforces document ACLs at query time so users only receive content they are allowed to see. The entitlement check runs in the retrieval layer before ranking, never in the prompt, and is proven with negative tests where a named user must not receive a named document.

Permission aware RAG means the retrieval system knows who is asking and filters the index by what that person is entitled to see before any passage reaches the model. Without it, an internal assistant becomes the most efficient data leak an organisation has ever deployed: a junior analyst asks about executive compensation, the vector index has the board pack, and the model summarises it helpfully. This article explains where permissions must be enforced, how to model access rights across sources that each have their own, how to keep the entitlements current, and how to prove the system is safe before anyone uses it.

Why RAG access control fails by default

A basic RAG pipeline ingests documents from wherever it is pointed, stores chunks in an index, and retrieves by similarity. The index has no idea that one document came from a shared drive open to everyone and another from a folder restricted to HR. When the model receives the retrieved passages, it does what it is asked and answers. Adding "do not reveal confidential information" to the prompt is not a control: the model has already been given the text, and prompts are not access-control mechanisms. The check has to happen before retrieval returns anything, in code, against the user's identity.

Where the enforcement point sits

Enforcement pointHow it worksVerdict
In the promptInstruct the model not to reveal restricted contentNot a control. The content has already been retrieved
After generationScan the answer for restricted content before showing itSecond line of defence at best; leaks through paraphrase
After retrieval, before generationDrop retrieved chunks the user cannot seeAcceptable, but the top-k is polluted and recall suffers
At query time, before rankingFilter the index by the user's entitlements, then rankCorrect. Restricted content never enters the candidate set
Separate index per audienceOne index per permission groupWorks for a few coarse groups; unmanageable beyond that

Document level security AI: modelling the entitlements

Carry the ACL with every chunk

Every chunk stores the identifiers of who may see it: users, groups, roles, tenants, or a document-level security label. At query time the user's identity resolves to a set of those identifiers, and the retrieval query includes a filter that the chunk's ACL must intersect that set. Vector and keyword stores both support metadata filtering that runs before or alongside ranking; the vector database comparison covers which handle large filter sets efficiently. In Postgres, row-level security can enforce the same rule at the database layer, so even a bug in the application cannot bypass it.

Normalise permissions across sources

Google Drive, SharePoint, Confluence, a ticketing system and a file server each express permissions differently: sharing links, site membership, space permissions, ticket visibility, NTFS ACLs. The ingestion connector for each source has to read the effective permission of every document and translate it into the common model, resolving group nesting where the source allows it. This translation is the bulk of the engineering, and it is where most leaks originate, because a connector that reads content but not permissions produces an index that looks complete and is unsafe.

Handle inheritance and exceptions

A document inherits its folder's permissions until someone shares it individually or breaks inheritance. The connector must capture the effective permission, not the folder default. "Anyone with the link" documents deserve a decision: treat them as public within the organisation, or exclude them, but do not let a connector silently classify them as open to everyone including external users.

Keeping entitlements current

Permissions change more often than content. Someone leaves, a folder is reshared, a project closes and its space is restricted. The index has to reflect that within an acceptable window. Approaches, in order of strength: re-sync permissions on a schedule (hours), subscribe to change events from the source where available (minutes), or check permissions live against the source at query time for the top candidates (immediate, but adds latency and load). Most production systems combine scheduled sync with a live check on the final passages for sensitive sources. Whichever is chosen, the window must be written down and agreed with security, because "eventually consistent" is not an answer a compliance officer accepts without a number.

Enterprise search permissions and identity

The retrieval system needs to know who the user is, reliably. That means the assistant is behind your identity provider, the user's groups are resolved from it at session start, and service accounts used for ingestion are separate from the identities used at query time. An assistant embedded in another product, or reached via WhatsApp or a helpdesk, has to map the channel identity to an internal one before any retrieval. Agents that act on behalf of users inherit the same entitlements; an agent with a broad service account and no per-user filter is the same leak in a different shape, which is why the private agentic AI service treats identity propagation as a core requirement.

Proving it: negative tests

The evaluation suite for permission aware RAG includes negative cases: user X asks a question whose best answer is in document Y, which X may not see, and the test passes only if Y's content does not appear in the retrieved set or the answer. These are written by security or the data owners, run on every change to the index, the connectors or the retrieval code, and reported alongside recall and precision. A system that has no negative tests has no evidence it is safe. The test set should include the awkward cases: a document shared with X's group but then individually restricted, a user who was recently removed from a group, a document with broken inheritance. The OWASP guidance on LLM applications lists sensitive information disclosure among the top risks and is a useful framing for the security review.

Citations, audit and what the user sees

When a user cannot see a document, the assistant should behave as if it did not exist: not "there is a relevant document you cannot access", which confirms existence, but a normal answer from what they can see, or "I could not find that". Every query is logged with the user, the entitlement set used, the chunks retrieved and the answer, so an audit can reproduce exactly what someone was shown and why. This log is also what regulators will ask for, described in AI audit trails.

Multi-tenant products

In a SaaS product, the permission model has two layers: tenant isolation, which must be absolute, and per-user permissions within the tenant. Tenant ID is a mandatory filter on every query, enforced at the database layer, with a test that a query from tenant A can never return a chunk from tenant B. The multi-tenant LLM architecture guide covers the patterns.

A worked example

A B2B software company built an internal knowledge assistant over its wiki, shared drives, ticketing system and a set of customer contracts. The first version indexed everything a service account could read, which was almost everything, and a pilot user asked a question that surfaced a contract renewal negotiation they had no business seeing. The rebuild started with the permission model: each connector was rewritten to capture effective permissions, groups were resolved from the identity provider at session start, the index stored ACLs on every chunk, and the retrieval query filtered before ranking with row-level security as a backstop. A negative test set was written with the legal and HR teams. Permissions re-synced hourly, with a live check on contract documents at query time. The assistant relaunched with the security team's sign-off, and the negative tests run on every deployment. The same discipline underpins the in-app copilot delivered for a field-service product, where customer data isolation was the equivalent concern.

Team and timeline

Permission-aware retrieval is an architect for the entitlement model, an AI engineer for retrieval, and an integration engineer per source connector, with security and data owners on your side writing the negative tests. Add two to four weeks to a standard RAG build for two or three sources; more for sources with complex permission models such as SharePoint. It is part of every enterprise retrieval and knowledge engineering engagement, from $14,000 / ₹8.8L, and of enterprise platform implementation work where the assistant sits on top of existing systems. Our security page describes how client data is handled during the build. Prices are on the pricing page.

Before you start: a checklist

  • List every source and how it expresses permissions
  • Decide the common entitlement model: users, groups, roles, tenants, labels
  • Confirm the identity provider and how groups are resolved at session start
  • Choose the enforcement point: pre-ranking filter, with database-level backstop
  • Agree the permission refresh window with security, in minutes or hours
  • Write negative tests with the data owners before indexing anything sensitive
  • Decide what the assistant says when the answer is in a document the user cannot see
  • Set up the query log with user, entitlements, chunks and answer

Glossary

  • ACL: access control list; who may read a document
  • Effective permission: the actual access after inheritance, sharing and exceptions are applied
  • Pre-ranking filter: restricting the candidate set by entitlement before similarity ranking
  • Row-level security: database policies that restrict rows per user, independent of application code
  • Negative test: a case that passes only if a restricted document is not retrieved
  • Identity propagation: carrying the end user's identity through agents and services so entitlements apply at every step
  • Tenant isolation: the absolute separation of one customer's data from another's in a shared product

Why basic RAG fails in production puts permissions among the six failures, Row-level security for AI analytics covers the structured-data equivalent, and the pricing page has the numbers.

Filter by entitlement before ranking, keep the entitlements fresh, and prove it with tests that must fail to retrieve; everything else is a prompt pretending to be a policy.

Frequently asked questions

Can we just tell the model not to share confidential documents?

▾

No. By the time the model sees a passage, the leak has happened. Permissions must be enforced in the retrieval layer, before ranking, against the user's verified identity.

How quickly must permission changes reach the index?

▾

Agree a window with security. Hourly re-sync plus a live check on sensitive sources at query time is a common production setting; event-driven sync brings it to minutes where the source supports it.

How do we prove the system is safe?

▾

Negative tests: named users asking questions whose best answer is in documents they may not see, passing only when nothing from those documents appears. Run them on every change and report the results.