Prompt injection
Prompt injection is an attack where text that an AI model reads contains instructions that change what it does. The text can come from a user, or hide in content the AI fetches, such as a web page, an email, a support ticket or a product review.
Why it matters
OWASP ranks prompt injection first in its Top 10 for applications built on large language models.1 It matters most when an assistant is connected to tools that can act.
In May 2025, Invariant Labs showed that a planted issue on a public GitHub repository could make an AI agent connected through the official GitHub MCP server leak data from the user's private repositories.2 The server had no bug. The agent read text an attacker wrote and followed it.
In practice
- Keep untrusted text away from conversations where the AI can act.
- Use read-only access wherever a tool offers it.
- Approve every action that sends, changes or pays.
- Turn off tools that read customer-written text when you don't need them.
- Log which assistant can reach which tool.
What the sources say
Allowing attackers to access private repository data.
Invariant Labs, May 2025, GitHub MCP Exploited: Accessing private repositories via MCP
What to do about prompt injection, depending on who you are
If you've connected Claude or ChatGPT to your store
Reviews, order notes and support tickets are written by strangers. An assistant that reads them and can also edit products or send emails is the setup to avoid.
- Read customer text in a conversation with read-only tools.
- Act in a separate conversation without that text.
- Keep approval on for every change.
If you're building an AI feature or agent
OWASP lists prompt injection as the top risk for LLM applications, and model alignment alone doesn't stop it. Limit what the model can do.
- Give the agent only the tools one task needs.
- Separate reading untrusted content from taking actions.
- Require a person to approve anything that moves money or data.
Go deeper
My guide to MCP security for online stores sets out six rules for connecting AI to a store.