AttnTrace: Contextual Attribution of Prompt Injection and Knowledge Corruption
On the map: Retrieval-augmented generation → Privacy and security of RAG
also in 1 more
Abstract (arXiv)
Long-context large language models (LLMs), such as Gemini-2.5-Pro and Claude-Sonnet-4, are increasingly used to empower advanced AI systems, including retrieval-augmented generation (RAG) pipelines and autonomous agents. In these systems, an LLM receives an instruction along with a context--often consisting of texts retrieved from a knowledge database or memory--and generates a response that is contextually grounded by following the instruction. Recent studies have designed solutions to trace back to a subset of texts in the context that contributes most to the response generated by the LLM. These solutions have numerous real-world applications, including performing post-attack forensic analysis and improving the interpretability and trustworthiness of LLM outputs. While significant efforts have been made, state-of-the-art solutions such as TracLLM often lead to a high computation cost, e.g., it takes TracLLM hundreds of seconds to perform traceback for a single response-context pair. In this work, we propose AttnTrace, a new context traceback method based on the attention weights produced by an LLM for a prompt. To effectively utilize attention weights, we introduce two techniques designed to enhance the effectiveness of AttnTrace, and we provide theoretical insights for our design choice. We also perform a systematic evaluation for AttnTrace. The results demonstrate that AttnTrace is more accurate and efficient than existing state-of-the-art context traceback methods. We also show that AttnTrace can improve state-of-the-art methods in detecting prompt injection under long contexts through the attribution-before-detection paradigm. As a real-world application, we demonstrate that AttnTrace can effectively pinpoint injected instructions in a paper designed to manipulate LLM-generated reviews. The code is at https://github.com/Wang-Yanting/AttnTrace.
Key facts. Cited by 7 papers in the map (data through 14 Oct 2026). Placed in Privacy and security of RAG, one of 15 directions in Retrieval-augmented generation. Builds on 69 of its 97 references that are in the map. First posted on arXiv 5 Aug 2025.
Builds on
69 of 97 references.
Closest ancestors · 6
Same direction, newest first
- 2025Traceback of Poisoning Attacks to Retrieval-Augmented Generation30 Apr
- 2024Machine Against the RAG: Jamming Retrieval-Augmented Generation with Blocker Documents9 Jun
- 2024BadRAG: Identifying Vulnerabilities in Retrieval Augmented Generation of Large Language Models3 Jun
- 2024Certifiably Robust RAG against Retrieval Corruption24 May
- 2024TrojanRAG: Retrieval-Augmented Generation Can Be Backdoor Driver in Large Language Models22 May
- 2024PoisonedRAG: Knowledge Corruption Attacks to Retrieval-Augmented Generation of Large Language Models12 Feb
Other references · 63
- 2017Attention Is All You Needcited by 60,361
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,297
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,695
- 2017A Unified Approach to Interpreting Model Predictionscited by 6,555
- 2016"Why Should I Trust You?": Explaining the Predictions of Any Classifiercited by 5,070
- 2020Dense Passage Retrieval for Open-Domain Question Answeringcited by 3,824
- 2018HotpotQA: A Dataset for Diverse, Explainable Multi-hop Question Answeringcited by 3,754
- 2017Axiomatic Attribution for Deep Networkscited by 3,384
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 3,104
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
- 2013Deep Inside Convolutional Networks: Visualising Image Classification Models and Saliency Mapscited by 2,371
38 more
- 2023Efficient Streaming Language Models with Attention Sinkscited by 2,186
- 2021WebGPT: Browser-assisted question-answering with human feedbackcited by 1,745
- 2016MS MARCO: A Human Generated MAchine Reading COmprehension Datasetcited by 1,605
- 2017Learning Important Features Through Propagating Activation Differencescited by 1,458
- 2023Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injectioncited by 1,443
- 2023LongBench: A Bilingual, Multitask Benchmark for Long Context Understandingcited by 1,417
- 2023FActScore: Fine-grained Atomic Evaluation of Factual Precision in Long Form Text Generationcited by 1,282
- 2021MuSiQue: Multihop Questions via Single-hop Question Compositioncited by 916
- 2018RISE: Randomized Input Sampling for Explanation of Black-box Modelscited by 838
- 2022Ignore Previous Prompt: Attack Techniques For Language Modelscited by 832
- 2023H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Modelscited by 832
- 2023AutoDAN: Generating Stealthy Jailbreak Prompts on Aligned Large Language Modelscited by 785
- 2019Attention is not not Explanationcited by 636
- 2017The NarrativeQA Reading Comprehension Challengecited by 597
- 2023Enabling Large Language Models to Generate Text with Citationscited by 595
- 2020Estimating Training Data Influence by Tracing Gradient Descentcited by 580
- 2024The Instruction Hierarchy: Training LLMs to Prioritize Privileged Instructionscited by 493
- 2024AgentPoison: Red-teaming LLM Agents via Poisoning Memory or Knowledge Basescited by 429
- 2019Is Attention Interpretable?cited by 389
- 2024StruQ: Defending Against Prompt Injection with Structured Queriescited by 375
- 2021QMSum: A New Benchmark for Query-based Multi-domain Meeting Summarizationcited by 365
- 2023Formalizing and Benchmarking Prompt Injection Attacks and Defensescited by 364
- 2025Defeating Prompt Injections by Designcited by 297
- 2023Exploiting Programmatic Behavior of LLMs: Dual-Use Through Standard Security Attackscited by 278
- 2020Explaining by Removing: A Unified Framework for Model Explanationcited by 218
- 2024SecAlign: Defending Against Prompt Injection with Preference Optimizationcited by 210
- 2023Poisoning Retrieval Corpora by Injecting Adversarial Passagescited by 159
- 2025DataSentinel: A Game-Theoretic Detection of Prompt Injection Attackscited by 143
- 2024Leave No Document Behind: Benchmarking Long-Context LLMs with Extended Multi-Doc QAcited by 122
- 2025Securing AI Agents with Information-Flow Controlcited by 121
- 2024Automatic and Universal Prompt Injection Attacks against Large Language Modelscited by 119
- 2023Jatmo: Prompt Injection Defense by Task-Specific Finetuningcited by 106
- 2024The Task Shield: Enforcing Task Alignment to Defend Against Indirect Prompt Injection in LLM Agentscited by 99
- 2024ContextCite: Attributing Model Generation to Contextcited by 98
- 2024System-Level Defense against Indirect Prompt Injection Attacks: An Information Flow Control Perspectivecited by 96
- 2024Attention Tracker: Detecting Prompt Injection Attacks in LLMscited by 95
- 2024Neural Exec: Learning (and Learning from) Execution Triggers for Prompt Injection Attackscited by 85
- 2024BadChain: Backdoor Chain-of-Thought Prompting for Large Language Modelscited by 80
50 most cited of 63 All 63 (JSON)
Built on by
Citing papers per year: 2026: 7.
7 papers.
- 2026What Guides the Agent? Adjudicating Unauthorized Behavior via Localizing Behavior-Guiding Instructionscited by 1
- 2026Retrieved But Not Reliable: A Survey on Attacks, and Defenses in Retrieval-Augmented Generationcited by 1
- 2026Influence Is Not Authority: When Causal Guardrail Signals Make Legitimate Tool Use Look Like an Attack in Tool-Using LLM Agentscited by 1
- 2026Tokengeist: Multi-Turn Attribution Tracing in Agentic Conversationscited by 0
- 2026Verification as an Architectural Layer for LLM Agents: A V-Model Design, and a Pilot Study of Its Deterministic Corecited by 0
- 2026Test-Time Memory Constructioncited by 0
- 2026What the Model Cannot See: Covert and Provable Text Invisibility in LLMscited by 0
- 2026What the Model Cannot See: Covert and Provable Text Invisibility in LLMs11 Oct 2026
- 2026Test-Time Memory Construction9 Oct 2026
- 2026Verification as an Architectural Layer for LLM Agents: A V-Model Design, and a Pilot Study of Its Deterministic Core25 Sep 2026
- 2026Influence Is Not Authority: When Causal Guardrail Signals Make Legitimate Tool Use Look Like an Attack in Tool-Using LLM Agents30 Aug 2026
- 2026Retrieved But Not Reliable: A Survey on Attacks, and Defenses in Retrieval-Augmented Generation25 Aug 2026
- 2026What Guides the Agent? Adjudicating Unauthorized Behavior via Localizing Behavior-Guiding Instructions25 Aug 2026
- 2026Tokengeist: Multi-Turn Attribution Tracing in Agentic Conversations14 Jun 2026
Similar, not cited
Close in wording, no citation either way
- 2025TracLLM: A Generic Framework for Attributing Long Context LLMs
- 2025Learning to Extract Context for Context-Aware LLM Inference
- 2025Where Did It Go Wrong? Attributing Undesirable LLM Behaviors via Representation Gradient Tracing
- 2025SAFE: Improving LLM Systems using Sentence-Level In-generation Attribution
- 2026FlashRT: Towards Computationally and Memory Efficient Red-Teaming for Prompt Injection and Knowledge Corruption
- 2026ARGUS: Defending LLM Agents Against Context-Aware Prompt Injection
- 2026Probing for Knowledge Attribution in Large Language Models
- 2026AttnDiff: Attention-based Differential Fingerprinting for Large Language Models