Skip to main content

Should an AI assistant check permissions before or after it searches?

Before. An assistant on your documents first looks up relevant passages, then writes its answer from them. Put the permission check ahead of the search and the assistant is physically unable to retrieve anything outside the asker's clearance. Put it after, and the assistant has already taken in restricted material, which can then seep into what it says.

There is a short video version of this topic, about four and a half minutes with captions, on YouTube.

Why the order matters

This is one of the first design questions we ask about any assistant, because two systems that look identical in a demonstration can behave very differently when something goes wrong. The difference is simply where the permission check sits.

A records room and two receptionists

You ask a records room for a file. The first receptionist inspects your badge and retrieves just the files your clearance allows.

The second gathers every file that matches, reads them all, and only then checks your badge. They may hand over only your files, but they have read the rest, and what they say to you can be coloured by it.

One caveat: an assistant can stitch passages from many documents into a single answer. So the check cannot happen once at the door; it has to apply to every passage.

The two designs

When a question comes in, the assistant searches its catalogs for the best-matching passages, a step engineers call retrieval. The permission check can go in one of two places.

Check firstCheck afterwards
How it worksThe search only covers passages this person may see.The search covers everything; restricted passages are stripped out later.
Also calledPre-filtering, permission-aware retrievalPost-filtering
What it means for youText that was never read cannot leak, and the answer is the best one available from what the person may see.Safety depends on every later step removing every restricted passage, every time.

Both look the same in a demo. They differ in what can go wrong.

What a well-built system does

  • The access rules go wherever the text goes. Each document's rules are copied in with it, attached to every passage, and updated when they change. Our guide on how permissions reach the assistant and stay current covers this.
  • The search is tied to the person asking. Their identity and group memberships narrow what is searched before a single passage is read.
  • Some content gets a catalog of its own. If two departments or two clients have to stay strictly apart, each can be given an entirely separate catalog; see keeping departments and clients apart.
  • Built-in assistants rely on your current permissions. Microsoft, for instance, says Microsoft 365 Copilot only brings up data a person can already at least view (Microsoft Learn). That makes it exactly as safe as your permissions are today.

Risks of filtering at the end

  • A single gap is enough. If any one stage skips the filter, or a newly added feature routes around it, restricted text ends up in a reply.
  • A leak need not be a quotation. Hints, summaries and source links can all expose the contents of a file the person could not open; see how an answer can give a document away.
  • Answers get worse without explanation. If the strongest matches were restricted and quietly removed, people receive thinner answers and never learn why.

Why security teams pay attention

The OWASP security foundation ranks poorly controlled access in these search systems among the ten biggest dangers for AI applications, since such gaps can leak sensitive material, even from one user of a shared system to another (OWASP, LLM08:2025).

What to ask your IT team or vendor

  • Is the person checked before the search, or are restricted results removed afterwards?
  • Is every passage checked, and are summaries and source links checked too?
  • When a person's access or a file's sharing changes, how soon does the assistant know?
  • Can we watch a test in which two people from different departments ask the same question and each sees only what they may?

Terms you may hear

TermWhat it means
RetrievalLooking through your files for the passages most relevant to a question.
Pre-filtering, permission-aware retrievalLimiting the search to permitted material from the outset.
Post-filteringSearching the whole collection and stripping out forbidden hits afterwards.
Security trimming, document-level securityVendor terms for suppressing results the asker has no right to view.
RAGRetrieval-augmented generation: the assistant finds relevant passages in your files first and builds its reply from them. See how it works.

How we help

When we review an assistant, design or vendor, we establish where the permission check sits: inside the search, or after it. If it comes afterwards, we map every step that has to catch restricted text, including summaries and source links.

We confirm that each passage carries its document's access rules and that the search uses the asker's identity and groups, and we help decide which content belongs in a separate catalog altogether.

Then we test it with you: two people from different departments, the same question, and a check that each sees only what they should.

Talk to us about your project

Sources

A vendor-neutral explainer on this topic is on securellm.ai, which we publish.