In this enterprise RAG pipeline, users must never receive content from documents they are not permitted to read. Where should that rule primarily be enforced?
Show the answer and explanation
Correct answer: B, In the retriever: filter on the user's permissions (ACL metadata on every chunk) at query time, so unauthorized chunks are never retrieved or put in the prompt.
Explanation Access Control
Authorization must be deterministic and enforced before the model sees the data. In RAG that means a permission filter in the retriever: every chunk carries ACL metadata (owner, groups, department, classification), and the vector or keyword query only searches chunks the user is allowed to read.
Why the alternatives fail:
- System-prompt rules are probabilistic. Prompt injection, jailbreaks or simple model mistakes can bypass them, and the restricted text is already inside the context window.
- A reranker score penalty only reorders candidates: whenever fewer than k permitted chunks are among them, restricted chunks still fill the top-k. Lowering a score is not access control.
- Filtering the answer afterwards misses restricted facts that the model states without citing them, and by then the restricted text has already been sent to the model.
Practical details interviewers like:
- Pre-filtering (filtered ANN search) versus post-filtering: post-filtering top-k can return fewer than k results, or none.
- Sync permissions from the source systems (SharePoint, Google Drive, Confluence) and re-index when ACLs change.
- Include the permission scope in cache keys, especially for semantic caches.
- Apply the same rule to tools in agentic systems: the agent acts with the user's permissions (least privilege), not a super-user service account.
Interview tip: a crisp line is "authorization lives in code and data filters, never in the prompt". Guardrails on the output are defence in depth, not the primary control.