Indirect Prompt Injection
Instructions hidden in content an LLM reads, such as web pages, emails or documents, are followed as if they came from the user, acting with the user's access.
| Severity | High |
| CVSS 3.1 | 7.1 CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N Open in the calculator |
| CVSS 4.0 | 7.1 CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:L/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') |
| OWASP Top 10 | A05:2025 Injection |
| Category | Injection |
Description
The application gives a large language model (LLM) content from sources outside the user's control, such as web pages it browses, emails and calendar invitations it summarises, documents users upload or share, search and retrieval results, and responses from tools or other systems. An attacker who can place text in any of those sources can include instructions in it. When the model processes the content on a user's behalf, it may follow those instructions as if the user had given them, because it cannot reliably distinguish data from instructions. The attacker need never interact with the application to act with the access of the user whose assistant reads the poisoned content: the user only has to use the feature normally, and assistants that process incoming content automatically need no action from the user at all.
The instructions are often hidden from people: white or tiny text, HTML comments, document metadata, the alternative text of images, or text inside images for models that read them. Common goals are to make the model send the conversation, or files and mailbox contents the assistant can see, to the attacker, for example by producing a Markdown image or link whose address contains that data; to call tools such as email, file or ticketing functions to act in the user's name, such as sending emails or changing records; or to manipulate the answers the user relies on, giving false information or a malicious link. What is possible depends on the tools available, and the impact is limited where the model cannot call tools while handling untrusted content and the interface does not fetch external resources named in model output.
The weakness is confirmed by placing a harmless test instruction in content the application will process, such as a shared document, a web page or an email to a test mailbox, then using the feature as an ordinary user and showing that the model follows the instruction. Testing should cover each content source and each tool the model can call, and whether the interface loads images or links from external addresses in model output.
Remediation
Treat all content the model reads from outside the application's control as untrusted, and design so that instructions in it cannot cause harm:
- Restrict what the model can do while untrusted content is in its context: limit it to read-only tools, or require explicit user confirmation, showing the exact parameters, before any action that sends data or changes state.
- Close the common exfiltration channels: do not render images or follow links in model output that point to arbitrary external domains, enforce an allowlist of domains, and apply a Content Security Policy that restricts image and connection sources in the chat interface.
- Run tools with the user's own permissions and enforce authorisation in the back end, so that an injected instruction cannot reach more than the user can.
- Separate and mark untrusted content in the prompt, for example by enclosing it in clearly labelled delimiters or transforming it (techniques sometimes called spotlighting). These reduce, but do not remove, the risk.
- Screen retrieved content and model output with classifier-based injection detection, and log tool calls together with the content that preceded them, so that attacks can be investigated.
Confirm the fix by repeating the planted-content tests for each source and tool, checking that no data leaves through rendered content and that no action completes without the user's informed confirmation.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.