# WTF is prompt injection?

> Sarge says: Your agent can take orders from anything it reads. Assume the enemy wrote some of it.

- Term: Prompt injection
- Also called: direct prompt injection; indirect prompt injection; prompt injection attack; LLM01
- Section: AI agent threats
- Web page: https://codemarine.ai/learn/prompt-injection/

## Short version

Prompt injection is when text an AI reads tricks it into following an attacker instead of you.

## The briefing

- **OWASP rank:** LLM01, the top entry in its 2025 list for large language model applications.
- **The cause:** Models get instructions and data as one stream of natural language, with no clear line between them. Orders and mail arrive on the same radio channel.
- **Direct injection:** Someone types the attack straight into the prompt.
- **Indirect injection:** The dangerous one for developers. The attack hides in something the model reads: a web page, an email, a file, a code comment, an issue or a commit message.
- **You may never see it:** OWASP notes the input does not need to be human-readable as long as the model parses it. Its examples include white text on a white background and non-printing Unicode characters.
- **What is at stake:** A tricked chatbot says something silly. A tricked coding agent has your shell, your files and your tools. Hidden instructions in a README can steer it toward your secrets or commands you would never approve.
- **No silver bullet:** OWASP says it is unclear if there are fool-proof methods of prevention, and that screening input is not a security boundary.

## In the Threat Brief this looks like

> Indirect prompt injection in ExampleAgent: a crafted README can steer it toward local secrets.

The attack is in the text, not in your prompt. Your agent only had to read the file.

Example only. The product, versions and names are made up.

## What to do

- Plan on it happening.
- Limit what the agent can touch.
- Keep a human approval on risky actions.
- Treat anything it reads or gets back from a tool as untrusted.

## Official sources

- [OWASP: LLM01:2025 Prompt Injection](https://genai.owasp.org/llmrisk/llm01-prompt-injection/)
- [OWASP: Prompt Injection](https://community.owasp.org/attacks/PromptInjection)
- [OWASP: LLM Prompt Injection Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/LLM_Prompt_Injection_Prevention_Cheat_Sheet.html)

## Related

- [MCP server](https://codemarine.ai/learn/mcp-servers.md)
- [Supply chain attack](https://codemarine.ai/learn/supply-chain-attack.md)
- [RCE and privilege escalation](https://codemarine.ai/learn/rce-and-privilege-escalation.md)
