Prompt injection: what it is, with real examples
Prompt injection is a technique where an attacker tries to override or manipulate an AI assistant's instructions by inserting malicious text. A model follows any instructions that reach it, whether they came from you or from some other source. For a coding agent that reads web pages, repositories and tool output, that means text you never wrote can steer what it does. It is unclear whether any method prevents this completely. What helps is limiting what the agent can reach and approving high-impact actions yourself. First step: check which mode your agent runs in and turn on the sandbox, as laid out on the prevention page.
You may have seen the term in a news story and wondered how it applies to the agent on your laptop. A prompt is the text a model receives: your request, the instructions set up behind it, and everything the agent reads while it works. An agent is a model that can also run commands, edit files and call tools. Prompt injection is what happens when someone slips instructions into that text.
01Why a model follows text it should ignore
A person can tell the difference between your request and a line buried in a web page. A language model, which is the AI system that reads and writes text, mostly cannot. It will follow any instructions that make it to the model, whether or not they came from its operator.
Developers try to fix this by writing rules into the hidden instructions that set up the assistant, called the system prompt. Those restrictions may not always be honored and could be bypassed by injected text. A rule written in plain text is a request to the model, not a lock.
02Real prompt injection examples
These are public cases, each with an identifier you can look up. A CVE is a public number assigned to a known security hole in a product.
| Case | What happened |
|---|---|
| Cursor, CVE-2025-54135 | In versions below 1.3.9, an attacker could chain an indirect injection to write to the settings file and trigger remote code execution, meaning the attacker's commands run on the victim's machine, without approval |
| Cursor, CVE-2026-26268 | A malicious agent, for example one steered by planted text, could write to improperly protected .git settings, including git hooks, which may cause code execution outside the sandbox the next time they are triggered |
| Claude Code, CVE-2026-55607 | A sandbox escape that, to be reliably exploited, needed the user to clone a malicious repository containing injected instructions and run Claude Code against it |
| Amazon Q extension for VS Code, July 2025 | The official extension was compromised to include a prompt to wipe the user's home directory and delete all their AWS resources, and was live on the marketplace for two days |
The Amazon Q script passed its prompt to the Amazon Q CLI with the arguments --trust-all-tools and --no-interactive. The first Cursor row is walked through step by step on the indirect injection page, which also covers where the hidden text sits. Settings for each tool are on the coding agents page, and the list of Claude Code advisories is on Claude Code security.
03Direct and indirect, in one line
A direct attack comes through the prompt input itself and changes how the model behaves. An indirect one arrives through content the model reads on its own, such as websites or files. Indirect is the one that matters for agents, because they read a lot you never look at. An MCP server is a program that gives an agent extra tools, and instructions can be embedded in a tool's description, invisible to you but visible to the model. That version is covered on MCP tool poisoning.
04You usually can't spot it by reading
Injections do not need to be human-visible or readable, as long as the model parses the content. So reading a file before the agent opens it is no guarantee that it is clean.
05How serious it is
It depends on what your agent can reach. Three things together turn a nuisance into data theft: access to private data, exposure to untrusted content, and the ability to communicate externally, meaning to send data out. If an agent combines these three features, an attacker can trick it into accessing your private data and sending it to that attacker.
Check your own setup against the three. Can the agent read your project and your keys? Does it read pages, issues and packages you did not write? Can the commands it runs reach the network? Each answer you can change to "no" takes something away from the attacker.
06Will it ever be solved?
Individual holes get patched. The Cursor hole in the first row was fixed in version 1.3.9, and users on Claude Code's standard auto-update received the fix for CVE-2026-55607 automatically. Patching closes one path, not the whole class of problem. Nobody can say it will be solved: it is unclear if there are fool-proof methods of prevention. Simon Willison put it bluntly: "we still don't know how to 100% reliably prevent this from happening".
Plan for the attack to work some of the time, and make sure that when it does, the damage is small.
07What reduces the damage
Three ideas come up everywhere. Give the model the minimum access privileges for its job. This is called least privilege: the agent gets only the access its task needs, nothing more. Require a human to approve high-impact actions before they are taken. Limit the extensions an agent may call to the minimum necessary. An extension here means any tool or plugin the agent can call. The prevention checklist turns them into settings and says where each one falls short. The wider picture is in AI agent security, and rule syntax is on Claude Code permissions.
Injected text does its damage through what the agent then runs. Artificial Immunity's free, open-source core watches Claude Code, Cursor and Codex sessions and every program start on your Mac, and reports what it finds.
FAQ
What is prompt injection?
It is a technique where an attacker tries to override or manipulate an AI assistant's instructions by inserting malicious text. The model follows instructions that reach it whatever their source.
How serious is a prompt injection?
It depends on what the agent can reach. If it combines private data, untrusted content and a way to send data out, an attacker can trick it into stealing that data.
Will prompt injection ever be solved?
Nobody can promise it. It is unclear whether fool-proof prevention exists, and Simon Willison writes that nobody yet knows how to prevent it 100% reliably.
How do you identify a prompt injection?
You often cannot by reading. Injected text does not have to be visible or readable to a person, as long as the model parses it.
What are the types of injection attacks on AI models?
The two main types are direct and indirect. Indirect injection happens when the model accepts input from external sources, such as websites or files. Details are on the indirect page.
How do you prevent prompt injections?
You cannot count on a single fix. Limit the model's privileges to the minimum and require a person to approve privileged operations. The prevention page has the full checklist.