Enterprise RAG: enforce access before content reaches the model

Company-knowledge assistants are often evaluated for answer relevance, although the first architectural question is access. Which documents may be used for this user, in this context, at this moment? When restrictions apply only after generation, prohibited content may already have entered the model context, caches or logs.

Establish the acting identity and scope

User identity should come from a trusted session rather than the question text or a model-generated parameter. Distinguish the user, organisation, assigned roles and permissions derived from document relationships. The service account connecting to search should not automatically define the end recipient's authority.

We recommend propagating a controlled authorisation context through search, full-document retrieval, answer construction and opening cited sources. Securing one step does not secure the others. Possessing a document link is not permission to read it.

Filter before constructing context

Microsoft describes permission-based result filtering. In the proposed design, the application determines permitted scope independently of the model's search request. Only qualifying results can enter generation. A model must not remove the filter because it considers the available material insufficient.

Permission metadata must be complete. A document without an assigned organisation or access policy should remain unavailable until clarified. Default inclusion of unclassified records is particularly hazardous during migrations and bulk imports.

Treat revocation as a production event

Role changes, employee departure and project-access removal must affect the assistant too. Define acceptable propagation time and how requests are restricted when permission synchronisation becomes unreliable. Periodically reimporting documents is not enough to control the intervals between runs.

In an illustrative scenario, a user loses project access after previously receiving a cached answer. A cache key based only on question text can continue exposing information. Answer caching should therefore include organisation, permission scope and policy version, or reauthorise the contributing sources before returning a result.

Defence layers and their boundaries

LayerControl to validate
SearchApplication-defined data scope
Source retrievalCurrent permission for the specific document
CacheRecipient isolation and policy invalidation
TelemetryNo unnecessary document content
CitationsAccess checks when a source link is opened

Where database-level controls are involved, inspect the application's actual credentials. PostgreSQL documents exceptions to RLS enforcement. A policy's existence in the schema is insufficient if the production path uses an identity outside the expected restriction.

Negative tests matter more than the demonstration

Create users with partly overlapping permissions, similarly named documents and questions whose answers exist only outside the permitted scope. Check answer text, citations, suggestions and error messages for disclosure. Revealing the existence or title of a restricted document can itself be inappropriate.

Include permission changes during an active conversation. Chat history should not become a permanent pass to information the user can no longer access. Establish when context must be rebuilt and which capabilities are reduced following a permission change.

Test source previews as well as main answers. A secure answer can still be undermined by an unrestricted download route, a thumbnail endpoint or a context-debugging screen. Administrative tools deserve separate authorisation rather than inheriting broad access from their usefulness during development.

The production acceptance gate

Before expanding access, validate change propagation, cross-organisation isolation and behaviour when permission services fail. Name the owner of discrepancies between the source and index. If permission cannot be established, reduce capability instead of silently searching a broader collection.

The acceptance record should describe residual propagation windows and the business owner's decision about them. Testing only a static snapshot of roles cannot establish control over a live knowledge system.

Permission changes between search and retrieval

Searching an identifier and fetching its content happen at different moments, with possible state changes between them. During acceptance, revoke access after the result list is created but before the full document is retrieved. Also attempt to open an earlier preview. The system should apply current authority rather than relying on the previous search succeeding.

Design emergency administrative access separately if the organisation needs it. Define its purpose, scope and usage record instead of making it a hidden default for troublesome documents. A diagnostic tool with broad privileges must not accidentally become an endpoint used by the production assistant. Such a bypass would invalidate the control even when ordinary search filtering works correctly.

Build controlled enterprise knowledge with Geekforce

We can connect a RAG assistant to access policies, source updates and controlled telemetry. Together, we can improve your team's access to knowledge without accidentally expanding its authority.

Sources and further reading

Don't just take our word for it — read what our clients say on independent platforms.