Enforce ACLs inside the vector search as a pre-filter, not in the prompt and not after retrieval. Pre-filtering preserves recall and closes the result-count side channel.
Think of a librarian helping you find books. If the librarian first grabs the ten best matches and then puts back the ones you cannot read, you sometimes leave with only three books, and the missing seven tell you that secret books exist on your topic. If the librarian instead checks your library card first and only searches among books you can read, you always get ten good matches and never learn the secret books are there. Now imagine asking the librarian to whisper the answer but skip secret parts. One slip of the tongue and the secret is out. RAG access control is exactly the same. Check before searching, never after, never in the answer.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
RAG access control is one of the most consistently mishandled areas in production LLM systems. The reason is that the problem looks like it has three plausible solutions and only one of the three is actually safe. The two unsafe options feel reasonable in a whiteboard discussion and only reveal their failure modes under attack or scale.
This deep dive walks the three placements, explains the specific failure mode of each unsafe option in enough detail to defend the choice in a review, and ends with the operational details that make the safe option actually safe in production.
Why prompt-level enforcement fails
The model is not a security boundary. Saying so out loud is the first move when this option comes up.
The failure modes stack. Prompt injection: an attacker writes content that hijacks the model's instruction-following and overrides the redaction directive. Model upgrades: a new model version may comply differently with the same prompt, and the system silently degrades from safe to leaky. Stochastic error: even without an attack, the model occasionally outputs content it was instructed to redact. Side-channel leaks: even when the prose obeys, citation lists, snippet previews, and oblique references can leak the existence of restricted content.
The more fundamental issue is that the restricted content has already been placed in the context window. Whatever happens next is the model's compliance with a request, not an enforcement boundary. Compliance is statistical; enforcement is binary. They are different things, and treating one as the other is how data leaks reach the news.
Production systems treat the model layer as inside the trust boundary, not as the trust boundary itself. The model can be asked to format, summarize, or organize authorized content. It cannot be asked to keep unauthorized content secret.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Glean and Atlassian Rovo enforce ACLs as metadata filters at search time, never as prompt instructions
- AWS Bedrock Knowledge Bases supports metadata filtering on vector queries so permission predicates run inside the search
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you implement the pre-filter in a typical vector database?
Most production vector databases (Pinecone, Weaviate, Qdrant, pgvector, AWS Bedrock KB) support metadata filtering as part of the query. Index the allowed-group list per vector and pass the user's resolved group set as the filter expression. Confirm the engine pre-filters rather than post-filters under the hood.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Letting the model decide what to omit, or filtering top-k after retrieval. The first leaks under injection, the second leaks through visible result-count variation.
60 second bullets to scan on the way to the call.
Why prompt-level enforcement is not a security boundary
How post-retrieval filtering destroys recall when restricted content outranks authorized content
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.