Prompt Injection Attack to Tool Selection in LLM Agents
Jiawen Shi, Zenghui Yuan, Guiyao Tie, Pan Zhou, Neil Gong, Lichao Sun · 2026 · 250 citationsRead the paper
Tool selection is a key component of LLM agents.A popular approach follows a two-step processretrieval and selection -to pick the most appropriate tool from a tool library for a given task.In this work, we introduce ToolHijacker, a novel prompt injection attack targeting tool selection in no-box scenarios.ToolHijacker injects a malicious tool document into the tool library to manipulate the LLM agent's tool selection process, compelling it to consistently choose the attacker's malicious tool for an attacker-chosen target task.Specifically, we formulate the crafting of such tool documents as an optimization problem and propose a two-phase optimization strategy to solve it.Our extensive experimental evaluation shows that ToolHijacker is highly effective, significantly outperforming existing manualbased and automated prompt injection attacks when applied to tool selection.Moreover, we explore various defenses, including prevention-based defenses (StruQ and SecAlign) and detectionbased defenses (known-answer detection, DataSentinel, perplexity detection, and perplexity windowed detection).Our experimental results indicate that these defenses are insufficient, highlighting the urgent need for developing new defense strategies.
What the full text shows
Shown in the lab- ToolHijacker bypasses prevention-based defenses (StruQ and SecAlign) with high Attack Success Rates (ASR). — ASR between 84.6% and 97.9% (Tested on MetaTool and ToolBench datasets using gradient-free and gradient-based attacks)
- Detection-based defenses (Known-answer and DataSentinel) fail to identify malicious tool documents. — False Negative Rates (FNR) exceeding 90% (Tested on MetaTool and ToolBench datasets)
- Perplexity-based detection (PPL) is effective against gradient-free attacks but less so against gradient-based attacks. — 100% FNR for G-Free on MetaTool; 80-90% FNR for G-Based on MetaTool/ToolBench (Tested on MetaTool and ToolBench datasets)
- Setup
- Experiments used MetaTool (10 target tasks, 100 descriptions per task) and ToolBench (larger tool library) datasets.
- How
- The authors developed ToolHijacker, a two-phase optimization strategy to craft malicious tool documents that manipulate both the retrieval and selection phases of LLM agents. They evaluated the attack using gradient-free and gradient-based methods against several prevention and detection defenses.
- Limitations
- ASR is lower on ToolBench compared to MetaTool due to the larger size of the tool library.
Summarized by Gemma 4 from the open-access full text · 28 Nov 2026. Read it