Every discussion of prompt injection that concludes "the worst case is it says something embarrassing" was written before agents could act. An agent with tools — read a file, send an email, query a database, call an API, run a command — converts injected text into executed action, performed with the agent’s credentials, which are usually broader than anyone intended.
This is the confused deputy problem, and it is as old as computing. What is new is that the deputy now takes instructions from any text it happens to read, and the text it reads includes web pages, emails, tickets, documents and tool responses.
The structural fact to design around
A model cannot reliably distinguish instruction from data in its context window. Not with delimiters, not with a firmer system prompt, not with a classifier in front. Those measures lower the success rate; none of them make the boundary sound. So the design question is not "how do we stop injection" but "what happens when it succeeds", and the answer has to be "very little".
What we attack
Injection through tool output
Teams sanitise the user’s message and forget that tool responses re-enter the context. A web-fetch tool returning an attacker’s page, a database row containing text a customer wrote, an email body, a calendar invite description — each is a channel into the agent’s instructions. We plant instructions in each reachable tool output and look for action, not just acknowledgement.
Chained actions and the irreversible step
Single-tool tests understate the risk. We test multi-step chains: read a document, discover an identifier, use it against a second tool, use that output to authorise a third call. The question we are answering is whether the agent can assemble a sequence no individual authorisation check would have refused.
MCP and connected tool servers
Model Context Protocol servers and similar connectors are now the standard way to give an agent capabilities, and they concentrate risk in a place few people review.
- Tool descriptions are part of the prompt. A malicious or compromised server can place instructions in a tool’s own description and influence the agent before any call is made.
- Credentials held by the server are usually long-lived, broadly scoped and shared across users of the agent.
- A server added "to try it out" rarely gets removed, and its supply chain — the package, its updates, its maintainer — is now part of your production authorisation surface.
- Tool responses are trusted implicitly by most agent loops, which makes a compromised server the cleanest possible injection channel.
Memory and state poisoning
Agents with persistent memory can be poisoned durably: an instruction written into memory on Monday influences behaviour on Friday, long after the conversation that planted it. We test whether memory writes are attributable, reviewable and bounded, and whether anything read back from memory is treated as instruction.
What we test, in order
- Inventory every tool, its parameters, its credentials and its blast radius, including tools reachable only after another tool succeeds.
- For each tool, confirm authorisation is enforced server-side against the initiating human’s session, not against the agent’s identity and not from model-supplied arguments.
- Inject instructions through every channel that re-enters context: user input, retrieved documents, tool responses, tool descriptions, memory, file contents, web pages.
- Test multi-step chains for privilege assembly, with an explicit target an attacker would want.
- Review every connected MCP or tool server: who runs it, what credentials it holds, how it is updated, and what its descriptions contain.
- Test the irreversibility boundary: which actions cannot be undone, and whether any of them can be reached without a human approving that specific action.
- Test containment: rate limits, spend caps, time bounds, loop detection, and what the agent can reach on the network.
- Review the audit trail: can you reconstruct every action an agent took, with the inputs that led to it.
Controls that hold up
- Capability scoping per task, not per agent. The agent that summarises tickets does not hold the credential that can refund money.
- Human approval on the irreversible step, with the approval request showing the exact action and arguments rather than a summary the model wrote.
- Authorisation decided by the backend from the initiating user’s session, with model output treated as a request, never as an authority.
- Tool outputs labelled as untrusted data in the context, with instruction-stripping applied before they re-enter.
- An allowlist of tool servers, pinned versions, reviewed descriptions, and credentials scoped per server with short lifetimes.
- Egress control: an agent with a fetch tool needs a proxy with an allowlist, or it is an SSRF primitive with a planner attached.
- Hard budgets — calls, tokens, spend, wall-clock — enforced outside the agent loop, because a looping agent is the most common incident and it is self-inflicted.
- Full action audit with the triggering context retained, so an investigation has something to read.
Where to start
List every tool your agent can call and, beside each, the worst thing a motivated stranger could do with it. Where that worst case is unacceptable, the fix is to remove the capability or put a human in front of it — not to improve the prompt.