ICON: Indirect Prompt Injection Defense for Agents based on Inference-Time Correction
Organizations: School of Computer Science, Peking University, China · College of Computing and Data Science, Nanyang Technological University, Singapore · Ant Group · Alibaba
Abstract
Large Language Model (LLM) agents are susceptible to Indirect Prompt Injection (IPI) attacks, where malicious instructions in retrieved content hijack the agent's execution. Existing defenses typically rely on strict filtering or refusal mechanisms, which suffer from a critical limitation: over-refusal, prematurely terminating valid agentic workflows. We propose ICON, a probing-to-mitigation framework that neutralizes attacks while preserving task continuity. Our key insight is that IPI attacks leave distinct over-focusing signatures in the latent space. We introduce a Latent Space Trace Prober to detect attacks based on high intensity scores. Subsequently, a Mitigating Rectifier performs surgical attention steering that selectively manipulate adversarial query key dependencies while amplifying task relevant elements to restore the LLM's functional trajectory. Extensive evaluations on multiple backbones show that ICON achieves a competitive 0.4% ASR, matching commercial grade detectors, while yielding a over 50% task utility gain. Furthermore, ICON demonstrates robust Out of Distribution(OOD) generalization and extends effectively to multi-modal agents, establishing a superior balance between security and efficiency.
Figures & tables
| Functionality | Template | Tool-Filter | Fine-tuning | ICON |
| Security | ✗ | ✗ | ✓ | ✓ |
| Utility | ✗ | ✗ | ✗ | ✓ |
| Efficiency | ✓ | ✓ | ✗ | ✓ |
| FMs | BU | Attack | No Defense | Repeat Prompt | Delimiting | MELON | LLM-Detector | ICON (Ours) | ||||||
| ASR | UA | ASR | UA | ASR | UA | ASR | UA | ASR | UA | ASR | UA | |||
| Qwen-3-8B | 69.8 | Ignore Instruction | 25.0 | 49.7 | 11.7 | 54.2 | 15.3 | 52.9 | 1.3 | 48.7 | 0.0 | 47.2 | 0.0 | 58.2 |
| Combined Attacks | 30.3 | 44.2 | 13.2 | 53.1 | 18.4 | 50.2 | 2.4 | 45.5 | 0.0 | 43.8 | 0.0 | 52.7 | ||
| TrojanTools | 42.7 | 35.3 | 25.4 | 45.6 | 31.8 | 43.7 | 5.8 | 36.8 | 0.6 | 38.6 | 1.2 | 50.5 | ||
| Avg | 32.7 | 43.1 | 16.8 | 51.0 | 21.8 | 48.9 | 3.2 | 43.7 | 0.2 | 43.2 | 0.4 | 53.8 | ||
| LLaMA-3.1-8B | 34.5 | Ignore Instruction | 23.4 | 25.7 | 14.6 | 30.1 | 16.8 | 28.1 | 0.6 | 26.1 | 0.0 | 25.2 | 0.0 | 32.6 |
| Model | Metric | InjectAgent | AgentDojo | ||
| No Def. | ICON (Ours) | No Def. | ICON (Ours) | ||
| Qwen-3-8B | ADR | 0% | 80.1% 1.9 | 0% | 98.0% 1.2 |
| URR | 0% | 62.3% 2.3 | 0% | 69.6% 2.7 | |
| LLaMA-3.1-8B | ADR | 0% | 85.4% 1.3 | 0% | 97.3% 1.8 |
| URR | 0% | 47.6% 3.1 | 0% | 55.9% 3.3 | |
| Method | Training Cost | Dataset Size | Parameters |
| Qwen3Guard | Over 10 hours | 1.19M | 8B |
| MELON | 0 | 0 | 0 |
| Repeat Prompt | 0 | 0 | 0 |
| ICON (Ours) | Less than 2 mins | 255 | 31553 |
| FMs | BU | No Def. | Repeat | LLM-Det. | Ours | ||||
| ASR | UA | ASR | UA | ASR | UA | ASR | UA | ||
| Qwen3VL | 70.5 | 69.9 | 21.3 | 47.8 | 46.5 | 0.0 | 21.9 | 3.8 | 44.9 |
| InternVL | 64.5 | 47.4 | 33.9 | 41.6 | 26.5 | 0.0 | 34.1 | 2.6 | 47.8 |
| MiniCPM | 72.0 | 59.7 | 29.0 | 59.6 | 22.0 | 0.0 | 30.3 | 2.4 | 48.8 |
| Avg | 69.0 | 59.0 | 28.1 | 49.7 | 31.7 | 0.0 | 28.8 | 2.9 | 47.2 |