Enterprise knowledge · Research feature

RAG Systems Vulnerable to Post-Retrieval Context Tampering

A study finds that retrieval-augmented generation models significantly lose accuracy when retrieved context is altered, with performance dropping from 77.9% to 43.5% under full corruption.

Adapted from research by Iliano Fasolino.

arXiv preprint revision · 2026-09-26 · Attribution & reuse
In this article
Editorial illustration of linked workflow.

Editor’s introduction

The study evaluates a small quantized RAG system using Llama 3.1 8B on a fact-checking task derived from FEVER. It measures accuracy degradation when retrieved passages are tampered with via entity swap, number swap, or negation, applied to zero, one, two, or three of three passages. Number-based tampering shows stability until a majority of passages are corrupted, at which point accuracy rises sharply. The model primarily responds to tampering by abstaining rather than inventing false information. The evidence is limited by small scale and automated labeling, and the findings are presented as suggestive until decoding and adjudication are improved. The study corrects a prior instrumentation error by measuring actual corruption applied, showing a fooling rate that increases from 0.4% to 72.0% as corruption grows, with abstention rising consistently across all levels.

Introduction

Large language models answer fluently but carry two known liabilities: their knowledge is frozen at training time, and they sometimes state false facts with confidence. Retrieval-augmented generation addresses both by fetching documents at query time and placing them in the prompt as evidence, with the instruction to answer from that evidence rather than from memory.

The same design creates a dependency. A RAG answer is only as trustworthy as the text that reaches the prompt. Shi et al. showed that merely irrelevant context pulls a model off track. Corrupted but on-topic context is a stronger lever, because it wears the appearance of the evidence the model was told to trust. Recent work on retrieval corruption shows that a small number of crafted passages can steer a RAG system toward an attacker’s answer, that text reaching a model through a retrieval or tool channel is an injection surface in deployed systems, and that poisoning the corpora behind such systems is practical at scale.

What is still thin is a plain measurement on the kind of system a practitioner runs on modest hardware: how far accuracy moves as corrupted context grows, whether the type of corruption matters, and whether a failing model fabricates or refuses. This paper reports such a measurement twice, because the first attempt was instrumented badly enough that the second is a replacement rather than a revision.

Contributions. We rebuild the measurement around a seeded harness that expresses the corruption level as a count of passages, asserts that the two prompts are byte-identical when that count is zero, randomises which arm is generated first, and logs the edits actually applied to each passage. On 1,911 generations this yields: a dose response scored on corruption actually applied, with a genuine zero-dose control; an edit-success rate showing that the three corruption rules deliver very different amounts of corruption for the same nominal level; a direct measure of poison adoption, separated from correctness; and closed-book and irrelevant-context controls establishing what retrieval was worth in the first place. We also state what the earlier analysis got wrong and which of its claims we withdraw.

Threat Model

The adversary can rewrite the text of passages after retrieval and before the prompt is assembled. It cannot retrain or fine-tune the generator, cannot alter the embedding model or the index, and cannot change which passages are retrieved. This is the tampered-context setting: a compromised cache or serving layer between retriever and prompt, a document store edited in place, or a rendering step that rewrites passage text.

We do not model index poisoning, where an attacker inserts documents so that they are retrieved at all. That threat is real but it turns on retrieval success, which this study does not manipulate. Claims here concern what a model does with corrupted evidence once that evidence is in front of it.

Corruption Rules and Dose

A corruption rewrites a retrieved passage so that it asserts something false while staying fluent and on topic. Entity swap replaces named entities with same-type alternatives, turning “the Eiffel Tower is located in Paris, France” into “… in Madrid, Spain”. Number swap perturbs a numeric value, turning “over 13,000 miles” into “over 3,000 miles”. Negation inserts a negation, so “Barack Obama was the 44th President” becomes “… was never the 44th President”. These are rule-based edits over a fixed substitution table, not model-generated adversarial text.

A requested count is not a delivered one. A rule can only corrupt a passage in which it finds something to change, and many FEVER evidence sentences contain no swappable numeral or no entity in the substitution table. The harness therefore records, per passage, whether an edit was applied, and we report the resulting applied dose alongside the requested one.

Outcome Labels

Correctness. The original criterion was presence of a reference keyword. That criterion is not neutral across rules: negation leaves the keyword in place, entity swap removes it by construction, and an answer that denies the fact (“Madrid, not Paris”) still contains the keyword. We use a polarity-aware criterion that resolves abstention first, reads the yes/no stance for boolean questions, and requires the keyword to fall outside the scope of a negation cue.

Fooled rate. Runs where the clean answer was correct and the corrupted answer was not, divided by the runs that were correct before the attack. The earlier version divided by all runs while describing it as the former.

Experimental Design

The evaluation set holds 49 indexed query slots drawn from 37 distinct question texts. The 12 repeats exist because the set was assembled by listing questions per rule and then appending a mixed block that re-used earlier questions. They are not independent observations, and every interval in this paper resamples the 37 distinct texts.

Two sweeps are referenced. The published sweep crossed 49 slots with three rules and four nominal levels for 588 runs; its analysis is corrected in Sections V-A and V-H. The seeded sweep supplies the results of this paper: three rules by three requested doses by 49 queries by three independent corruption draws, 1,323 grid cells, plus 147 runs each of a clean arm, a zero-dose control, a closed-book arm and an irrelevant-context arm, for 1,911 generations and about 38 hours of CPU.

What a Real Zero Dose Looks Like

The seeded harness makes the zero cell real: it asserts the two prompts are byte-identical before generating and randomises which arm runs first. Across 147 control runs the assertion holds in 100% of cases and no passage is edited.

The Rules Do Not Deliver the Dose They Request

Two consequences follow, and both are consequential for the earlier analysis. Any dose response indexed on the requested level is attenuated by an unknown and rule-dependent amount. And the three rules were never delivering comparable corruption, so comparing their strength at equal nominal dose compares different attacks.

The Rules Are Still Not Separable

The comparison is in fact worse posed than that. Table I shows the rules deliver different amounts of corruption, so a fair test would hold applied dose equal. Restricting to cells where a rule landed all three edits leaves no query answered that way by both entity and number substitution, and only five shared between entity swap and negation. At this corpus the rules cannot be compared at equal delivered corruption, because they cannot deliver equal corruption. We withdraw the ranking and do not replace it.

Adoption Separates the Rules Where Fooled Rate Cannot

Two further observations bear on how the earlier metrics were read. Adoption and abstention are not exclusive: 57.6% of adopting answers also decline to commit, quoting the corrupted value and then reporting the context insufficient. Refusal is therefore not evidence that corruption was rejected. And in the seeded sweep no adopting answer was scored correct, so adoption is cleanly distinguishable from the fooled rate rather than a relabelling of it.

What the Context Was Worth

The irrelevant arm gives the mechanism. Given three true but off-topic passages the model answers correctly zero times out of 147 and abstains in every single run. It never falls back on knowledge it demonstrably has. The instruction to answer only from context is obeyed absolutely, so context does not compete with parametric knowledge, it replaces it.

That reframes the dose response. Corruption is not overriding what the model believes; it is the only thing the model is permitted to believe. The degradation in Table II is the cost of binding an instruction following model to evidence, realised when the evidence is corrupted. It also bounds external validity: these questions concern well-known entities the generator already knows, and a corpus of facts outside its training data would behave differently in ways this design cannot predict.

One caveat on comparability. The closed-book arm necessarily uses a different system instruction, since “answer only from the context” is undefined with no context, so 83.7% is not a strictly matched condition. The direction does not depend on the margin.

Claims Withdrawn from the Published Analysis

The headline drop. Reporting 77.9% on the clean arm against 43.5% at full corruption mixes a between-arm gap with the attack. On the published table the nominal within-arm attack-only drop is 69.4% to 43.5%, or 25.9 points; the rebinned applied-dose drop from realised dose 1 (66.7%) to dose 3 (43.5%) is 23.2 points. In the seeded sweep the corresponding contrast is the zero-to-three row of Table II.

The fall in unsupported generation. Eq. (2) scores every abstention as supported, and abstention is what rises under attack, so the measure declines arithmetically. On the published table the all-answers rate fell from 28.9% to 12.2% while the rate over committed answers moved only from 33.1% to 25.4% and was not monotone in between. The proxy is also blind to adoption by construction, since it compares an answer against the corrupted text it received: “located in Madrid, Spain, not France” overlaps the true context at 0.67, far above the threshold. Direct adoption measurement replaces it.

A fifth claim is weakened rather than withdrawn. Abstention was offered as a cheap warning signal. It still rises with dose, but 57.6% of adopting answers abstain, and a merely irrelevant context produces 100% abstention, so the signal does not distinguish corruption from useless retrieval and does not imply the corruption was rejected.

On the adversarial side, Zou et al. show that injecting a small number of crafted passages into a knowledge base steers a RAG system to attacker-chosen answers, and frame retrieval corruption as an attack surface distinct from prompt manipulation. Greshake et al. show that any channel delivering text into a model’s context functions as an indirect injection vector in deployed applications. Carlini et al. show that poisoning the web-scale corpora behind such systems is practical. Our setting is narrower than all three: the adversary edits already-retrieved text, which isolates the generation stage from retrieval success.

Shi et al. establish that irrelevant context degrades reasoning. Our irrelevant-context arm sharpens that for this setting: under an answer-only-from-context instruction, irrelevant context does not degrade the answer, it suppresses it entirely. Zhou et al. caution that evaluation data can leak into training; we keep the query set fixed across all cells, though we cannot rule out that FEVER-derived facts about well-known entities are present in the generator’s training data, and Section V-G suggests they are.

Reproducibility Details

The system prompt is: “You are a fact-checking assistant. Answer the question based ONLY on the provided context. If the context doesn’t contain enough information, say ‘Not enough information’.” The user turn is the numbered context, then Question:, then Answer:, wrapped in the Llama 3.1 chat template. Abstention is matched, case-insensitively, against: not enough information, cannot determine, not provided, unclear, no information, don’t know, cannot answer.

Versions are pinned as follows: llama-cpp-python 0.3.16, sentence-transformers 5.2.2, faiss-cpu 1.13.2, numpy 1.26.2, pandas 2.1.4; generator Llama 3.1 8B Instruct GGUF Q4_K_M with SHA-256 7b064f5842bf9532c91456deda288a1b672397a54fa729aa665952863033557c; embedder all-MiniLM-L6-v2; corpus the FEVER dev split, 19,597 deduplicated evidence sentences, plus ten author-written passages; hardware an Apple M1 with 8 GB, CPU inference only (n_gpu_layers=0). Seeds are derived per generation from a checksum of the cell coordinates. Bootstrap intervals use 10,000 resamples of the 37 distinct query texts with seed 42.

One quirk applies to every run reported here. The prompt is built with an explicit <|begin_of_text|> token and the runtime prepends its own, so each prompt carries a duplicated leading token. It is a deviation from the reference chat template, kept in the seeded harness so old and new runs stay comparable, and flagged rather than silently changed.

The artifact contains the corruption code, the seeded harness, the 49 queries with reference keywords, the ten injected passages, the index build script, both run tables, the scoring and analysis scripts and the figure code. Release is pending and will be linked from the version of record.

Conclusion

We measured a small quantized RAG system under post-retrieval context tampering, replacing an earlier measurement whose instrumentation was faulty. Scored on corruption actually applied, the fooled rate runs 0.4%, 35.7%, 54.0% and 72.0% across zero to three corrupted passages, with the zero cell an internal control that shows no adoption at all. Abstention rises throughout. Adoption peaks in the middle of the range and falls at full corruption as refusal displaces commitment.

The comparative claim we previously published does not survive. The three corruption rules cannot be separated by fooled rate on three independent draws, and they cannot be equalised on delivered corruption either, since numeric substitution lands its full requested dose in 6% of cells. Where they do differ is adoption: substituted entities and figures are repeated at 15.2%, inserted negations at 1.1%.

The practical reading is narrower than before and, we think, more useful. Under an instruction to answer only from retrieved text, that instruction is obeyed absolutely: with off-topic context the model abstained on all 147 runs rather than using knowledge it plainly had, and with no context at all it scored higher than with clean retrieval. Evidence quality therefore sets a hard ceiling, corrupted evidence has no internal competitor, and retrieval should be justified per query set rather than assumed, because on facts a model already knows it can subtract accuracy instead of adding it. Abstention is a weaker signal than we previously suggested, since it accompanies adoption more often than not and is also what useless retrieval produces.

What this design still cannot answer is how any of it behaves on facts outside the generator’s training data, which is precisely where retrieval should earn its place, and whether model-written corruption that removes the internal inconsistencies of rule-based edits would be adopted more readily. Both are the next measurements rather than the next argument.