Home / Lab / Blog

RAG that respects permissions

A company chatbot that can read everything will eventually tell someone something they were never allowed to see. Here is how to stop that at retrieval time, not in the prompt.

Nov 07, 2026 · 2 min read · Rudhvish Patel

The fastest way to build an internal assistant is to index every document into one vector store and let the model answer from whatever comes back. It demos well. It also means a sales rep can ask about salary bands and get a confident, cited answer from an HR spreadsheet.

Prompts are not access control

"Only answer from documents the user is allowed to see" in a system prompt does nothing: by the time the model reads that line, the restricted text is already in its context window. The model can't un-read it, and a prompt injection in another document can tell it to ignore the rule. Permission checks have to happen before anything reaches the model.

Filter at retrieval, using the source system's rules

  • Carry ACLs into the index. Every chunk stores the groups or user IDs that can read its source document, copied from SharePoint, Google Drive, the CRM or SAP at ingest time.
  • Filter in the query, not after it. The vector search runs with a metadata filter for the caller's groups. Post-filtering the top 10 results means a user with narrow access often gets zero useful passages and the bot starts guessing.
  • Resolve identity server-side. The user's groups come from your identity provider on the backend, never from a field the browser sends.
  • Re-sync on change. Permission changes need to reach the index within minutes. A nightly job means a fired contractor keeps access until tomorrow.

Test it like a security feature

An eval set for a permissioned RAG system needs negative cases: questions a given role should not be able to answer, run as that role, on every release. The pass condition is "I don't have access to that" or a refusal, never a partial leak. Log retrieval results with the caller's identity so an audit can show exactly which chunks a user saw.

None of this is exotic. It is the same least-privilege rule every other system already follows, applied one step earlier than most chatbot tutorials apply it.

Next noteWhat a CCTV theft-detection pilot should measure

Contact Null Overflow

Let’stalk.

An AI system, an app, a website, or a written plan for which one you need.
Tell me the problem, the data involved and your timeline. No forms, no auto-pricing.