Our new X account is live! Follow @wizwand_team for updates
WorkDL logo mark

MELON: Provable Defense Against Indirect Prompt Injection Attacks in AI Agents

About

Recent research has explored that LLM agents are vulnerable to indirect prompt injection (IPI) attacks, where malicious tasks embedded in tool-retrieved information can redirect the agent to take unauthorized actions. Existing defenses against IPI have significant limitations: either require essential model training resources, lack effectiveness against sophisticated attacks, or harm the normal utilities. We present MELON (Masked re-Execution and TooL comparisON), a novel IPI defense. Our approach builds on the observation that under a successful attack, the agent's next action becomes less dependent on user tasks and more on malicious tasks. Following this, we design MELON to detect attacks by re-executing the agent's trajectory with a masked user prompt modified through a masking function. We identify an attack if the actions generated in the original and masked executions are similar. We also include three key designs to reduce the potential false positives and false negatives. Extensive evaluation on the IPI benchmark AgentDojo demonstrates that MELON outperforms SOTA defenses in both attack prevention and utility preservation. Moreover, we show that combining MELON with a SOTA prompt augmentation defense (denoted as MELON-Aug) further improves its performance. We also conduct a detailed ablation study to validate our key designs. Code is available at https://github.com/kaijiezhu11/MELON.

Kaijie Zhu, Xianjun Yang, Jindong Wang, Wenbo Guo, William Yang Wang• 2025

Related benchmarks

TaskDatasetResultRank
Prompt Injection DefenseAgentDojo No Attack
Benign Utility74.29
23
Prompt Injection DefenseAgentDojo Important Instructions
Utility under Attack0.4141
23
Prompt Injection DefenseAgentDojo New Attack 1
Utility under Attack41.84
23
Prompt Injection DefenseAgentDojo New Attack 2
Utility under Attack (UA)42.47
23
Indirect Prompt Injection DefenseIgnore Instruction
ASR0.2
18
Indirect Prompt Injection DefenseCombined Attacks
ASR0.5
18
Indirect Prompt Injection DefenseTrojanTools
ASR5.8
18
Tool-use agent security evaluationSIREN
Explicit Directive (UA)8.62
16
Indirect Prompt InjectionAgentDojo
Benign Utility57.61
12
Agentic Prompt Injection DefenseAgentDojo (test)
ASR (Direct)0.00e+0
6
Showing 10 of 12 rows

Other info

Follow for update