Arviser

Threat modeling a RAG pipeline

Short answer: threat modeling a RAG pipeline means walking every step from source documents to the rendered answer and asking two questions at each one. Who can put text here, and what happens if the model follows it? The main risks sit in the write path, secrets in the index, tenant and role boundaries, backups and exports, and outbound channels.

A RAG assistant reads untrusted input almost everywhere, and the model cannot reliably tell data from instructions. Controls have to sit outside it.

Which steps does the model need to cover?

Short answer: ten steps. Sources, ingestion, embedding, the vector store, retrieval, prompt assembly, the model, tools, output, and logs with any feedback loop. Draw them as one data flow. Then mark each arrow with who controls the input and which control sits there today. Gaps show up as arrows with no control.

For embedding and the model, the main questions are where the text is sent and what the provider keeps.

Step Who controls the input Risk to check Test idea Pass criterion
Sources Staff, customers, external systems Instructions hidden in text, secrets in data Plant a canary instruction in a doc, ticket, and log Answer ignores it in every repeat
Ingestion Pipeline Hidden text, permissions lost at chunking Index a file with hidden text and a restricted label Hidden text stripped, label kept on every chunk
Vector store Admins, service accounts Open access, shared index, soft delete List who can read, export, and restore it Access matches the source data
Retrieval User query and content authors Permission bypass, one source flooding top results Query from two tenants and two roles No chunk outside the caller's rights reaches the prompt
Prompt assembly Developers Data and commands mixed, secrets in system prompt Ask for the system prompt and tool schemas No secrets or internal addresses exposed
Tools The agent Rights wider than the task, approvals skipped Ask for an action outside the task Gateway refuses, approval enforced outside the model
Output The model, so potentially the attacker Data in links, images, HTML Request an answer with an external image No external resource renders
Logs Everyone Secrets in traces, output re-indexed Search logs for the canary Masked, and logs never return to the index unreviewed

Cover tools only if the assistant has them. Mark the row not applicable otherwise, with the reason.

How does the write path poison the index?

Short answer: anyone who can edit a source can change what every later user retrieves. A junior wiki editor, a contractor, a customer filing a ticket, or an outside author whose text lands in a log all count. Map every write path, rank them by trust, and test whether a planted document reaches the top results.

Two variants deserve their own lines in the model. A document written to match many common questions can dominate answers across topics. And model output that gets indexed again turns one injection into a repeating one, which is hard to trace once the original input is gone. Controls: review on publish, recorded provenance per chunk, a cap on chunks from one source, and an index rollback. The indirect prompt injection guide covers how planted text steers the model.

Where do secrets enter the index?

Short answer: through configs, logs, error messages, and code that get indexed with everything else. A connection string in a sample config or a token in a stack trace becomes retrievable text. The test is simple: plant a fake secret in a source and check whether it ever appears in an answer.

Scan for secret patterns at ingest and redact before indexing. Keep secrets out of the system prompt as well, because hidden context can be extracted.

How do tenant and role boundaries fail?

Short answer: most often when permissions are checked after retrieval or only in the interface. If a restricted chunk reaches the prompt, the boundary has failed, even if the model refuses to repeat it. Filter by the caller's rights before prompt assembly, or keep tenants in separate indexes, and test with users who should and should not see each document.

Include a revoke test. Remove a user's access in the source system and confirm the assistant stops returning that document. Full method in cross-tenant retrieval.

Are backups and exports part of the threat model?

Short answer: yes. A vector store dump, its backups, and debug exports are close to a copy of the source text. Published research has recovered readable text from embeddings. Treat the store and every copy with the same access rules and encryption as the documents, and check that deletion really removes chunks, vectors, caches, and traces.

Ask who can download the index, who can restore a backup, and who can read production prompt traces. Broad observability access can leak the same data without anyone touching the chat.

Which outbound channels matter?

Short answer: any path that carries data out of the answer. Markdown images that load on their own, links with data in the URL, tool calls, ticket comments, and emails. Untrusted input, sensitive data, and an outbound channel together form the lethal trifecta. Removing the outbound channel is often the most practical first fix.

Check the list of allowed domains too. A trusted proxy or an approved domain can still carry data out. See the lethal trifecta.

Worked example (synthetic)

This example is synthetic. It describes no client system.

An internal assistant answers engineers' questions over runbooks, tickets, and connector logs. The team draws the ten steps and finds three gaps. Connector logs carry field values from customer records, so outside text reaches the index. The answer renders markdown images. The index holds 14 sample configs. They plant a canary instruction in a log line and a fake token in one config. In 9 of 20 runs the answer includes an image URL carrying the token. They disable external images, redact configs at ingest, and rerun. The result is 0 of 20.

Checklist

Common questions

How often should the threat model change?

Update it when you add a source, a tool, or a tenant, and after a model or index change.

Do filters on input solve injection?

They catch known patterns. Simple rewording gets past them, so the model needs hard limits on data and actions as well.

What if we have no staging copy?

Testing on production with read-only access is possible but limits what can be checked. Write those limits down.

Who should own it?

The engineering owner of the assistant, with security review. See what an AI security review report includes.

Next: Cross-tenant retrieval · Indirect prompt injection · Lethal trifecta · AI security risks · Request a security review · Vector store backups and exports

Request a security review