Most lists of prompt injection examples start with a chatbot told to "ignore previous instructions". That still happens, but it is not the case that costs a developer a key. This list is about the AI agent you run on your own machine, such as Claude Code, Codex or OpenCode, and every example comes from a vendor advisory or the vendor's own research that you can read yourself.
Direct and indirect, and why agents changed the picture
Anthropic's Security page for Claude Code defines prompt injection as a technique where an attacker tries "to override or manipulate an AI assistant's instructions by inserting malicious text." When a person types that text into the chat, it is direct. When the text sits in something the model reads on your behalf, it is indirect.
An agent reads a lot on your behalf: the README of a repository you just cloned, an issue someone opened, a page it fetched to check an API, the output of a test. Any of those can carry instructions, and the model sees them in the same context window as yours. The difference from a chatbot is what comes next. An agent can run a command, write a file and call a host with your account, so a followed instruction becomes an action.
Example 1: instructions hidden in an email
Anthropic's research note on prompt injection in browser use, from November 2025, gives the textbook case. A user asks the agent to read recent emails and draft replies to meeting requests. One email, posing as a vendor inquiry, carries instructions in white text that the user cannot see and the agent can: forward every email containing the word "confidential" to an outside address first.
Nothing in that email is code. It is a sentence, placed where the agent would read it while doing a normal task. Anthropic's own tests in the same note show its improved safeguards still let between 1.4 and 2.4 percent of adaptive attacks through, depending on the model, and it says no browser agent is immune.
Example 2: read a file, then send it out
Advisory GHSA-x5gv-jw7f-j6xj, published 15 August 2025, is the coding agent version. Claude Code kept a list of commands it treated as safe enough to run without asking, and the list was too broad. With the right text in the context window, the agent could read a file and then send its contents over the network, with no confirmation prompt along the way.
Version 1.0.4 fixed the list. The shape of the attack is the one to remember: one step that reads a secret, one step that reaches a host, and an instruction that joins them. That mix has a name, the lethal trifecta. Our notes on how Claude Code permissions work cover what those allow and deny rules match today.
Example 3: a command built to get past the prompt
Two more Claude Code advisories show the approval check itself as the target. GHSA-x56v-x2h6-7j34, published 1 August 2025, and GHSA-qxfv-fcpc-w36x, published 9 September 2025, describe an error in command parsing, one around echo and one around rg. A command could look like something harmless to the parser and still run something else, so the confirmation prompt never appeared.
Both advisories carry the same precondition: "Reliably exploiting this requires the ability to add untrusted content into a Claude Code context window." That line is the whole lesson. The parsing bug was the opening, and the injected text is what used it. Versions 1.0.20 and 1.0.105 fixed them.
Example 4: write a config file that runs code
Cursor's advisory GHSA-4cxx-hrm3-49rm, published 2 August 2025, chains an indirect prompt injection with a gap in file approvals. Cursor's agent needed approval to edit an existing dotfile but not to create a new one. If the project had no .cursor/mcp.json yet, injected text could have the agent create it, and the MCP server it named would then run code on the machine without anyone approving it.
Version 1.3.9 blocked the agent from writing those files without approval. The pattern reaches well past one editor: any file that later gets executed or loaded as settings, such as a shell startup file, a hook, a CI workflow or an agent's own config, is a place where a single write turns into code execution.
Reliably exploiting this requires the ability to add untrusted content into a Claude Code context window.Anthropic, GHSA-qxfv-fcpc-w36x
Example 5: the prompt as the payload
The last one runs the other way. In August 2025, malicious releases of the nx package ran an install script that searched the machine for credentials and text files and uploaded what it found to a new repository under the victim's own GitHub account. The Nx advisory prints the prompt the script carried, which opens "You are a file-search agent."
Strictly, that is not injection: the attacker's code wrote the prompt itself, for an agent to carry out. It belongs on this list because it shows the same thing from the attacker's side. An agent that already reads your files with your sign-ins is a useful tool to borrow, whether the instructions arrive in a README or in a script. Our notes on the risks of agentic AI put this next to the other ways an agent's reach gets used.
What the examples have in common
| Example | Where the text came from | What it reached for | The fix |
|---|---|---|---|
| Hidden email text | A message the agent read | Mail to an outside address | Better safeguards; still not immune |
| Read and send | The context window | A file, then a host | Claude Code 1.0.4 |
| Past the prompt | The context window | A command without approval | Claude Code 1.0.20 and 1.0.105 |
| Config file | Indirect prompt injection | A new MCP config that runs code | Cursor 1.3.9 |
| Prompt as payload | A malicious install script | Credentials and files, then GitHub | Releases pulled, tokens revoked |
Every fix in the table closed a path. None of them stopped the model from reading instructions in text, because that is what a model does. The vendors say as much: Anthropic's Security page ends its list of protections with the warning that no system is completely immune to all attacks.
"Prompt injection is a model problem, so the model has to fix it."
Revision 1: the model will sometimes follow the text; what the process can read, write and reach decides what that costs.What you can do about it
Assume some text will be followed. Treat every README, issue, fetched page and tool output as input from a stranger. Anthropic's best practices for untrusted content start with reviewing suggested commands and avoiding piping untrusted content straight to the agent.
Limit what it can read. The project folder, not your home folder. The read and send example needs a secret within reach, so keep ~/.ssh, cloud credentials and other repositories outside the agent's view.
Limit where it can send. A short list of named hosts, with everything else refused. Anthropic's sandboxing page warns that allowing a broad domain such as github.com "can create paths for data exfiltration", and says file limits and network limits only work together.
Protect the files that run later. Shell startup files, hooks, CI workflows and agent config should not be writable by the agent, or should always ask. The Cursor example is a write that became code execution.
Keep a person on the decisions that widen reach. A new host or a new folder is a question for a human, and our notes on human in the loop for AI agents cover why asking about every command stops working. Those limits are the core of agentic AI security as we see it, and our list of AI agent security risks covers what happens without them.
Update, and run it in a box. Every example above was fixed in a version, so stay on current releases. OpenCode's security policy says plainly that it does not sandbox the agent and suggests a container or a VM for real isolation; Anthropic's best practices also recommend VMs for scripts and tool calls.
A side note on how we do it
We build Fenzi, which starts the agent inside an OpenShell sandbox with a copy of the project, a short host list and a placeholder instead of the real key, so text that fools the model still meets those limits. The security model sheet says which layer stops what. A container or VM with a tight network allowlist answers the same question another way.
So, what does prompt injection look like?
Ordinary text in an ordinary place: an email, a README, a page, a script. The published examples asked an AI agent to read a secret and send it, to run a command without asking, or to write a file that runs code later. You cannot stop a model from reading instructions, so decide what it can read, write and reach before it starts. Anthropic's Security page for Claude Code is a good next read, even if you run another agent.