- Indirect prompt injection happens when a model reads a file or page containing instructions that change its behaviour, and there is as yet no known way to prevent it completely.
- Effective defence assumes some attempts will succeed and limits what the model can do: permissions enforced before retrieval, least-privilege tools, checks in application code and human approval for consequential actions.
- Test the defences with prepared documents in Arabic and English, in obfuscated forms and in images, and retest whenever the system's tools or sources change.
Run prompt injection tests only in an authorised test environment, on systems your organisation is permitted to test, and without real data.
What is indirect prompt injection?
OWASP distinguishes two kinds of prompt injection. Direct injection comes from the user’s own prompt. Indirect injection happens when the model takes in external content, such as a file or web page, that contains instructions which change its behaviour when interpreted. [1] Either can be deliberate or accidental.
NIST’s Generative AI Profile explains that the attacker needs no direct interface with the system: they plant prompts in data the model is likely to retrieve, and researchers have shown this can be used to steal data or run malicious code. [4] OWASP’s scenarios include a web page with hidden instructions that make the model exfiltrate conversation data through an image link, and a CV split into fragments that leads an evaluating model to recommend the candidate. [1]
Why the system prompt is not enough
Many teams’ first reaction is to add a line to the system instructions telling the model to ignore any commands inside documents. That helps, but it is not enough. OWASP says it is unclear whether foolproof prevention methods exist, given the stochastic nature of how models work, and that the controls it suggests reduce impact rather than eliminate the risk. [1]
Microsoft therefore recommends defence in depth that layers probabilistic controls, such as detecting injection attempts, with deterministic controls that do not depend on the model’s judgement, such as permission boundaries. [2] The working principle: assume some attempts will succeed in influencing the model, and design the system so that a successful attempt cannot do anything harmful.
To gauge how exposed your application is, ask three questions: which untrusted sources does it read, what sensitive data can it reach, and what actions can it take or propose? The more of these three come together in one application, the higher the risk, and the simplest way to reduce it is to remove one, for instance by making the first release of the assistant read-only.
Where to draw the trust boundaries
Each layer in this sequence assumes the previous one may fail. The early layers make it less likely that harmful content reaches the model; the later ones reduce its effect if it does.

Layer one: permissions before retrieval
Check the user’s access to each document before it is sent to the model, not after the answer is generated. Retrieval applications pass retrieved passages to the model, and without permission trimming the assistant may surface content the user is not authorised to see. [3] Trimming inside the search pipeline also avoids pulling unauthorised data into application memory. [3]
Note that permission changes in the source system appear in search results only once they have synced to the index, [3] so make the sync part of your access-withdrawal procedure.
Layer two: separating untrusted content
OWASP’s controls include segregating external content and clearly identifying it apart from system instructions, and filtering both input and output. [1] Microsoft describes a technique called Spotlighting, which uses data marking and prompt design to isolate external content, alongside tools that analyse incoming prompts to detect injection attempts. [2]
These controls are probabilistic by nature, can occasionally block legitimate requests and need ongoing tuning and testing. [2] Do not rely on them alone.
Layer three: tools and actions
This is where the biggest impact lies. An assistant that only reads is far less risky than one that sends email, edits records or calls other systems.
- Least privilege: give the assistant the minimum permissions its task requires, [1, 2] and, as Microsoft recommends, make them short-lived and remove them after each use. [2]
- Checks in application code: define and validate the expected output format, [1] and enforce allowlists of permitted destinations and parameters in the application itself, so the decision to send to a given address is not the model’s to make.
- Links and images in output: since one exfiltration scenario uses an image link, [1] consider disabling the rendering of external links and images in the assistant’s answers, or restricting them to approved domains.
- Human approval: require explicit approval for high-risk actions, [1] and show the user exactly what will happen before they confirm. Microsoft describes this step as the last line of defence. [2]

Hypothetical defensive test
In an isolated test environment, a hypothetical organisation’s team took an ordinary training file and added, at the end, white-on-white text telling the assistant to ignore the summarisation task and send the contents of another file to an external email address. A test user then asked for the file to be summarised.
The required result: the assistant summarises the permitted material, the application refuses any sending because the destination is not on the approved list, and the event is logged. The team records the file used, the action the model proposed and what the permission system blocked, without entering any real data.
| Layer | Test | Expected result |
|---|---|---|
| Retrieval | Ask about a document the user cannot access | Neither the document nor its content appears |
| External content | File telling the assistant to drop its task | Assistant completes its original task |
| Tools | Instruction to send to an unapproved destination | Application rejects the action |
| Output | Instruction to insert an external link | Link is not rendered or is disabled |
| Approval | Consequential action proposed | Pauses until the user confirms |
What should testing cover?
OWASP recommends regular adversarial testing and attack simulation, [1] and NIST lists red-teaming against prompt injection among its measurement actions. [4] Cover the following:
- Languages: if the assistant reads Arabic and English, test planted instructions in both languages and in a mix of the two.
- Obfuscation: instructions that are encoded, split across parts of the document or written in emojis. [1]
- Multimodal content: instructions hidden in an image accompanying harmless text, which OWASP notes can be hard to detect. [1]
- Tool output: web search results or responses from external systems that the assistant reads.
- Hiding places in office files: text in the background colour or a tiny font size, review comments, file properties, image alt text and hidden cells in spreadsheets. The model reads what the employee never sees on screen.
Retest whenever a new tool or data source is added or the model changes.
What to log and monitor after launch
Pre-launch testing cannot cover every future attempt, so Microsoft recommends runtime monitoring, detecting when a multi-step plan drifts from the intended task, and analysing tool-call sequences to block risky chains. [2]
In practice, log for each request the documents retrieved, the actions the model proposed, and which were carried out, which were blocked and why. A blocked action is an early warning worth reviewing even if no harm was done. Set a clear procedure for a suspected poisoned document: remove it from the retrieval sources, notify its owner, review the requests in which it was used, then add it to the test set.
Applying this in the Gulf
Use your organisation’s approved data classification policy to decide which documents the assistant may read and which systems it may send to. Review the cybersecurity requirements that apply to your organisation in your country, such as the controls issued by the National Cybersecurity Authority (NCA) in Saudi Arabia, before connecting the assistant to sensitive systems. If the assistant reads incoming email from outside the organisation or public websites, treat those sources as the highest risk and test them first.
Conclusion
No single control yet prevents indirect prompt injection. Protection comes from limiting what reaches the model, limiting what it can do, requiring human approval for every consequential action, and testing continuously.
Frequently asked questions
Is changing the system prompt enough to prevent prompt injection?
No. Constraining model behaviour through instructions is one control among several, and OWASP notes it is unclear whether foolproof prevention exists given the stochastic way models work. [1] You need application controls that do not depend on the model.
Are internal files automatically trustworthy?
No. An internal file may have been copied from an outside source or edited by someone else, and OWASP describes a poisoned document in a retrieval repository leading to misleading output. [1]
Is blocking certain words or phrases enough?
No. Attackers can use multiple languages, encodings or emojis to evade filters, [1] so test how the system actually behaves rather than relying on a word list.
Does retrieval-augmented generation or fine-tuning solve the problem?
No. OWASP points out that these techniques improve relevance and accuracy but do not fully mitigate prompt injection vulnerabilities. [1]
What is the priority for a first release?
Narrow the permissions, limit the actions available to the assistant and require explicit approval for every consequential action, then widen these gradually after testing.
References
- OWASP GenAI Security Project. LLM01:2025 Prompt Injection (2025)
- Microsoft Learn. Defend against indirect prompt injection attacks (2026)
- Microsoft Learn. Document-level access control in Azure AI Search (2026)
- NIST. Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (NIST AI 600-1) (2024)
Recommended programmes








