AttnTrace: A context attribution method for prompt injection and knowledge poisoningAttnTrace: Contextual Attribution of Prompt Injection and Knowledge Corruption
Researchers propose AttnTrace, a context attribution method based on large language model attention weights, for tracing prompt injection and knowledge poisoning scenarios and locating the context text that contributes most to model responses. The method targets RAG pipelines and agents supported by long-context models such as Gemini-2.5-Pro and Claude-Sonnet-4; the authors introduce two techniques to enhance effectiveness and provide theoretical analysis. Addressing the problem that existing methods such as TracLLM require hundreds of seconds to trace a single response-context pair, the authors' systematic evaluation shows AttnTrace is more accurate and more efficient. Through an attribution-before-detection paradigm, it can also improve existing methods' prompt injection detection under long contexts; in a real case demonstrated by the authors, AttnTrace effectively located injected instructions in a paper designed to manipulate an LLM into generating reviews. Code open-sourced at https://github.com/Wang-Yanting/AttnTrace。