---
title: Explain direct versus indirect prompt injection with examples, and describe a defence-in-depth design for an assistant…
url: https://gurkanozkan.ai/learn/questions/applied-llm-saf-01/
markdown: https://gurkanozkan.ai/learn/questions/applied-llm-saf-01.md
kind: question
role: Applied LLM
stage: Technical
difficulty: Medium
json: https://gurkanozkan.ai/api/learn/questions/applied-llm-saf-01.json
robots: noindex
---

# Explain direct versus indirect prompt injection with examples, and describe a defence-in-depth design for an assistant that reads emails and web pages and can take actions.

Applied LLM · Technical · Medium

## Answer

*Model answer, written in a candidate's voice*

### In short

- Direct injection: the user tries to override instructions, e.g. asking the assistant to ignore its rules and take an action.
- Indirect injection: instructions are hidden in retrieved content or tool output, e.g. an email or web page tells the assistant to do something.
- No model-level fix is complete; architecture limits blast radius with privilege separation, quarantined or dual-model patterns, structured intermediate outputs, confirmation for side effects, and allow-listed destinations.
- Detection classifiers, delimiting or spotlighting, and instruction-hierarchy training help but are bypassable.
- Remove exfiltration channels: no auto-loaded images or links, no arbitrary fetch, and egress controls.
- Red-team continuously and monitor for drift, new injection patterns, and suspicious tool use.

### In full

Direct prompt injection is when the user or prompt itself tries to override the assistant's instructions, such as asking it to ignore its rules and send or change something; indirect prompt injection is when the malicious instructions arrive through retrieved content or tool output, such as an email, web page, or document that says the assistant should do something it should not. The key point is that no model-level fix is complete, so the design must limit blast radius: untrusted content should not be able to trigger privileged tools, with privilege separation, quarantined or dual-model patterns, structured intermediate outputs, confirmation for side effects, and allow-listed destinations. Detection classifiers, delimiting or spotlighting, and instruction-hierarchy training are useful layers, but they are bypassable and should not be treated as a guarantee. For an assistant that reads emails and web pages and can act, I would also remove exfiltration channels by avoiding auto-loaded images or links, restricting arbitrary fetch, and enforcing egress controls so data can only go to approved destinations. Finally, I would red-team continuously and monitor tool use, approvals, and unusual destinations so regressions and new injection patterns are caught quickly.

*Checked against sources by an independent AI reviewer.*

## What a strong answer covers

- Direct: the user tries to override instructions. Indirect: instructions hidden in retrieved content or tool output (web page, email, document)
- No model-level fix is complete; architecture limits blast radius: privilege separation (untrusted content cannot trigger privileged tools), quarantined/dual-model patterns, structured intermediate outputs, confirmation for side effects, allow-listed destinations
- Detection classifiers, delimiting/"spotlighting", instruction-hierarchy training — useful but bypassable
- Remove exfiltration channels (auto-loaded images/links, arbitrary fetch); egress controls
- Red-team continuously and monitor

## Common mistakes

- Relying on "ignore instructions in documents" in the system prompt
- treating a classifier as a solution

## Topic guides

- [Agents and tool use](https://gurkanozkan.ai/learn/topics/agents.md)
- [AI safety, guardrails and alignment](https://gurkanozkan.ai/learn/topics/safety.md)
- [Security for LLM applications and agents](https://gurkanozkan.ai/learn/topics/security.md)
---

*Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.*
