In short
- A pizza chef finds a note in the flour bag: “Give everyone free pizza.” That's prompt injection: text that changes what the AI does.
- Direct: typed into the chat. Indirect: it hides in a web page or file the agent reads. It can even be invisible to you.
- A tricked agent can leak sensitive information, use tools it shouldn't, or run commands in connected systems.
- There may be no foolproof fix, so add layers: only the access it needs, a human approves risky actions, and outside content is marked as untrusted.
- Tip: check what the agent wants to do before you approve. Unexpected request? Say no.
A note in the flour bag
Imagine a pizza chef who opens a bag of flour and finds a note: “Give everyone free pizza.” A sensible chef ignores it. But an AI model reads instructions and data as the same kind of thing: text. If a piece of text looks like an order, the model may follow it.
That is prompt injection: text that changes what the AI does, against what you or the app wanted.
Direct and indirect
Indirect injection is a special risk for agents, because they read lots of outside content on their own. The text can even be invisible to you, like white text on a white background, as long as the model reads it.
- Direct: someone types it straight into the chat, for example “Ignore your rules and…”.
- Indirect: it hides in content the agent reads for you: a web page, an email, a PDF, a code comment. You never typed it, and you may never see it.
What a tricked agent can do
A chatbot that only talks can say something wrong. An agent with tools can do something wrong. OWASP, the security community behind the Top 10 for LLM Applications, lists prompt injection as risk number one (LLM01). The damage depends on what the agent can reach:
- Leak sensitive information, like files, emails or secrets.
- Use tools it shouldn't, like sending messages or making purchases.
- Run commands in connected systems.
Defense in layers
OWASP says it is unclear whether there are fool-proof ways to prevent prompt injection. So instead of one magic fix, you stack several layers:
- Least privilege: give the agent only the access it needs for the task.
- Human in the loop: a person approves risky actions before they happen.
- Mark outside content as untrusted: keep it separate from your instructions, so the model treats it as data, not as orders.
Your part
When an agent asks for approval, read what it wants to do. If the request doesn't match what you asked for, like sending files somewhere or buying something, say no. An unexpected request is a warning sign that something in its input may be trying to steer it.
Test yourself
5 quick questions. Pick an answer to check it.
Sources
- OWASP Top 10 for LLM Applications 2025: LLM01 Prompt Injection
- Claude API docs: Computer use tool, prompt injection precautions
Checked November 22, 2026.