Automating Agent Hijacking via Structural Template Injection
On the map: LLM agents and tool use → Agent threats, guardrails and governance
Abstract (arXiv)
Agent hijacking, highlighted by OWASP as a critical threat to the Large Language Model (LLM) ecosystem, enables adversaries to manipulate execution by injecting malicious instructions into retrieved content. Most existing attacks rely on manually crafted, semantics-driven prompt manipulation, which often yields low attack success rates and limited transferability to closed-source commercial models. In this paper, we propose Phantom, an automated agent hijacking framework built upon Structured Template Injection that targets the fundamental architectural mechanisms of LLM agents. Our key insight is that agents rely on specific chat template tokens to separate system, user, assistant, and tool instructions. By injecting optimized structured templates into the retrieved context, we induce role confusion and cause the agent to misinterpret the injected content as legitimate user instructions or prior tool outputs. To enhance attack transferability against black-box agents, Phantom introduces a novel attack template search framework. We first perform multi-level template augmentation to increase structural diversity and then train a Template Autoencoder (TAE) to embed discrete templates into a continuous, searchable latent space. Subsequently, we apply Bayesian optimization to efficiently identify optimal adversarial vectors that are decoded into high-potency structured templates. Extensive experiments on Qwen, GPT, and Gemini demonstrate that our framework significantly outperforms existing baselines in both Attack Success Rate (ASR) and query efficiency. Moreover, we identified over 70 vulnerabilities in real-world commercial products that have been confirmed by vendors, underscoring the practical severity of structured template-based hijacking and providing an empirical foundation for securing next-generation agentic systems.
Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Placed in Agent threats, guardrails and governance, one of 16 directions in LLM agents and tool use. Builds on 23 of its 43 references that are in the map. First posted on arXiv 18 Feb 2026.
Builds on
23 of 43 references.
Closest ancestors · 3
Same direction, newest first
- 2025ChatInject: Abusing Chat Templates for Prompt Injection in LLM Agents26 Sep
- 2025Adaptive Attacks Break Defenses Against Indirect Prompt Injection Attacks on LLM Agents27 Feb
- 2024Agent Security Bench (ASB): Formalizing and Benchmarking Attacks and Defenses in LLM-based Agents3 Oct
Other references · 20
- 2022Training language models to follow instructions with human feedbackcited by 15,712
- 2023Qwen Technical Reportcited by 3,273
- 2022Constitutional AI: Harmlessness from AI Feedbackcited by 2,950
- 2023Jailbroken: How Does LLM Safety Training Fail?cited by 1,565
- 2023The Rise and Potential of Large Language Model Based Agents: A Surveycited by 1,422
- 2022Ignore Previous Prompt: Attack Techniques For Language Modelscited by 760
- 2018A Tutorial on Bayesian Optimizationcited by 734
- 2024StruQ: Defending Against Prompt Injection with Structured Queriescited by 325
- 2023Visual Adversarial Examples Jailbreak Aligned Large Language Modelscited by 307
- 2023Exploiting Programmatic Behavior of LLMs: Dual-Use Through Standard Security Attackscited by 268
- 2023Benchmarking and Defending Against Indirect Prompt Injection Attacks on Large Language Modelscited by 237
- 2024Defending Against Indirect Prompt Injection Attacks With Spotlightingcited by 233
8 more
- 2023On the Robustness of ChatGPT: An Adversarial and Out-of-distribution Perspectivecited by 208
- 2024SecAlign: Defending Against Prompt Injection with Preference Optimizationcited by 179
- 2023Tensor Trust: Interpretable Prompt Injection Attacks from an Online Gamecited by 135
- 2025DataSentinel: A Game-Theoretic Detection of Prompt Injection Attackscited by 124
- 2023Identifying and Mitigating Vulnerabilities in LLM-Integrated Applicationscited by 54
- 2023Assessing Prompt Injection Risks in 200+ Custom GPTscited by 49
- 2024ChatBug: A Common Vulnerability of Aligned LLMs Induced by Chat Templatescited by 29
- 2025AgentBay: A Hybrid Interaction Sandbox for Seamless Human-AI Intervention in Agentic Systemscited by 5
Built on by
Citing papers per year: 2026: 6.
6 papers.
- 2026Taming OpenClaw: Security Analysis and Mitigation of Autonomous LLM Agent Threatscited by 25
- 2026Safety in Self-Evolving LLM Agent Systems: Threats, Amplification, and Case Studiescited by 6
- 2026Security of OpenClaw Agents: Fundamentals, Attacks, and Countermeasurescited by 1
- 2026Provably Secure Agent Guardrailcited by 0
- 2026Control-Token Injection Suppresses Chain-of-Thought and Defeats Reasoning-Based Oversight in Tool-Using Agentscited by 0
- 2026Same Bytes, Different Authority: Reserved-Token Representations in Chat-Template Prompt Injectioncited by 0
- 2026Same Bytes, Different Authority: Reserved-Token Representations in Chat-Template Prompt Injection28 Sep 2026
- 2026Control-Token Injection Suppresses Chain-of-Thought and Defeats Reasoning-Based Oversight in Tool-Using Agents23 Sep 2026
- 2026Safety in Self-Evolving LLM Agent Systems: Threats, Amplification, and Case Studies22 Jun 2026
- 2026Provably Secure Agent Guardrail28 May 2026
- 2026Security of OpenClaw Agents: Fundamentals, Attacks, and Countermeasures25 May 2026
- 2026Taming OpenClaw: Security Analysis and Mitigation of Autonomous LLM Agent Threats12 Mar 2026
Similar, not cited
Close in wording, no citation either way
- 2025AgentVigil: Generic Black-Box Red-teaming for Indirect Prompt Injection against LLM Agents
- 2026AgentDrift: A Step-Labeled Benchmark of Injection-Hijacked LLM Agent Trajectories
- 2026The Landscape of Prompt Injection Threats in LLM Agents: From Taxonomy to Analysis
- 2026AutoRISE: Agent-Driven Strategy Evolution for Red-Teaming Large Language Models
- 2025A Multi-Agent LLM Defense Pipeline Against Prompt Injection Attacks
- 2026Toward Secure LLM Agents: Threat Surfaces, Attacks, Defenses, and Evaluation
- 2024Imprompter: Tricking LLM Agents into Improper Tool Use
- 2026Beyond Direct Access: Resource Hijacking in LLM Agents