When Does a Prompt Become a Worm? Measuring Reproduction Numbers of Self-Replicating Instructions in Retrieval-Augmented Memory

Retrieval-augmented generation (RAG) assistants increasingly store their own answers in the same index they retrieve from, closing a loop in which a planted instruction can copy itself across answers. While it has been established that such “prompt-injection worms” are feasible, what has been missing is a way to measure them. We give the first quantitative, epidemiological treatment of instruction replication in RAG memory: casting it as a branching process, we estimate a reproduction number R0, a per-exposure transmissibility p1, and a lineage-attributed Reff, separating marker expression from instruction replication. Across a controlled factorial (placement × memory window × model, five seeds, clustered logistic model), self-sustaining spread (R0 > 1, 95% CI entirely above one) is already reachable by an 8B open model under realistic document-level placement; at 32B it saturates (R0 ≈ 5.7). A short memory of the system’s own answers is the amplifier that makes removing the original poisoned document insufficient after an outbreak. Of three defenses, a perfect marker filter is cosmetic, a storage-time copy guard is defeated by the still-present source document, and spotlighting lowers realized spread without lowering per-exposure transmissibility. We release the harness, corpus hash, and logs. (Code and data: https://github.com/samtout/rag-worm).

Authors

Publication Details

Journal
Preprints.org
Published
2026-10-27
DOI
https://doi.org/10.20944/preprints202610.2588.v1
Primary Topic
Adversarial Robustness in Machine Learning
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
preprint

When Does a Prompt Become a Worm? Measuring Reproduction Numbers of Self-Replicating Instructions in Retrieval-Augmented Memory

Samir Tout
1 links
Preprints.org
Adversarial Robustness in Machine Learning
preprint

When Does a Prompt Become a Worm? Measuring Reproduction Numbers of Self-Replicating Instructions in Retrieval-Augmented Memory

Samir Tout
preprint en

Abstract

Retrieval-augmented generation (RAG) assistants increasingly store their own answers in the same index they retrieve from, closing a loop in which a planted instruction can copy itself across answers. While it has been established that such “prompt-injection worms” are feasible, what has been missing is a way to measure them. We give the first quantitative, epidemiological treatment of instruction replication in RAG memory: casting it as a branching process, we estimate a reproduction number R0, a per-exposure transmissibility p1, and a lineage-attributed Reff, separating marker expression from instruction replication. Across a controlled factorial (placement × memory window × model, five seeds, clustered logistic model), self-sustaining spread (R0 > 1, 95% CI entirely above one) is already reachable by an 8B open model under realistic document-level placement; at 32B it saturates (R0 ≈ 5.7). A short memory of the system’s own answers is the amplifier that makes removing the original poisoned document insufficient after an outbreak. Of three defenses, a perfect marker filter is cosmetic, a storage-time copy guard is defeated by the still-present source document, and spotlighting lowers realized spread without lowering per-exposure transmissibility. We release the harness, corpus hash, and logs. (Code and data: https://github.com/samtout/rag-worm).

Preprints.org
Adversarial Robustness in Machine Learning
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon