AI agent hijacking is an attack in which an adversary redirects an AI agent's goals, reasoning, or actions so the agent operates on the attacker's behalf while retaining its legitimate permissions and access. Unlike attacks that target the model's safety alignment, agent hijacking exploits the agent's autonomy and its ability to plan multi-step workflows, invoke tools, access data, and interact with external systems.
A hijacked agent can exfiltrate sensitive data, execute unauthorized transactions, modify infrastructure, or propagate malicious instructions to other agents, all without triggering the credential-based alerts that traditional security controls rely on.
Key Points
Legitimate Access, Malicious Intent: A hijacked agent uses its own valid credentials and permissions, making malicious actions indistinguishable from normal operations.
Multiple Entry Points: Attackers can hijack agents through indirect prompt injection, tool poisoning, memory manipulation, credential theft, or compromised agent-to-agent channels.
Operational Consequences: Successful hijacks result in actions, not just harmful text: data exfiltration, unauthorized code execution, financial transactions, or infrastructure changes.
Cascading Compromise: A single hijacked agent in a multi-agent workflow can propagate malicious instructions to every connected agent.
Persistence Through Memory: Poisoned short-term or long-term memory maintains attacker influence across multiple steps or sessions.
AI agents inherit the identity of the user or service account that deployed them. The agent inherits the full scope of those permissions but none of the human judgment that normally governs their use. A compromised employee might hesitate before exfiltrating a database. A hijacked agent will execute the same action in milliseconds if it falls within its authorized tool set, following the attacker's redirected instructions as faithfully as it would follow legitimate ones.
Traditional applications maintain a clear separation between code and data. AI agents do not. An agent retrieves content from emails, documents, web pages, databases, and tool outputs, then reasons over that content using the same language processing pipeline that interprets its operator's instructions.
An attacker who controls any piece of retrieved content can embed instructions the agent may treat as its own. This architectural gap, the inability to reliably distinguish trusted instructions from untrusted data, is what makes indirect prompt injection effective.
Enterprise deployments increasingly connect agents in multi-agent workflows where agents delegate tasks, share context, and pass results to one another. Each agent-to-agent communication channel becomes a potential attack surface. A hijacked agent does not just execute malicious actions on its own. It can inject poisoned context into downstream agents, manipulate shared memory stores, or exploit stateful communication protocols to redirect entire workflows.
Agent hijacking exploits the surfaces, i.e., the content they consume, the tools they invoke, the memory they reason from, and the channels they communicate through.
Indirect Prompt Injection: An attacker embeds malicious instructions inside content an agent will retrieve during normal operation: a web page, an email body, a document, a code comment, or a tool's response. The agent processes this content as data but interprets the embedded instructions as directives, redirecting its behavior without any direct interaction between the attacker and the agent.
Unit 42 researchers documented the first observed case of this technique being used in the wild to bypass an AI-based ad review system, demonstrating that indirect prompt injection has moved from theoretical risk to active exploitation.
Structural Template Injection: LLM-based agents rely on chat template tokens to separate system instructions, user messages, assistant responses, and tool outputs. Attackers inject crafted template tokens into retrieved content to create fake conversation history, a technique researchers call "ghost turns." The agent misinterprets the injected content as legitimate prior interactions, causing it to follow attacker-supplied instructions as if they came from its operator.
Tool and MCP Poisoning: Agents interact with external tools through protocols like the Model Context Protocol (MCP), relying on tool descriptions, metadata, and return values to decide which tools to call and how to interpret results. An attacker who controls or compromises an MCP server can manipulate tool descriptions to attract agent selection, alter return values to inject instructions, or redirect tool behavior entirely.
Memory Poisoning: Agents that maintain short-term or long-term memory store context across steps and sessions. Attackers can inject false knowledge or malicious instructions into these memory stores, either directly (if the memory system is writable) or indirectly (by feeding the agent content designed to be stored as a memory). Poisoned memories influence future decisions, tool selections, and reasoning paths.
Agent Session Smuggling: In multi-agent systems using stateful communication protocols like Agent2Agent (A2A), a compromised agent can exploit session state to inject covert instructions between legitimate messages. Unlike stateless tool invocations, A2A sessions maintain conversation history, allowing a malicious agent to poison the shared context and redirect the victim agent's behavior.
Credential Compromise: The most direct path to agent hijacking bypasses the agent's reasoning entirely. If an attacker obtains the credentials an agent uses to authenticate with its tools and data sources, they gain the same autonomous access the agent holds. Static, long-lived credentials are particularly vulnerable.
Unlike prompt-based hijacking, credential compromise gives the attacker persistent, independent access that survives agent restarts and redeployments.
| Attack Vector | Entry Point | Potential Impact |
|---|---|---|
| Indirect Prompt Injection | Retrieved content (web, email, docs) | Goal redirection, data exfiltration |
| Structural Template Injection | Chat template tokens in retrieved context | Full instruction override |
| Tool and MCP Poisoning | Tool descriptions, metadata, return values | Unauthorized tool execution, data theft |
| Memory Poisoning | Short-term or long-term memory stores | Persistent influence across sessions |
| Agent Session Smuggling | Stateful A2A communication channels | Cross-agent context poisoning |
| Credential Compromise | API keys, OAuth tokens, service accounts | Full autonomous access |
| Technique | Where the attacker places influence | What can happen |
|---|---|---|
| Indirect prompt injection | Web pages, emails, documents, code comments, or retrieved records | The agent follows instructions embedded in source material. |
| Conversation or template spoofing | Content crafted to resemble higher-priority messages or prior conversation turns | The agent mistakes attacker text for trusted context. |
| Tool or MCP poisoning | Tool descriptions, metadata, or responses | The agent selects an unsafe tool or acts on a manipulated result. |
| Memory poisoning | Stored context used in later tasks | False information or malicious instructions influence future decisions. |
| Agent-to-agent message manipulation | Shared context or stateful conversations between agents | One agent passes malicious instructions into another agent’s workflow. |
These techniques may overlap. For instance, a poisoned tool response can carry a prompt injection that the agent later stores in memory. Unit 42 has also demonstrated how a malicious agent can exploit session state in an Agent2Agent workflow to influence another agent.
Defending against agent hijacking requires controls at every layer of the agent's execution pipeline, from identity verification through runtime enforcement.