Indirect prompt injection occurs when an AI application processes external content containing instructions designed to influence its behaviour. The content might appear in a webpage, document, email or retrieved knowledge source. If the application fails to separate trusted instructions from untrusted data, an attacker may influence its responses or connected actions. Security teams need to validate what the application can access, what it can do and whether malicious content can cross those boundaries.
What Is Indirect Prompt Injection?
AI applications often process information from sources beyond a user’s direct message. A chatbot might retrieve webpages, summarise uploaded documents, read emails or query an internal knowledge base. An AI agent might also use tools to search systems, update records or interact with other applications.
Indirect prompt injection targets this workflow.
Instead of placing malicious instructions directly in a user’s prompt, an attacker embeds them in content the AI system is expected to read. The content may look like ordinary text, but it contains instructions intended to override the application’s expected behaviour.
For example, an AI assistant might be asked to summarise a webpage. That webpage could contain hidden or misleading instructions telling the assistant to ignore its original task, reveal information from its context or perform an unauthorised action using an available tool.
Whether the attempt succeeds depends on the application’s design, permissions, safeguards and handling of untrusted content. Reading a malicious instruction does not automatically mean an AI system will follow it. The security concern is whether the application can be manipulated into doing something it should not do.
The OWASP GenAI Security Project identifies prompt injection as an important security concern for applications built with large language models.
How Indirect Prompt Injection Works
Indirect prompt injection becomes relevant when an AI application combines external content with its own instructions or has access to tools and sensitive information.
A typical attack path has four stages.
1. An attacker places malicious instructions in content
The attacker creates or modifies content that an AI application may later process. This could be a webpage, a shared document, an email or a record in a searchable knowledge source.
The instructions may be visible, disguised within ordinary content or presented in a way that encourages the model to treat them as authoritative.
The attacker does not necessarily need direct access to the AI application. If the application retrieves the content automatically, the external source can become an entry point.
2. The AI application retrieves the content
The application reads the content as part of a legitimate task. For example, it may summarise a document, answer a question using a retrieval system or analyse information from an external website.
At this stage, the application should treat retrieved content as data to analyse, not as instructions that can override its governing rules.
However, language models process both instructions and information through the same general interface. Clear separation, robust system design and enforcement outside the model are therefore important.
3. The model is influenced by the injected instructions
If the application’s safeguards are insufficient, the model may follow some or all of the malicious instructions.
The outcome might be an inaccurate answer, disclosure of information present in the model’s context, an inappropriate tool call or an attempt to perform an action beyond the user’s original request.
These outcomes are not inevitable. They depend on the model, the prompt structure, the content, the tools available and the surrounding controls.
4. The application produces an unsafe result or action
The potential impact increases when the AI application can interact with other systems.
An assistant that only summarises public webpages has a different risk profile from an agent that can access confidential documents, send emails, change customer records or execute operational workflows.
The important question is not simply whether the model responded to malicious text. It is whether that response crossed a meaningful security boundary.
Why AI Agents Can Increase the Impact
AI agents can use tools to complete multi-step tasks. Depending on their configuration, they may retrieve data, call application programming interfaces (APIs), update records or initiate workflows.
This creates additional opportunities for indirect prompt injection to cause harm.
Excessive permissions
An AI agent may have access to more data or actions than its assigned task requires. If malicious content influences the agent, those permissions may increase the potential impact.
For example, a research assistant may need read access to a limited document collection. If it also has permission to send external messages or retrieve unrelated confidential records, a successful manipulation could have broader consequences.
Apply least privilege to the agent’s tools, data sources and connected identities. Access should match the specific task, rather than the maximum capabilities the agent could use.
Unrestricted tool execution
Some AI applications allow the model to select tools and provide arguments for those tools. If the application executes those requests without suitable checks, manipulated model output may trigger an unsafe action.
A model-generated instruction should not, by itself, authorise a sensitive operation.
Enforce permissions and validation in the application layer. Require appropriate approval for high-impact actions, and validate tool arguments against the user’s authorised task.
Sensitive information in context
AI applications may retrieve internal information to produce more useful answers. If untrusted content influences the model, the application may attempt to disclose information included in its context.
The risk depends on what data the application can access and whether the output controls prevent unauthorised disclosure.
Restrict data retrieval to the user’s authorised scope. Avoid placing unnecessary secrets in prompts or model context, and apply access checks before information is retrieved, not only after the model generates a response.
Where Indirect Prompt Injection Can Enter an AI Workflow
Security teams should examine every untrusted source an AI application can process, including sources that appear internal or familiar.
Web browsing and search. An AI assistant may retrieve a webpage controlled by an attacker or content that has been compromised. The malicious instructions can enter through the retrieval process.
Document processing. Uploaded files and shared documents may contain instructions that influence summarisation, classification or extraction tasks.
Email and messaging. An AI assistant that reads incoming messages may encounter content designed to influence its behaviour or misuse its connected tools.
Retrieval-augmented generation. Retrieval-augmented generation (RAG) systems use external information to help a model answer questions. If untrusted or compromised content enters the knowledge collection, it may influence later responses.
Third-party integrations. AI applications often rely on external services and connectors. The information returned by these services should be treated according to its trust level, even when the integration itself is legitimate.
Each source creates a different trust boundary. Security teams should document which sources the application reads, which identities it uses and which actions it can take after processing the content.
How to Validate Indirect Prompt Injection Risk
A security review should establish whether malicious content can influence the application in a way that produces an unauthorised result. Testing must be performed against systems and data that the organisation is authorised to assess.
Step 1: Map the AI application’s data flow
Document the model, system instructions, retrieval sources, connected tools, identities and downstream applications.
Identify where external content enters the workflow and where model output can trigger further processing or actions.
This helps establish the relevant attack paths. A prompt injection issue in a read-only assistant may require different controls from one in an agent that can modify business records.
Step 2: Identify trust boundaries
Determine which instructions are trusted and which content is untrusted.
Review how the application handles webpages, documents, retrieved passages, emails and third-party responses. Check whether content from those sources can influence decisions beyond the intended task.
Do not assume that labelling a source as untrusted is enough. The application needs controls that enforce the intended boundaries.
Step 3: Test representative attack scenarios
Create controlled test cases using benign documents or webpages containing instructions that conflict with the application’s intended task.
For example, test whether a document can cause the assistant to attempt to retrieve unrelated information or request an action outside the user’s permissions.
Observe the complete workflow, including retrieval, model output, tool selection and downstream enforcement. A suspicious response alone is not proof of a successful compromise. Equally, a refusal in one test does not prove that every attack path is secure.
Step 4: Validate tool permissions and actions
Check whether the application can perform actions that are not required for its intended function.
Use a test environment and non-sensitive test data to determine whether a manipulated response can trigger a tool call, access an unauthorised resource or bypass an approval step.
Verify that access controls are enforced independently of the model. Even if the model produces an unsafe request, the application should reject an unauthorised operation.
Step 5: Record evidence and retest fixes
Document the input source, test conditions, observed behaviour, affected capability and security impact.
After remediation, repeat the same scenario and relevant variations. Confirm that the malicious content no longer causes the unauthorised result and that legitimate functionality still works.
Testing should be repeated when the model, system instructions, retrieval sources, tools or permissions change.
Defences That Reduce Prompt Injection Risk
No single prompt instruction can guarantee protection against every prompt injection technique. Effective defence requires multiple controls across the AI application’s architecture.
Treat retrieved content as untrusted input
Design the application so that external content cannot grant itself authority over system instructions or user permissions.
Clear delimiters, explicit trust labels and careful prompt construction can help, but they should be treated as supporting measures rather than complete protection.
Apply least privilege
Give the model and its connected tools only the access required for the task. Separate read and write permissions where possible, and restrict access to sensitive data by user and purpose.
Enforce authorisation outside the model
Check permissions in the application and tool layers before sensitive data is returned or an action is executed.
The model should not be responsible for deciding whether a user is authorised to access a resource. Nor should its generated output override established access controls.
Require approval for sensitive actions
Actions such as sending external communications, changing important records or initiating financial transactions may require explicit human approval.
Approval workflows should show what will happen and which information or resources are affected. They should not simply ask users to approve an unclear model-generated action.
Minimise sensitive context
Only retrieve the information needed to complete the task. Limit exposure to credentials, confidential records and other sensitive data.
Output checks can help identify unwanted disclosures, but data minimisation and access enforcement should remain the primary controls.
Monitor and validate changes
Review tool calls, access decisions, rejected operations and unusual workflows. Use logs to investigate what happened, while protecting sensitive information contained in those logs.
Retest the application after changes to models, prompts, connectors, retrieval pipelines or permissions. A control that worked in one configuration may not remain effective after the workflow changes.
Why AI Security Needs More Than Prompt Testing
Prompt testing is useful, but an AI application is more than a model and its instructions.
Its security also depends on identity management, data access, application logic, APIs, tool permissions and the systems that execute its actions. A model may resist a malicious instruction while a poorly designed integration still exposes data through an independent access-control weakness.
Security teams should therefore assess the complete application and its attack paths.
This includes reviewing the web application and APIs that connect the model to business systems. Attack Insights provides information on its Web Application Security and API Security capabilities, which are relevant when assessing the application layers around AI features.
Where authorised, security validation can help determine whether a suspected weakness can be exercised and whether remediation closes the tested path. The objective is to establish what an attacker can actually achieve, rather than relying on a policy statement or a single successful model response.
Build AI Security Around Verified Boundaries
Indirect prompt injection highlights a fundamental challenge for AI applications: content that a model reads must not automatically become authority over what the application can access or do.
Security teams should map data flows, restrict permissions, validate sensitive actions outside the model and test how untrusted content behaves across the full workflow. They should also reassess the application when its models, integrations or capabilities change.
A defensible AI security programme combines model-level safeguards with application security, access control and evidence-based testing.
Want to understand how attackers can reach your external applications and APIs? Explore how Attack Insights helps security teams assess external exposure and validate weaknesses across their attack surface.
Request an Attack Insights ASM Demo
Frequently Asked Questions
What is indirect prompt injection?
Indirect prompt injection occurs when an AI application processes external content containing instructions designed to manipulate its behaviour. The instructions may appear in webpages, documents, emails or retrieved information. The security impact depends on whether the application follows those instructions and can access sensitive data or perform unauthorised actions.
What is the difference between direct and indirect prompt injection?
Direct prompt injection comes from instructions supplied directly by a user, such as a message intended to override an application’s rules. Indirect prompt injection arrives through content the application retrieves or processes, such as a webpage or document. Both can attempt to influence model behaviour, but indirect attacks can originate outside the immediate user interaction.
Can prompt injection be completely prevented?
No single safeguard can guarantee that every prompt injection attempt will fail. Organisations can reduce risk by treating retrieved content as untrusted, limiting permissions, enforcing authorisation outside the model and requiring approval for sensitive actions. Testing should cover the complete application workflow, not just the model’s response to a prompt.
How should organisations test AI applications for prompt injection?
Use an authorised test environment with controlled documents or webpages containing conflicting instructions. Check whether those instructions influence responses, data retrieval or tool use beyond the intended task. Record the evidence, assess the impact, implement controls and repeat the tests after changes to the model or application.