← Latest papers
💻 computer science

When Context Bites: Detecting RAG Poisoning via Document-Level Attention Collapse

This paper introduces D-SCAN, a lightweight detection framework that identifies RAG poisoning attacks by monitoring document-level attention collapse, a distinctive signature where attention entropy decreases as the model focuses on adversarial documents, overcoming the limitations of existing output-side detection methods.

Original authors: Yingtao Ren, Ziyi Zhao, Yiwei Fu, Xiao Luo, Yu-Cheng Chang, Chin-Teng Lin

Published 2026-08-19
📖 4 min read☕ Coffee break read

Original authors: Yingtao Ren, Ziyi Zhao, Yiwei Fu, Xiao Luo, Yu-Cheng Chang, Chin-Teng Lin

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

In the modern landscape of artificial intelligence, large language models act as vast libraries of human knowledge, capable of answering questions and generating text with startling fluency. However, these models have a blind spot: they do not inherently know the latest facts or specific details about the world unless they are told. To fix this, developers use a system called retrieval-augmented generation. Think of this process as a student taking an open-book test; the computer first searches a database for relevant documents, feeds them to the model, and then asks the model to write an answer based on that new information. This method allows the machine to access up-to-date facts, but it also opens a door for trouble. If an attacker slips a carefully crafted, false document into that database, the model might read it, believe it, and use it to construct a harmful or incorrect answer. This is known as a poisoning attack, and it poses a serious risk in high-stakes fields like law and medicine, where a single wrong fact could have real-world consequences.

For a long time, researchers trying to catch these attacks looked at the final answer the computer produced. They hoped to spot the lie by checking if the answer sounded unsure or if it contradicted itself. The prevailing idea was that when a model is confused or hallucinating, it would sound hesitant, like a person guessing. However, a team of researchers from the University of Technology Sydney and Peking University discovered that this assumption is dangerously wrong. They found that when a model is successfully tricked by a poisoned document, it does not sound confused at all. Instead, it sounds more confident than usual. The attackers design their fake documents so perfectly that the model becomes "blindly confident," assigning a higher probability to the wrong answer than it ever would to a correct one. This means that traditional methods, which rely on detecting uncertainty or inconsistency, are often useless because the model is not uncertain; it is convinced it is right.

To solve this, the researchers stopped looking at the final text and started looking inside the machine's brain while it was thinking. They examined how the model paid attention to the different documents it was reading. In a normal, healthy reading session, a model spreads its attention across several documents, weighing the evidence from each one to build a complete picture. The researchers found that when a poisoning attack occurs, this behavior changes drastically. The model stops looking at the other documents and focuses almost entirely on the single poisoned file. They call this phenomenon "attention collapse." It is as if the model's gaze is hijacked, locking onto the malicious information and ignoring everything else. This happens even if the attack fails to change the final answer, making it a reliable early warning sign that something is wrong.

Based on this discovery, the team built a new detection tool called D-SCAN. This system is designed to be lightweight and fast, monitoring the internal attention patterns of the model as it works. Instead of waiting to see if the final answer is wrong, D-SCAN watches for that specific moment when the model's focus collapses onto a single document. In their tests, the researchers used three different sets of complex questions and found that their new method was far better at spotting attacks than any existing technology. While other tools struggled to tell the difference between a real answer and a fake one, D-SCAN consistently identified the poisoning attempts. Perhaps most importantly, the tool worked even when the attack did not succeed in changing the final output. This suggests that the act of the model being hijacked is a distinct signature that exists independently of the final result.

The study also revealed a surprising detail about the size of the models themselves. One might assume that a larger, more powerful computer would be better at spotting a trick, but the researchers found the opposite. Smaller models were actually better at detecting the poison, while the largest models seemed more easily fooled. This suggests that the very training that makes these large models follow instructions so well might also make them too trusting of the documents they are given. By focusing on the internal mechanics of how attention is distributed rather than the surface-level text, the researchers have provided a new way to secure these systems. Their work shows that to protect artificial intelligence, we must understand not just what it says, but how it thinks.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →