ChainForge: Tool-Chain Hijacking Attacks against LLM Agents via Execution-Grounded Tool Synthesis

Jiluan Fan, Haotian Zhu, Zhigang Lu, Junhao Xia, Xunzhu Tang, Shuchao Pang, Jason XueNeurIPS 2026

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.

Figure 1: Overview of CHAINFORGE. Phase I uses reference execution logs to select a feasible chain length and iteratively optimize a grounded metadata-level tool chain through rollout feedback, contrastive examples, and failure-aware critiques. Phase II converts the optimized chain into exe- cutable tools that preserve benign utility while embedding adversarial payloads, and refines the code with MCIR for stealthy, semantically consistent instantiation.
  • 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 filter drops 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%.
Figure 2: CHAINFORGE remains effective and utility-preserving against existing runtime defenses. Points on the Pareto frontier of utility-robustness are in bold.

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

Abstract

LLM-based agents increasingly rely on external tools to accomplish complex tasks, yet the security of tool-calling pipelines remains poorly understood at the chain level. Prior attacks target individual tool invocations through prompt injection or metadata manipulation, but compromising a single step in a multi-step workflow is conspicuous and rarely sufficient for complex adversarial objectives. In this work, we uncover a more insidious yet realistic attack surface, tool-chain hijacking, in which an adversary constructs a coherent sequence of tools that collectively replace the agent's intended execution trace while still completing the user's task correctly, rendering the hijack invisible to both the agent and the user. To operationalize this threat, we propose ChainForge, an execution-grounded framework that mines agent execution logs to synthesize replacement chains through rollout-based optimization, then embeds adversarial payloads into the chain's code via multi-criteria iterative refinement. To systematically evaluate chain-level threats, we further construct ChainBench, a benchmark of 97 tasks across 4 domains. Experiments on four frontier LLMs show that ChainForge achieves a trace hijack rate of up to 98.54\%, maintains task utility above 80.41\%, transfers across models with up to 84.95\% success, and achieves high attack success rates under the evaluated defenses and code-safety scanners, exposing a critical blind spot in current agent security. Our artifacts are available at \url{https://github.com/larryfans/ChainForge}.
BibTeX
@inproceedings{fan2026chainforge,
  author = {Jiluan Fan and Haotian Zhu and Zhigang Lu and Junhao Xia and Xunzhu Tang and Shuchao Pang and Jason Xue},
  title = {{ChainForge: Tool-Chain Hijacking Attacks against LLM Agents via Execution-Grounded Tool Synthesis}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=K070HFaYyp},
}
Figure