mlsanityData to 7 Oct 2026

Automating Agent Hijacking via Structural Template Injection

arXiv 2602.16958 ↗First posted 18 Feb 2026cs.AI cs.LGcited by 6

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

  1. 2025ChatInject: Abusing Chat Templates for Prompt Injection in LLM Agents26 Sep
  2. 2025Adaptive Attacks Break Defenses Against Indirect Prompt Injection Attacks on LLM Agents27 Feb
  3. 2024Agent Security Bench (ASB): Formalizing and Benchmarking Attacks and Defenses in LLM-based Agents3 Oct

Other references · 20

  1. 2022Training language models to follow instructions with human feedbackcited by 15,712
  2. 2023Qwen Technical Reportcited by 3,273
  3. 2022Constitutional AI: Harmlessness from AI Feedbackcited by 2,950
  4. 2023Jailbroken: How Does LLM Safety Training Fail?cited by 1,565
  5. 2023The Rise and Potential of Large Language Model Based Agents: A Surveycited by 1,422
  6. 2022Ignore Previous Prompt: Attack Techniques For Language Modelscited by 760
  7. 2018A Tutorial on Bayesian Optimizationcited by 734
  8. 2024StruQ: Defending Against Prompt Injection with Structured Queriescited by 325
  9. 2023Visual Adversarial Examples Jailbreak Aligned Large Language Modelscited by 307
  10. 2023Exploiting Programmatic Behavior of LLMs: Dual-Use Through Standard Security Attackscited by 268
  11. 2023Benchmarking and Defending Against Indirect Prompt Injection Attacks on Large Language Modelscited by 237
  12. 2024Defending Against Indirect Prompt Injection Attacks With Spotlightingcited by 233
8 more
  1. 2023On the Robustness of ChatGPT: An Adversarial and Out-of-distribution Perspectivecited by 208
  2. 2024SecAlign: Defending Against Prompt Injection with Preference Optimizationcited by 179
  3. 2023Tensor Trust: Interpretable Prompt Injection Attacks from an Online Gamecited by 135
  4. 2025DataSentinel: A Game-Theoretic Detection of Prompt Injection Attackscited by 124
  5. 2023Identifying and Mitigating Vulnerabilities in LLM-Integrated Applicationscited by 54
  6. 2023Assessing Prompt Injection Risks in 200+ Custom GPTscited by 49
  7. 2024ChatBug: A Common Vulnerability of Aligned LLMs Induced by Chat Templatescited by 29
  8. 2025AgentBay: A Hybrid Interaction Sandbox for Seamless Human-AI Intervention in Agentic Systemscited by 5

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2026: 6.

6 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2025AgentVigil: Generic Black-Box Red-teaming for Indirect Prompt Injection against LLM Agents
  2. 2026AgentDrift: A Step-Labeled Benchmark of Injection-Hijacked LLM Agent Trajectories
  3. 2026The Landscape of Prompt Injection Threats in LLM Agents: From Taxonomy to Analysis
  4. 2026AutoRISE: Agent-Driven Strategy Evolution for Red-Teaming Large Language Models
  5. 2025A Multi-Agent LLM Defense Pipeline Against Prompt Injection Attacks
  6. 2026Toward Secure LLM Agents: Threat Surfaces, Attacks, Defenses, and Evaluation
  7. 2024Imprompter: Tricking LLM Agents into Improper Tool Use
  8. 2026Beyond Direct Access: Resource Hijacking in LLM Agents