Skip to main content

RAG poisoning

Indirect prompt injection via poisoned documents in a retrieval-augmented (RAG) corpus.

Static. Builds its prompts up front and sends them. It drives no model of its own, so it is cheap and repeatable.

Poison the retrieved corpus and judge what the target does with it.

Helper models​

Models this attack drives, configured under its roles. Each one is a ModelConfig.

RoleKindNeededWhat it does
attackerchat modelrequiredWrites the poisoned passages that are planted in the retrieved documents.
embedderembedding modelrequiredEmbedding model used to index the documents and retrieve the passages most relevant to each query.

Parameters​

Settings for the algorithm itself, written under the attack's parameters. Anything left out keeps its default.

FieldTypeDefaultDescription
documentslist of string (at least 1)requiredThe knowledge base to poison, one entry per document (raw text).
benign_querieslist of stringemptyBenign queries to retrieve with. Empty means the attacker writes them.
queries_per_goalinteger (>= 1)5Queries generated per goal when none are given.
strategystringinline_context_overrideHow the payload is written: inline_context_override | append_hidden_directive | maximize_retrieval.
poisoned_rationumber (> 0.0, <= 1.0)0.5Fraction of the corpus to poison, most-relevant documents first.
payloads_per_queryinteger (>= 1)5Payloads inserted per query anchor, each at its own paragraph.
chunk_sizeinteger (>= 1)1000Retrieval chunking.
chunk_overlapinteger (>= 0)200Characters shared between consecutive chunks, so a passage cut at a chunk boundary is still retrievable.
top_kinteger (>= 1)5Chunks retrieved per query.
vulnerable_promptbooleanfalseTreat instructions in retrieved context as authoritative. The attack's ceiling, not a realistic defence.

In a campaign file​

attacks:
- name: rag
parameters:
documents:
- '...'
roles:
attacker:
name: llama3.2
connection:
provider: ollama
type: OLLAMA
embedder:
name: nomic-embed-text
connection:
provider: ollama
type: OLLAMA
Needs a helper model

This attack cannot run without attacker, embedder. A campaign that leaves it out fails to resolve, before anything is attacked.