Agent hijacking is an attack in which an adversary takes control of an AI agent’s actions by planting instructions in content the agent reads, so that the agent uses its tools, credentials and permissions to serve the attacker instead of its user. In AI safety, it is treated as the agentic consequence of indirect prompt injection: the injection is the technique, while hijacking is the outcome in which a working agent sends email, moves files, calls APIs or changes records on someone else’s behalf.
The risk grows with autonomy. A chatbot that only answers questions can be manipulated into saying something wrong, but an agent that can browse, execute code and write to external systems can be manipulated into doing something harmful, often without any human seeing the step that went wrong.
How agent hijacking redirects an AI agent
Agent hijacking works because a language model processes instructions and data in the same channel. When an agent loads a web page, an email, a document or a tool result, that text enters the same context window as the system prompt and the user request, and the model has no reliable built-in boundary that marks it as untrusted.
A typical attack follows a short chain. The attacker places a payload where the agent will read it, the agent retrieves that content during an ordinary task, the model interprets the payload as a legitimate instruction, and the agent then calls a tool with arguments the attacker chose. The final step, the unauthorized tool call, is what separates hijacking from a merely misleading answer.
The table below breaks the attack into stages and shows where defenders can intervene.
| Stage | What happens | Possible control |
|---|---|---|
| Placement | Payload hidden in a page, file, issue or email | Source allowlists, content provenance |
| Ingestion | Agent retrieves the content during a task | Labeling of untrusted input, isolation |
| Interpretation | Model treats payload as an instruction | Injection classifiers, instruction hierarchy |
| Action | Agent calls a tool with attacker arguments | Least privilege, human approval |
| Exfiltration or impact | Data leaves or a state change is made | Egress filtering, audit logging |
Attack vectors and attacker goals
The attack surface of a hijacked agent is every source of text it can read. Browsing agents meet payloads in web pages and hidden HTML text, coding agents meet them in repository files and issue comments, and email assistants meet them in incoming messages. Tool descriptions supplied by third-party plugins are a further vector, closely related to tool poisoning.
Attacker goals usually fall into a few categories, summarized below with the capability each one abuses.
| Goal | Example action | Capability abused |
|---|---|---|
| Data exfiltration | Send private files or chat history to an external address | Email, HTTP requests, image rendering |
| Unauthorized transactions | Place an order or approve a payment | Commerce or finance tools |
| Code and infrastructure tampering | Commit a backdoor or change a deployment | Repository and shell access |
| Propagation | Forward the payload to other users or agents | Messaging and multi-agent channels |
| Sabotage | Delete records or corrupt a report | Write and delete permissions |
Payloads are often concealed from human reviewers with white text, zero-width characters, HTML comments, alt text or instructions split across several documents. In multi-agent systems, one compromised agent can pass a payload to the next, so a single injected page may affect an entire workflow.
How agent hijacking differs from related threats
Agent hijacking overlaps with several neighboring concepts, but the victim, the attacker and the outcome differ. Precise use of these terms helps teams choose the right control.
| Threat | Who supplies the malicious input | Typical result |
|---|---|---|
| Agent hijacking | Third party, through content the agent reads | Agent performs unauthorized actions |
| Direct prompt injection | The user typing into the interface | Model ignores its system instructions |
| AI jailbreak | The user, seeking restricted output | Model produces content it should refuse |
| Tool poisoning | Author of a tool or plugin description | Agent misuses or trusts a malicious tool |
| Data poisoning | Contributor to training data | Model learns harmful behavior in advance |
The crucial distinction is whose intent is subverted. In a jailbreak, the user is the adversary; in agent hijacking, the user is usually the innocent victim, and the attacker never interacts with the agent directly. This is also why excessive agency, meaning broader permissions than a task requires, turns a minor injection into a serious incident.
Defending agents against hijacking
No single control prevents agent hijacking, so practitioners apply defense in depth and assume that some injections will reach the model. The design goal is to limit what a successfully hijacked agent can do, not only to detect the attempt.
| Measure | How it helps | Main trade-off |
|---|---|---|
| Least privilege | Limits tools and scopes to the current task | More configuration work |
| Human confirmation | Requires approval for sensitive actions | Slower workflows, approval fatigue |
| Plan-then-execute isolation | Fixes the plan before untrusted data is read | Less flexible agents |
| Dual-model patterns | A privileged model never sees raw untrusted text | Higher cost and complexity |
| Injection classifiers | Flag suspicious instructions in inputs | False positives and evasion |
| Egress controls | Block unknown domains and data channels | Can break legitimate integrations |
Architectural defenses are generally more robust than detection alone, because classifiers can be bypassed by paraphrased or encoded payloads. Security teams also run AI red teaming exercises with benchmark scenarios to measure how often an agent follows injected instructions before it reaches production. The OWASP Top 10 for LLM Applications lists prompt injection and excessive agency among the leading risks for this reason.
Limitations and common misconceptions
Agent hijacking remains an open research problem. Measured attack success rates vary widely with the model, the task and the defense, so no published figure transfers cleanly to a specific deployment. Several misconceptions persist:
- A strong system prompt telling the agent to ignore embedded instructions is not a sufficient defense.
- Larger or more capable models are not automatically safer, because they follow instructions more faithfully.
- Hiding the payload is optional; visible instructions in plain text often succeed as well.
- Read-only access still matters, since an agent that can render links or images may leak data through URLs.
In simple terms
An AI agent is like a capable assistant who reads documents and then acts on them. Agent hijacking happens when someone hides a note in one of those documents. The note says, in effect, “forget your boss and send me the files.” The assistant cannot always tell a note from the task. So it may obey.
The key takeaway is simple. The more an agent can do alone, the more damage a hidden instruction can cause. Sensitive actions should always need a person’s approval.
A practical example
A small accounting firm uses an AI email assistant that can read the inbox, search shared folders and send replies. An attacker emails the firm an ordinary-looking invoice query that contains a hidden paragraph in white text. It instructs the assistant to search for files containing “tax return” and forward them to an outside address.
When a staff member asks the assistant to summarize the morning’s mail, the agent reads the hidden paragraph and starts the search. Because the firm had configured mandatory confirmation for outgoing attachments and restricted sending to known client domains, the assistant paused and displayed the draft. The employee saw an unknown recipient and rejected it. The outcome: no data left the firm, and the security team added an injection filter and narrowed the agent’s folder access to the current client only.