Agentic Security Pedia

Prompt injection and agent goal hijack

Untrusted text takes over an agent when the model follows it as instructions. Models can't reliably separate data from commands, so a web page, issue, README or tool result can redirect its goal. Agents act on files, commands and the network, so the attacker's goal runs with your access.

The question How does untrusted text take over an agent?

Direct and indirect prompt injection

OWASP puts prompt injection first in its Top 10 for LLM Applications 2025, as LLM01:2025. It occurs when input changes a model's behaviour or output in ways nobody intended. OWASP describes two kinds:

  • Direct: the user's own prompt alters the model's behaviour. It can be deliberate, or an accident.
  • Indirect: the model takes in content from an outside source, such as a website or a file, and that content alters its behaviour.

Indirect injection is the one to worry about for agents, because agents read outside content all day. People don't have to be able to see the instructions. OWASP notes that input can affect the model even when humans can't perceive it. MITRE ATLAS says indirect injections are frequently hidden, for example as invisible text.

Why agents raise the stakes

A chatbot that falls for an injection gives a bad answer. An agent that falls for one takes bad actions. It reads files, runs commands, calls APIs and sends data out, with the access of whoever started it. OWASP says the impact depends largely on the business context and on how much agency the model has. The UK's National Cyber Security Centre (NCSC) goes further. Once a model can call tools, the impact is whatever an attacker could do with direct access to them.

OWASP's Top 10 for Agentic Applications, published in December 2025, names the agent version ASI01 Agent Goal Hijack. Attackers redirect an agent's objectives, task selection or decision pathways. They use injected prompts, deceptive tool outputs, malicious files, forged messages from other agents or poisoned data. OWASP draws the line this way: LLM01 covers altering a single model response, while ASI01 covers inputs that redirect goals, planning and multi-step behaviour.

Simon Willison names the dangerous mix the lethal trifecta: access to private data, exposure to untrusted content, and a way to communicate externally. A coding agent on a laptop can have all three at once: your code and keys, the pages it reads, and the network. GIRD's 19-day case study covered one company's engineering laptops. Agents' own processes opened credential files 19 times in week one and 29 times in week two. Four named keys went out inside ordinary agent requests. A hijacked agent would have the same reach. See what an AI coding agent can reach on a laptop.

Four documented cases

Each of these was published by the researchers who found it.

CaseWhere the text hidWhat the agent did
GitHub MCP server, May 2025 (Invariant Labs)An issue in a public repositoryAsked to look at open issues, the agent read the owner's private repositories. It then posted details from them in a pull request on the public one.
GitHub Copilot in VS Code, CVE-2025-53773, fixed August 2025 (Embrace The Red)A source file, web page or GitHub issueCopilot wrote "chat.tools.autoApprove": true into VS Code settings without asking. That switched off confirmations, so it could run shell commands.
Rules files, March 2025 (Pillar Security)Rules files for Cursor and GitHub Copilot, using invisible Unicode charactersAsked for a simple HTML page, the agent added a script from an attacker's site and didn't mention it.
Perplexity Comet, August 2025 (Brave)A Reddit comment behind a spoiler tagAsked to summarise the page, the browser agent found the user's email address, triggered a one-time code and read it in their Gmail. It posted both in a reply, enough to take over the account.

Invariant Labs stressed that their case was "not a flaw in the GitHub MCP server code itself" but an architectural issue for agent systems. The root cause is the same in all four: each agent did what the text told it, with access it already had.

Why filters alone can't stop it

The obvious fix is to filter what the agent reads. Filtering helps, but it can't be the whole defence.

The NCSC explains why. Current models "simply do not enforce a security boundary between instructions and data inside a prompt." SQL injection was fixed at the root with parameterised queries. The NCSC says there's a good chance prompt injection will never be mitigated that way. It calls the model an "inherently confusable deputy". The best anyone can hope for, it says, is to reduce the likelihood or impact of attacks. It also tells buyers to beware any product that claims to "stop" prompt injection.

Research points the same way. In October 2025, a team of 14 researchers tested 12 recent defences against attackers who adapt their approach. They bypassed all 12, most with attack success rates above 90%. Most of those defences had first reported near-zero attack success. OWASP's own verdict is that it is unclear whether fool-proof prevention exists.

A filter that catches 95% of attacks sounds good. Willison points out that in security, 95% is a failing grade, because the attacker only needs the rest. Filters lower the odds. What caps the damage is what the agent is allowed to do.

Controls that limit the damage

Design as if some injected text will get through, then make sure a hijacked agent can't do much with it. OWASP's guidance for ASI01 includes exactly this: least privilege for agent tools, and human approval for high-impact or goal-changing actions. Five controls do most of the work.

  1. Least privilege. Give the agent only the tools, files and tokens the task needs, and scope tokens to one repository or service. After the GitHub case, Invariant Labs' first recommendation was to limit agents to the repositories they need. More in least privilege for AI agents.
  2. Check each action against the task. Before a tool call runs, compare it with what the person asked for. OWASP says to validate intent at run time, and to pause or block on any unexpected goal shift. Brave proposes the same check for browser agents.
  3. Human approval for risky actions. Ask a person before deletes, pushes, payments, outbound messages and permission changes. Keep the list short so people read it. Never let an agent that reads untrusted content switch approvals off; the flaw behind CVE-2025-53773 let injected text do exactly that.
  4. Egress control. Exfiltration needs a way out. Allow the destinations each agent needs and deny the rest, which removes the third leg of the trifecta. OWASP's guidance on tool misuse calls for outbound allow lists that deny all non-approved destinations.
  5. A record of what happened. Log what the agent read, each tool call with its arguments, and each approval or block, tied to a person and a task. The NCSC recommends logging the model's inputs, outputs and tool calls. Failed tool calls can reveal an attacker honing an attack. See what an audit trail for AI agents must show.

FAQs

Can a better model or a filter fix prompt injection?

Not fully. OWASP says it is unclear whether fool-proof prevention exists. The UK NCSC says prompt injection may never be mitigated the way SQL injection was. Filters lower the odds. Limits on what the agent can do cap the damage.

Where does indirect prompt injection hide for a coding agent?

Anywhere the agent reads: issues, pull requests, code comments, READMEs, rules files, documentation pages and tool results. The text can be hidden from people with invisible characters or formatting, and still reach the model.

Does human approval stop it?

It helps for high-impact actions, but approvals wear thin. Invariant Labs noted that many users choose 'Always Allow', and CVE-2025-53773 let injected text switch Copilot's confirmations off. Keep approvals for a short list of risky actions and enforce the rest with policy.

Is jailbreaking the same as prompt injection?

OWASP treats jailbreaking as one form of prompt injection: input that makes the model disregard its safety protocols entirely. Goal hijack is the agent form, where the injected text redirects what the agent does next.

What should we log to investigate a suspected injection?

The content the agent read, every tool call with its arguments, every approval or block, and the person and task behind the session. Without that record, you can't tell a hijacked action from a requested one.

Sources

  1. LLM01:2025 Prompt Injection, OWASP GenAI Security Project. Read 26 Oct 2026.
  2. OWASP Top 10 for Agentic Applications for 2026, OWASP GenAI Security Project, 9 Dec 2025. Read 26 Oct 2026.
  3. LLM Prompt Injection: Indirect (AML.T0051.001), MITRE ATLAS. Read 26 Oct 2026.
  4. The lethal trifecta for AI agents: private data, untrusted content, and external communication, Simon Willison, 16 Jun 2025. Read 26 Oct 2026.
  5. GitHub MCP Exploited: Accessing private repositories via MCP, Invariant Labs, 26 May 2025. Read 26 Oct 2026.
  6. GitHub Copilot: Remote Code Execution via Prompt Injection (CVE-2025-53773), Embrace The Red, 12 Aug 2025. Read 26 Oct 2026.
  7. New Vulnerability in GitHub Copilot and Cursor: How Hackers Can Weaponize Code Agents, Pillar Security, 18 Mar 2025. Read 26 Oct 2026.
  8. Agentic Browser Security: Indirect Prompt Injection in Perplexity Comet, Brave, 20 Aug 2025. Read 26 Oct 2026.
  9. Prompt injection is not SQL injection (it may be worse), National Cyber Security Centre, 8 Dec 2025. Read 26 Oct 2026.
  10. The Attacker Moves Second: Stronger Adaptive Attacks Bypass Defenses against LLM Jailbreaks and Prompt Injections, arXiv, 10 Oct 2025. Read 26 Oct 2026.