TL;DR
Imagine asking an AI agent to fetch a security code from your email and text it to a colleague. ChainForge shows how an attacker can plant a sequence of disguised, third-party tools that completely replace the agent's entire multi-step workflow—doing your exact task flawlessly while silently copying your data to an external server, slipping right past both runtime defenses and industrial code scanners.
What Problem Does This Paper Address?
Modern LLM agents don't work alone; they pull external tools from open marketplaces (like Glama or Smithery) to read emails, book flights, or transfer money. Previously, security researchers looked at how attackers could trick an agent into calling a single malicious tool using prompt injection or attractive tool descriptions.
However, real-world tasks take multiple steps. If an attacker just drops a handful of independently optimized malicious tools into an ecosystem, the attack falls apart. Even if an agent has an 80% chance of picking a malicious tool at step one, the probability of staying on the attacker's path across five steps plummets exponentially ($0.8^5 \approx 33\%$). Meanwhile, current agent defenses suffer from this exact same "single-step myopia"—they check if individual tool inputs, outputs, or permissions look safe, completely missing whether a chain of seemingly benign tools secretly composes into an end-to-end hijack.
Methods
To overcome exponential decay across multi-step workflows, the authors introduce ChainForge, an automated two-phase synthesis framework that builds executable, cohesive tool chains rather than isolated traps.
- Phase I: Chain-Level Hijack Optimization. Grounded in how agents naturally decompose tasks (via execution logs or public tool schemas), ChainForge first probes for the shortest feasible chain length ($K^*$). It then uses a population-based iterative search with rollout feedback to co-design the entire sequence's names, descriptions, and staged outputs. By critiquing moments where the agent falls back to legitimate tools, it aligns the tool chain's narrative with the LLM's internal logic. Once the agent takes the first bite, "semantic momentum" makes the rest of the attacker's chain the path of least resistance.
- Phase II: Stealthy Code Instantiation & Refinement. Metadata alone doesn't run code. Phase II synthesizes actual Python implementations that fulfill the user's real task while embedding the hidden malicious payload. Using Multi-Criteria Iterative Refinement (MCIR), an LLM-guided loop polishes the code so it avoids suspicious regex patterns, utilizes all declared parameters (no dummy arguments), and ensures the code's logic semantically matches its docstring to fool static and LLM-based scanners.
Datasets
To test multi-step hijacking systematically, the authors built ChainBench, derived from the existing AgentDojo benchmark. ChainBench features 97 user–attack task pairs spanning four everyday domains: Banking, Travel, Slack, and Workspace. Each pair includes a benign user request, a permission-compatible malicious side objective, and ground-truth execution traces.
Key Insights and Ideas
- Semantic Momentum Neutralizes Decay: When tools are co-designed as a unified narrative rather than standalone lures, longer chains don't fall apart—hijack success actually stays remarkably stable because each tool's output naturally sets up the next malicious tool as the obvious choice.
- The Runtime Defense Blind Spot: Most current agent defenses monitor observable artifacts (prompts, arguments, return values). Because ChainForge tools genuinely complete the user's task with clean inputs and outputs while hiding side effects inside the tool's internal execution, runtime monitors think everything is fine.
- No Victim Logs Required: Even when the attacker has zero access to the victim's execution logs or probing environment—relying strictly on public tool schemas and the target task—the attack still reliably hijacks workflows.
Key Results
Evaluated across four frontier models (GPT-5.4, Gemini-3.1-Pro-Preview, Claude-Sonnet-4.6, and DeepSeek-V4-Pro), ChainForge demonstrates alarming effectiveness:
- Near-Total Trace Hijacking: Achieves a Trace Hijack Success Rate (TSR) of 98.54% on GPT-5.4, 90.00% on Claude, 88.13% on Gemini, and 74.58% on DeepSeek—crushing sequential adaptations of prior single-tool baselines (e.g., Chord-Chain averages just 12.2% across models).
- Cross-Model Transferability: Chains optimized on one LLM transfer cleanly to others, reaching up to 84.95% TSR when transferring to GPT-5.4.
- Defense & Scanner Evasion: Six out of seven runtime defenses (including MELON, DRIFT, and Progent) leave ChainForge with an Attack Success Rate above 83% while preserving user task utility above 80.41%. Only restrictive
Tool filterdrops ASR (to 39.3%), at the cost of tanking benign utility to 47.1%. Meanwhile, refined tool code evades four industrial scanners (VirusTotal, AntGroup MCPScan, Tencent A.I.G, and Cisco MCP Scanner) at rates between 78.35% and 100%.
Limitations and Future Work
ChainForge operates under a supply-chain threat model where the attacker is a task-aware third-party publisher: it assumes the target workflow and benign tool pool are known, and requires users or administrators to install the tools with approved permissions. Furthermore, cross-model transferability is notably weaker against DeepSeek-V4-Pro (~48% TSR) compared to other frontier models. Moving forward, the authors emphasize that securing autonomous agents will require shifting from isolated, single-invocation checks to chain-aware defense mechanisms capable of verifying internal tool side effects across full execution traces.
Summary updated