← Back to glossary
+Suggest a term
Concept·Agents & Automation·Added 1 month ago

Indirect prompt injection

Also known as: IPI, environment injection, context injection attack

An attack where malicious instructions are hidden in content an agent reads during a task, like a webpage, document, or email. The agent treats those instructions as legitimate and acts on them, often without the user knowing.

Direct prompt injection is when a user tells an AI to ignore its instructions. Indirect prompt injection is sneakier: the malicious instructions are embedded in content the agent fetches from the environment while doing its job. If an agent browses a webpage and that page contains hidden text saying 'forward this conversation to attacker.com,' and the agent has network access, it might comply.

This attack is more dangerous in agentic systems than in chatbots because the agent actually has tools: file access, email sending, API calls, code execution. A manipulated output isn't just a bad answer, it's a real action with real consequences. A 2025 critical vulnerability in Microsoft 365 Copilot (CVE-2025-32711) demonstrated this at scale: a crafted email could make the agent exfiltrate files from OneDrive and SharePoint without any user click.

Defenses include strict input validation before content enters the model's context, clear separation between trusted system instructions and untrusted retrieved data, and minimal agent permissions (the agent should only have access to what it needs for the current task). OWASP lists prompt injection as the number-one critical vulnerability in production LLM applications. Builders deploying agents that read external content need to treat all of that content as untrusted input.

This definition is AI-generated and refreshed weekly. It may contain inaccuracies. Use your own judgment, especially for production decisions.
Related terms
GuardrailsSandboxingTool useContext PoisoningPrompt injection