Skip to content

Interview question · LLM Application Security

How would you secure a RAG application end to end, from ingestion to answer?

A design round in miniature. The answer that scores follows the data through both halves of the pipeline and spends most of its time on authorization, where real leaks happen.

hardEssentialNewPreparation tags: Microsoft, Google, AmazonUpdated Nov 2026

TL;DR: Walk the pipeline. At ingestion: know who can write each source, copy permissions and tenant into chunk metadata, scan for secrets, and propagate updates and deletions. At retrieval: filter on the asking user's identity before ranking, isolate tenants, key caches by user. At generation: mark retrieved text as untrusted, keep secrets out of prompts, minimise context. At output: safe rendering, citations, no external fetches. Around it: logging with privacy controls, monitoring for poisoning and leaks, and tests for revocation and cross-tenant access.

How to approach it

Clarify scope first: internal or customer-facing, single or multi-tenant, which sources, whether the assistant has tools. Then go stage by stage. Lead with authorization, because missing permission filters cause more real RAG leaks than any exotic attack.

A strong answer

FIG · RAG END TO END · CONTROLS AT EACH STAGE
Walk the pipeline from ingestion to answer

Ingestion

who can write sources

Index

ACL and tenant per chunk

Retrieval

filter before ranking

Generation

context marked untrusted

Output

safe render, citations

Key controls

Secret scan, deletions sync

  • Updates propagate with known lag

User-keyed caches

  • Tenants isolated in the store

No external fetches

  • Blocks exfiltration through rendering

Assume a multi-tenant SaaS assistant answering from each customer's documents and tickets.

Ingestion.

  • Source trust. List sources and who can write them. Customer-uploaded documents and inbound tickets are untrusted for instructions.
  • Permissions into metadata. Each chunk records tenant, source document ID and allowed principals. Documents whose permissions cannot be represented are excluded.
  • Hygiene. Scan for secrets and regulated data; decide what should not be indexed at all.
  • Lifecycle. Updates, permission changes and deletions propagate with a defined maximum lag.

Retrieval.

  • Tenant isolation. Separate index or namespace per tenant, enforced by the store, not only by application code.
  • User filtering before ranking. The query carries the user's principals; only allowed chunks are scored.
  • Caches of retrieved context and answers keyed by user and tenant.

Generation.

  • Retrieved chunks delimited and labelled as data; instruction-hierarchy model.
  • Minimal context: only what the question needs.
  • No secrets or access rules in the system prompt.
  • If the assistant has tools, apply the lethal trifecta check: retrieved content is untrusted, so outbound capabilities are restricted.

Output.

  • Safe rendering: encoded text, no external images, links neutralised or confirmed.
  • Citations so users can verify, which also limits harm from poisoned content.

Operations.

  • Logs that record retrieval sets and answers with redaction and short retention.
  • Monitoring: denied cross-tenant access attempts, documents that suddenly dominate retrieval, outbound URLs in answers.
  • Tests: a revoked user cannot retrieve; tenant A cannot retrieve tenant B; deleted documents disappear; an injected test document cannot trigger exfiltration.
FIG · BYPASSED VS PROTECTED · RAG PIPELINE
Service-account retrieval and raw rendering versus user-filtered retrieval and safe output

Weak RAG

Search runs as service

all documents

Answer renders images

from any URL

Cross-user leaks

Outcome, unsafe: Exfiltration via render

Poison unnoticed

Secured RAG

Filter by user before ranking

ACLs on chunks

Safe markdown, no remote images

citations

Only permitted content

Outcome, safe: No render channel

Provenance tracked

What interviewers probe next

  • "Filtering after top-k is simpler. Why not?" Relevance collapses when many top results are forbidden, and teams then loosen filters. Filter inside the search.
  • "What about embeddings themselves?" Embeddings can leak information about source text, so protect the index like the documents it was built from.
  • "How do you handle a shared knowledge base plus private documents?" Two scopes in the query, each with its own permission filter, and clear source labels in answers.

What if?

What if · interview follow-ups

Hold your answer as the constraints change

You are reviewing a RAG assistant design from document ingestion to the rendered answer, before it is opened to all employees.

  1. Start here

    What would you check at ingestion?

How it's scored

Weak: Focuses on prompt instructions and an input filter; access control is mentioned vaguely.

Hire: Copies permissions into metadata, filters by user, isolates tenants and treats retrieved text as untrusted.

Strong Hire: Covers lifecycle sync and deletion, caches, output handling, the trifecta for tool-using variants, and gives a concrete test plan.

Common mistakes

  • Indexing everything first and planning permissions later.
  • Tenant filters implemented in one code path that another path skips.
  • Ignoring deletion and revocation latency.
  • Sharing a response cache across users.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 10, and we keep track of how far you get in every topic.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in doubles your free answers, from 5 to 10 per topic, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

No comments yet. Share a correction or a different way to answer it.