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.
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.
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