{"id":"TIE-AGT-018","title":"Permission-aware retrieval for RAG and agent search","maturity":"documented","collection":"Agent identity","category":"Data access","complexity":"High","intent":"Make sure an agent that retrieves documents to answer a question only ever puts content into the model's context that the person it serves, and the agent itself, are allowed to read, using permissions that stay in step with the source systems.","summary":"RAG copies content into one index, usually under a powerful account. Carry access control from source to index to query, pre-filter as the user, confirm sensitive results with the source of truth, and keep caches and citations per user.","problems":["Data leakage through AI answers","Oversharing","Excessive agency","Confidential data exposure","Regulatory data protection","Audit evidence for AI governance"],"standards":["OWASP Top 10 for LLM Applications 2025 (LLM02 Sensitive Information Disclosure","LLM08 Vector and Embedding Weaknesses)","OWASP Top 10 for Agentic Applications 2026 (ASI03 Identity and Privilege Abuse)","Relationship-based access control (Google Zanzibar model)"],"tags":["RAG","retrieval-augmented generation","vector database","search index","document-level security","security trimming","ACL","permission filter","ReBAC","fine-grained authorisation","FGA","OpenFGA","sensitivity labels","oversharing","data leakage","embeddings"],"roles":["IAM architect","Identity engineer","Security leader","Platform engineering","AI engineering"],"industries":["Cross-industry","Financial services","Healthcare","Retail","Public sector"],"builds_on":["TIE-AGT-002","TIE-AGT-003"],"related":["TIE-AGT-005","TIE-AGT-015"],"authors":"Trevonix Innovation","reviewers":"Trevonix IAM architecture","version":"1.0","last_reviewed":"2026-11-24","published":"2026-11-24","og_image":"og-tie-agt-018.png","sections":{"summary":[{"type":"bullets","content":"Permissions **travel with the content**: every chunk in the index carries the access control of its source document, kept in step by sync, and content without permissions is **visible to nobody**.\nAt query time the agent retrieves **as the user**: a **pre-filter** on permission metadata keeps the search fast, and an **authoritative check** confirms access for sensitive results before they reach the model.\nAnswers, caches, summaries and citations are **per user**. The agent's own rights are the outer limit; the user's rights decide what each answer may use."}],"problem":[{"type":"paragraph","content":"A RAG pipeline indexes content from file shares, wikis, ticketing systems and CRM so an agent can find relevant passages and pass them to the model. The indexer usually runs under a service account that can read everything, and the resulting index has no idea who could open which document. When a user asks a question, the agent retrieves the most relevant chunks regardless of who is asking, and the model happily summarises a board paper, a salary file or another customer's contract.\n\nFiltering the answer afterwards does not help: once restricted text is in the model's context it can shape the answer in ways no output filter reliably catches. Permissions also change after indexing; a document shared yesterday and restricted today may still be served from the index."},{"type":"note","content":"Oversharing through AI assistants is one of the most common findings when organisations roll out enterprise search and copilots. The fix is in access control, not in the prompt.","title":"Why this matters"}],"use_when":[{"type":"bullets","content":"An agent or copilot answers questions from content that not every user may read.\nYou build your own RAG pipeline or vector index over enterprise content.\nCustomer-facing agents retrieve from multi-tenant data.\nAgents retrieve on behalf of users from systems with document- or record-level permissions."}],"avoid_when":[{"type":"bullets","content":"All indexed content is genuinely public to every user of the agent. Document that decision and keep restricted content out of that index."}],"forces":[{"type":"bullets","content":"**Speed against accuracy.** Filtering on metadata in the index is fast but can lag the source; checking each result against the source of truth is accurate but slower.\n**Coverage against complexity.** Real permissions involve groups, inheritance, sharing links and relationships that simple role filters cannot express.\n**Relevance against restriction.** Filtering after ranking can leave the agent with too few results; filtering before can be expensive at scale.\n**Shared caches against per-user answers.** Caching answers saves cost and leaks across users if keyed wrongly."}],"solution":[{"type":"paragraph","content":"Treat retrieval as an authorised read. At ingestion, the indexer captures each document's access control (users, groups, roles, sensitivity label, tenant) and writes it as filterable metadata on every chunk; documents it cannot resolve get *no access*. A sync job keeps permissions current. At query time the agent passes the **user's identity**, not its own, and the search applies a permission pre-filter. For content above a sensitivity threshold, the agent asks the authoritative authorisation service (or the source system) to confirm each result before it enters the model's context. Everything derived from retrieved content is scoped to the user who asked."},{"type":"image","content":"Permissions travel from source to index; retrieval pre-filters as the user and confirms sensitive results with the source of truth.","title":"Solution overview","media":"tie-agt-018-solution.png","alt":"Diagram. Left: source systems (file shares, SharePoint, wiki, CRM) with their permissions. An indexer reads content and permissions; each chunk is stored in the index with metadata: document ID, allowed users and groups, sensitivity label, tenant. A permission sync job keeps metadata current; docume"},{"type":"table","content":"Approach | How it works | Strengths | Weaknesses\nSecurity pre-filter | Permission metadata on each chunk; the query filters by the user's IDs and groups | Fast; scales; works with ranking | Lags source changes; group expansion limits\nAuthoritative post-check | Each candidate result is checked against an authorisation service or the source system | Accurate; handles complex relationships | Slower; may leave too few results\nFederated retrieval | The agent queries source systems with the user's delegated token | Always current; source enforces access | Slowest; uneven search quality\nHybrid (recommended) | Pre-filter for everything, post-check for sensitive content | Balances speed and accuracy | Two mechanisms to operate","title":"Retrieval approaches"},{"type":"numbered","content":"**Capture permissions at ingestion.** For each document, record allowed users and groups (or the relationship that grants access), its sensitivity label and its tenant. Copy them to every chunk.\n**Fail closed.** If permissions cannot be resolved, the chunk is visible to nobody until fixed.\n**Keep in step.** Sync permission changes on events where the source supports them, and at least daily; re-index or tombstone deleted and restricted documents promptly.\n**Search as the user.** The agent passes the user's token or identifiers to the search service; the agent's service identity is never used to bypass the filter.\n**Confirm sensitive results.** For results above a threshold, call the authorisation service or source with the user and document ID before using them.\n**Keep derived data per user.** Answer caches, conversation memory, summaries and embeddings of user conversations are keyed and stored per user (and per tenant).\n**Cite and log.** Return citations only for documents the user can open, and log which document IDs fed each answer.","title":"How it works"},{"type":"tip","content":"A copilot respects permissions that are already too broad. Before you switch on AI search, find content shared with everyone or with large groups, and fix the most sensitive of it. AI makes oversharing findable, not new.","title":"Fix oversharing first"}],"design_rules":[{"type":"numbered","content":"**Retrieval is an authorised read,** evaluated for the user who asked.\n**Permissions travel with every chunk.**\n**Unknown permissions mean no access.**\n**The agent's identity is the ceiling, the user's is the filter.**\n**Sensitive content gets an authoritative check** before it reaches the model.\n**Derived data is per user:** caches, memory, summaries.\n**Citations only to documents the user can open.**\n**Log document IDs per answer** for investigation."}],"anti_patterns":[{"type":"table","content":"Anti-pattern | What goes wrong\nIndex everything under a service account with no ACLs | Every user can get answers from every document\nFilter the answer, not the retrieval | Restricted text already shaped the answer\nRole-only filters for relationship-based sharing | Sharing links and inheritance are lost; over- or under-sharing\nShared answer cache keyed by question text | One user's answer served to another\nNightly permission sync only | Revoked access keeps working for a day\nAgent searches with its own identity | The user's permissions are ignored entirely"}],"benefits":[{"type":"bullets","content":"AI answers that respect the same access as the source systems.\nSafer roll-out of copilots and agents over enterprise content.\nEvidence of which documents fed which answer.\nCustomer-facing agents that cannot leak one tenant's data to another."}],"costs":[{"type":"bullets","content":"Indexers and sync jobs that understand each source's permission model.\nLatency for authoritative checks on sensitive content.\nAuthorisation service or relationship store to operate.\nRemediation of existing oversharing before go-live."}],"tests":[{"type":"table","content":"Test | Expected result\nUser A asks about a document only user B can read | Not retrieved; not cited; answer does not use it\nRemove a user's access in the source | Document no longer retrieved within the sync target\nIndex a document with unresolvable permissions | Visible to nobody\nTwo users ask the same question | Answers built from each user's permitted documents; no cache crossover\nCustomer agent for tenant X searches | Never retrieves tenant Y content\nConfidential result returned by the pre-filter for a user who lost access | Rejected by the authoritative check"}],"maturity_notes":[{"type":"paragraph","content":"**Documented.** This pattern is written from vendor and project documentation and has not yet been lab-tested by Trevonix."},{"type":"warning","content":"Native document-level access control in search services is new and some features are in preview APIs. Check limits such as the number of ACL entries per document and group expansion behaviour.","title":"Preview features"}],"faq":[{"type":"faq","content":"Both, in different roles. The agent's own access decides what it can ever retrieve. The user's access decides what it may use for this user's answer. Retrieval must pass both.","title":"Whose permissions apply: the agent's or the user's?"},{"type":"faq","content":"Embeddings are derived from the text and can leak information about it. Store them in the same index with the same permission metadata as the chunk, and never share an embedding store across tenants without filtering.","title":"Are embeddings sensitive?"},{"type":"faq","content":"Copilots built on platform search generally respect the source permissions. That makes existing oversharing visible, so fixing broad sharing and applying sensitivity labels is still your job before roll-out.","title":"Does Microsoft 365 Copilot already do this?"}],"references":[{"type":"bullets","content":"[Microsoft Learn: Document-level access control in Azure AI Search](https://learn.microsoft.com/azure/search/search-document-level-access-overview)\n[Microsoft Learn: Query-time ACL and RBAC enforcement in Azure AI Search](https://learn.microsoft.com/en-us/azure/search/search-query-access-control-rbac-enforcement)\n[Auth0 for AI Agents: Authorization for RAG](https://auth0.com/ai/docs/intro/authorization-for-rag)\n[OpenFGA](https://openfga.dev/)\n[OWASP Top 10 for LLM Applications](https://genai.owasp.org/llm-top-10/)"}]},"recipes":{"ping":{"status":"documented","product_name":"PingOne Authorize or PingAuthorize with PingGateway","summary":"Per-document authorisation decisions for sensitive results, with the user's delegated token enforced at the gateway. A Trevonix design from Ping's general capabilities; not lab-tested.","last_verified":"2026-11","blocks":[{"type":"table","content":"Component | Role in this pattern\nPingOne Authorize or PingAuthorize | Evaluates per-document read decisions for the user and agent\nPingGateway | Enforces that retrieval services are called with the user's delegated token\nPing identity platform | Supplies the user's identity, groups and attributes","title":"Components"},{"type":"numbered","content":"Store permission metadata on chunks as described above for the pre-filter.\nFor sensitive results, have the retrieval service send a batch of document IDs with the user and agent to your authorisation policy and keep only permitted documents.\nFront the retrieval service with PingGateway so it receives the user's delegated token, not just the agent's.","title":"Configure"}]},"okta":{"status":"documented","product_name":"Auth0 Fine-Grained Authorization with Okta or Auth0 identities","summary":"Relationship-based checks on each retrieved document through the Auth0 AI SDK retriever filters. Written from Auth0 documentation; not lab-tested by Trevonix.","last_verified":"2026-11","blocks":[{"type":"table","content":"Component | Role in this pattern\nOkta or Auth0 user identity | The user the agent retrieves for\nAuth0 Fine-Grained Authorization (FGA) | Stores relationships between users, groups and documents and answers \"can this user view this document?\"\nAuth0 AI SDKs | Provide retriever filters for LangChain, LlamaIndex and similar frameworks","title":"Components"},{"type":"numbered","content":"Model documents and their relationships in FGA (for example `owner` and `viewer` relations on a `doc` type, with group membership) and write tuples as documents are created and shared.\nIn the agent's retriever, wrap the vector search with the SDK's FGA filter so every candidate document is checked for the current user before it is returned.\nKeep FGA tuples current from the source systems' sharing events.\nUse a pre-filter on tenant or broad group in the vector store to keep candidate sets small, then let FGA make the final decision.","title":"Configure"}]},"entra":{"status":"documented","product_name":"Azure AI Search document-level access control with Microsoft Entra ID","summary":"Permission metadata ingested with content and enforced at query time from the user's Entra token; security filters for other sources. Written from Microsoft documentation; not lab-tested by Trevonix.","last_verified":"2026-11","blocks":[{"type":"table","content":"Component | Role in this pattern\nAzure AI Search document-level access control | ACL and RBAC permission metadata on indexed documents, enforced at query time from the user's Entra token\nSharePoint and ADLS Gen2 indexers | Ingest source permissions with the content (preview)\nMicrosoft Purview sensitivity labels | Classify content so sensitive results can get extra checks\nEntra ID | Issues the user token the search service uses to trim results","title":"Components"},{"type":"numbered","content":"Create the index with permission filter fields (user IDs and group IDs as Entra object IDs, or RBAC scope) and enable the permission filter option, using the preview REST API version that supports it.\nUse the ADLS Gen2 or SharePoint indexer to ingest permission metadata with the content, or push ACLs with the push API for custom sources.\nAt query time, have the agent pass the user's Entra token in the `x-ms-query-source-authorization` header so the service trims results to what the user can read.\nFor sources without native support, use security filters: store allowed user and group IDs in a filterable string field and add a filter for the user's IDs to every query.\nUse sensitivity labels to route confidential results to an extra check, and review oversharing before roll-out.","title":"Configure"},{"type":"bullets","content":"Permission metadata is evaluated as last synced; changes in the source are not enforced until the indexer runs again.\nDocuments with more ACL entries than the documented limits may not be fully enforced.\nNative ACL and RBAC enforcement is in preview APIs; check feature availability in your region and API version.","title":"Gotchas"}]},"saviynt":{"status":"documented","product_name":"Saviynt access governance and Agent Access Gateway","summary":"Reduces source oversharing and limits which knowledge bases each agent can reach; per-document enforcement stays in the retrieval layer. Written from Saviynt's published material; not lab-tested by Trevonix.","last_verified":"2026-11","blocks":[{"type":"table","content":"Capability | Role in this pattern\nAccess governance and certification | Reviews and reduces who has access to the source repositories the index reads\nAgent Access Gateway | Controls which knowledge bases and tools an agent may reach","title":"Capabilities used"},{"type":"numbered","content":"Certify and clean up access to the repositories that feed RAG indexes before roll-out.\nRestrict each agent's outbound access to the knowledge bases its purpose requires.\nKeep per-document enforcement in the retrieval layer as described above.","title":"Configure"}]},"misc":{"status":"documented","product_name":"OpenFGA, Elasticsearch document-level security or PostgreSQL row-level security","summary":"Open-source and database-native options for permission-aware retrieval.","last_verified":"2026-11","blocks":[{"type":"paragraph","content":"OpenFGA (the open-source project behind Auth0 FGA) provides relationship-based checks for any stack. Search engines such as Elasticsearch and OpenSearch offer document-level security, and PostgreSQL row-level security can enforce permissions on pgvector tables when queries run as the user's role."}]}},"slug":"tie-agt-018-permission-aware-retrieval-for-rag-and-agent-search","updated_at":"2026-11-24T17:50:33.942Z","url":"https://exchange.trevonix.com/patterns/tie-agt-018-permission-aware-retrieval-for-rag-and-agent-search","markdown_url":"https://exchange.trevonix.com/patterns/tie-agt-018-permission-aware-retrieval-for-rag-and-agent-search.md","publisher":"Trevonix","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"}}