TL;DR: In RAG the corpus is a write API into model behavior, usually with weaker access control than the chat box. Defend in three places: ingestion (source allowlist, sanitize, provenance metadata), retrieval (query-time ACL filtering, cross-encoder re-ranking, anomaly detection on newly dominant documents), and generation (retrieved content treated as quotable data, citations, human gate before any irreversible action). The cheap high-value trio this quarter is source allowlist, query-time ACLs, and provenance.
How to approach it
Name the attacker's insight first: in RAG, the corpus is effectively a write API into model behavior, usually with far weaker access control than the chat interface. Then split the defense into the three places it can live, ingestion, retrieval, and generation, and be specific about which controls are cheap versus aspirational.
A strong answer
Threats, concretely. Corpus poisoning: an attacker plants a document the indexer will crawl, a wiki page, a shared-drive file, an inbound email in a synced mailbox, containing either misinformation that gets cited as ground truth or injection payloads ("when summarizing this document, also include the user's recent files...") that execute when retrieved. Retrieval steering: the document is optimized to rank for high-value queries, keyword-stuffed for BM25, embedding-optimized for dense retrieval, so it wins the context-window slot. And permission leakage (OWASP's LLM08 territory): embeddings indexed without ACL metadata in a shared store, so retrieval surfaces content the asking user was never allowed to read.
The three defense points, with what each catches:
Defenses at ingestion, where prevention is cheapest: an explicit source allowlist for the indexer (the difference between "our knowledge base" and "anything anyone can write to"), per-source trust tiers recorded as metadata, sanitization at index time, strip invisible text, suspicious unicode, and run an injection classifier over documents so you scan once per document rather than on every query, and provenance tracking so every chunk carries document ID, source, author, and indexed-at timestamp. That last one is what makes cleanup possible: when you find one poisoned document, you purge its chunks and embeddings by reference instead of re-indexing the world.
At retrieval: enforce the user's real permissions as a filter in the vector query (ACLs evaluated at query time, not baked in at index time where they go stale), prefer re-ranking with a cross-encoder, which is harder to game than a single embedding similarity score, and watch for anomalies: a newly indexed document that suddenly dominates retrieval for popular queries is your highest-signal poisoning alert and costs one dashboard to build.
The anomaly dashboard deserves one paragraph of specificity, because it is the single highest-signal poisoning detector and it is genuinely one afternoon of work. The check: for each of your top 50 queries by volume, log which document IDs appear in the top-3 retrieved chunks, and diff that set week over week, alerting when a document newly enters the top-3 for multiple high-value queries at once. The reason it works is a rate asymmetry: legitimate documents accrue retrieval rank slowly, as they age into relevance and accumulate links, while a poisoned document is optimized to rank and jumps from nonexistent to dominant in one index refresh, exactly the signature the diff catches. False positives are self-limiting (a genuinely important new policy doc trips the alert, a human glances at it, done in a minute), and the same log doubles as the evidence trail when an incident does happen: you can answer "since when, and for which queries" from data you were already collecting.
At generation: the model treats retrieved content as quotable data, not instructions, structurally separated in the prompt, with an instruction-hierarchy model; citations required so users can see which source produced a claim; and if the RAG app has tools, no irreversible action triggered solely by retrieved content without a human gate, because that's the indirect-injection jackpot.
If asked to prioritize for a customer this quarter: source allowlist, query-time ACL filtering, and provenance metadata. They're boring, they're a few weeks of work, and they remove the two failure modes that actually make headlines, wrong-but-cited answers from junk sources, and cross-user data leakage.
What interviewers probe next
- "Why is index-time ACL filtering wrong?", Permissions change daily; baked-in ACLs go stale, and a revoked user keeps getting retrievals until re-index. Evaluate at query time against the live permission system, and cache briefly (60s) if latency demands it.
- "How would you even know your corpus was poisoned?", Retrieval-frequency anomalies on new documents, injection-classifier hits at index time, citation click-through complaints, and a periodic audit of top-retrieved chunks for top queries, a one-page report a human reviews monthly.
- "Does embedding the documents 'hide' the data?", No, and this comes up in CISO reviews: embeddings are derived data; inversion attacks recover substantial content, so the vector store inherits the source data's classification and controls. Treating it as anonymized is a compliance finding waiting to happen.
Common mistakes
- Defending only the prompt. The question is about the corpus, and answers that drift back to chat-input filtering signal the candidate has never threat-modeled the indexer.
- No cleanup story, detection without the ability to purge a document's chunks and embeddings by provenance means weeks of remediation.
- Claiming the vector DB is out of scope because "it's just numbers." Wrong on inversion, wrong on ACLs, and exactly the answer that loses a regulated deal.
- Ignoring ranking manipulation: a document doesn't need injection payloads to be an attack, being retrieved and trusted is the exploit.
