Secure RAG: keeping private knowledge inside its access boundaries
Why a useful AI knowledge base still needs document-level permissions, tenant isolation and deletion controls.

Search relevance is not access permission
Retrieval-augmented generation (RAG) can help an assistant answer questions using corporate documents. Yet a similarity score answers only which text is close to a question; it does not decide whether the person asking is entitled to read that text. If the index contains payroll notes, contract drafts and engineering documents together, a highly relevant passage can still be forbidden to the current user.
The failure can be subtle. An assistant may paraphrase a private document without providing a link, so a reviewer sees a plausible answer rather than a file access event. The security boundary therefore must be enforced before retrieved chunks enter the model context, not only when deciding which citation to show.
Carry source permissions into each chunk
At ingestion, preserve the source identifier, classification, owner, permitted users or groups, tenant, document version and deletion state. When a document is split into chunks, every chunk must inherit the relevant access policy. Do not assume that folders with similar names belong to the same team. A label provided by an uploader should not be treated as a verified authorization rule.
When a user asks a question, authenticate that user and build a retrieval scope from a trusted identity service. Apply permission filters in the retrieval or storage layer before the model receives results. When metadata filters are available, test how they behave with missing fields, stale group membership and mixed-language queries. Reject ambiguous or incomplete authorization rather than widening the search by default.
Isolate teams and customers by design
A shared AI service may support a private workspace, several project teams and multiple customers. These boundaries should remain separate even when a person participates in more than one team. Depending on the storage technology and risk assessment, use separate collections, namespaces, indexes or dedicated stores; in all cases, enforce authorization independently of the model's answer.
Create negative tests as well as positive ones. A user in Team A should retrieve an approved Team A document, but must not retrieve a uniquely marked synthetic document belonging to Team B. Repeat the test for users whose memberships changed and for administrators who may have broad platform privileges but no business need to read customer data. Review both retrieval results and generated text for leakage.
Track updates, deletions and revocations
A source file may be deleted while its extracted text, embeddings, cache entries, summary or backup remains available. Design a lifecycle for all derived artifacts. When access is revoked, the next authorized search should no longer retrieve the restricted chunks. Document how deletion flows to indexes and caches, and separately explain any retention needed for backups or security investigations.
Treat a connector sync as a privileged operation. Use restricted service accounts and record the identity, permission snapshot and version of each ingested document. When a connector loses access or returns partial permission metadata, stop syncing affected content instead of silently exposing it to a wider audience. Review index freshness as part of access control, not just search quality.
Logs, answers and memory are also data stores
Request histories, citations, response caches, evaluation datasets and long-term conversational memory may contain excerpts of restricted documents. Give them retention limits, access controls and deletion workflows appropriate to their sensitivity. Do not automatically move personal memory into a shared team knowledge base. If a user deliberately shares selected knowledge, apply the receiving team's permissions to a controlled copy.
A logging strategy should support investigation without recording everything by default. Keep request identifiers, retrieval document IDs, permission decisions and operational metadata where justified; restrict the use of raw prompts and document bodies. Evaluate whether support engineers, external monitoring vendors or analysts can see confidential queries in logs.
Practical test before production
Prepare three synthetic projects with overlapping vocabulary and distinctive private phrases. Test direct search, summarization, citations, follow-up questions and cached responses under different roles. Attempt cross-team queries, revoke a user's group membership, delete a document, then repeat the same requests. Every leaked phrase, even without a visible citation, is a failure requiring investigation.
Use the same tests after modifying embedding models, vector storage, chunking, access filters or connectors. Before operating a RAG system, require measurable authorization controls at every boundary; the model’s promise to respect privacy is not an access control.
An authorization matrix worth maintaining
Create a compact matrix of sample roles against sources: personal notes, Team A contracts, Team B proposals, public engineering documentation and archived files. For every pair, state whether the user should retrieve, cite and summarize that content. Use unique synthetic phrases to make forbidden retrieval obvious. Include cases where a person changes teams, a document changes classification and the source becomes unavailable.
An end-to-end regression run should fail if even one forbidden phrase appears in retrieval payloads, model context, citations or generated responses. The check should execute with the real production access-control path but synthetic content, so it verifies permissions rather than memorized model behavior.
