# What is prompt injection?

Prompt injection is an attack in which text hidden in a web page, an email or a document tricks an AI system into following the attacker's instructions and not yours.

## Key takeaways
- A model cannot always tell your instructions from instructions inside content it reads.
- The risk grows when an AI agent can browse, read email or take actions.
- The defense is limited access and human approval, not a cleverer prompt.

## How it works
An AI agent reads outside content as part of its work. An attacker places a sentence in that content, such as an instruction to send the user's contact list to an address. The agent may treat the sentence as a command, because all the text arrives in the same context window.

## Example
You ask an AI assistant to summarize your unread email. One message contains hidden white text that tells the assistant to forward your latest invoice to a stranger. An assistant with permission to send email could do it.

## Why it matters
As you connect AI to your inbox, your files and your accounts, anything it reads becomes a possible way in. This is the main security question for AI agents today.

## Common mistake
No prompt makes a model immune. Give agents the least access they need, keep approval on for sending, paying and deleting, and be careful with content from unknown sources.

## Related terms
- [Guardrails](https://www.excellentaiprompts.com/ai-encyclopedia/guardrails)
- [AI Agent](https://www.excellentaiprompts.com/ai-encyclopedia/ai-agent)
- [Model Context Protocol (MCP)](https://www.excellentaiprompts.com/ai-encyclopedia/model-context-protocol)
- [Human in the Loop](https://www.excellentaiprompts.com/ai-encyclopedia/human-in-the-loop)

Source: https://www.excellentaiprompts.com/ai-encyclopedia/prompt-injection (Excellent AI Prompts, updated 2026-11-10)
