Abstract
As Large Language Models (LLMs) transition into autonomous agents capable of interacting with external resources, they become vulnerable to Indirect Prompt Injection (IPI) attacks. We present RENNERVATE, a novel defense framework that leverages the internal attention mechanisms of LLMs to detect and neutralize these threats. By analyzing attention features at a fine-grained token level, RENNERVATE can surgically sanitize external data, removing malicious instructions while maintaining the utility of the retrieved information. Our evaluation shows that RENNERVATE achieves over 97% detection accuracy and reduces attack success rates to near zero across multiple state-of-the-art LLMs.
Introduction
The integration of LLMs into applications that browse the web or process documents has introduced a significant security challenge: Indirect Prompt Injection (IPI). In an IPI attack, an adversary embeds malicious instructions within external content. When the LLM retrieves this content, it may prioritize the injected instructions over the user's original intent, leading to data exfiltration, phishing, or unauthorized actions.
Current defenses typically rely on external guardrails or auxiliary models. These methods are often computationally expensive, slow, and struggle to identify "stealthy" attacks that avoid common trigger words. Moreover, most existing solutions are binary, either blocking the entire data source or allowing the attack to proceed.
Methodology: The RENNERVATE Framework
RENNERVATE operates on the principle that an LLM processes instructions differently than plain data, and this difference is reflected in its internal attention maps. The framework consists of three primary components:
1. Token-Level Detector
Instead of analyzing the document as a whole, RENNERVATE monitors the attention weights of every token during inference. It employs a two-step attentive pooling mechanism:
- Response-Wise (Resp-Wise) Pooling: Aggregates features across the initial generated tokens to capture the model's immediate reaction to the input.
- Head-Wise Pooling: Aggregates information across different attention heads, identifying specific heads that are more sensitive to instruction-following behaviors.
2. Injection Identifier
The framework uses a mean filter to detect clusters of tokens flagged as suspicious. If a sequence of tokens identified as "injected" exceeds a predefined length threshold, the input is formally flagged as a potential attack.
3. Injection Sanitizer
Unlike traditional "all-or-nothing" firewalls, RENNERVATE performs surgical sanitization. Once the malicious tokens are localized, they are removed from the input sequence. The LLM then re-processes the "purified" text, ensuring the user receives the requested information without the security risk.
Data and Evaluation
To evaluate RENNERVATE, we developed the FIPI (Fine-grained IPI) dataset, containing 100,000 injected and 10,000 benign instances across 300 NLP tasks. FIPI provides character-level and token-level labels, covering diverse attack vectors such as escape characters and fake completions.
RENNERVATE was tested against 15 baselines using five major LLMs (including LLaMA3 and Falcon). Key results include:
- High Detection Accuracy: Achieved 97-99% accuracy, outperforming specialized tools like Prompt-Guard.
- Effective Mitigation: Reduced the Attack Success Rate (ASR) from approximately 85% to near 0%.
- Utility Preservation: Benchmarking with AlpacaEval 2.0 confirmed that sanitization has a negligible impact on the model's performance on the original task.
Discussion and Insights
The core insight of this work is that internal attention is a robust security signal. Even when attackers use sophisticated language to hide their intent, the way the LLM's internal state "latches onto" those tokens as instructions remains detectable. Furthermore, the defense is "plug-and-play," requiring no fine-tuning of the base model, and demonstrates high transferability across different attack styles.
Conclusion
RENNERVATE represents a shift from external monitoring to internal behavioral analysis for LLM security. While it currently requires access to internal attention weights (white-box access), it provides a highly effective and efficient defense for open-source models and platform providers. Future work will explore extending this attentive defense to multi-modal environments where IPI attacks are increasingly prevalent.
Summary updated