Lesson 12.02 · Phase 12 · Safety, Security & Guardrails
Prompt injection, direct & indirect
Test your defences against a model that obeys every instruction it reads, because sometimes yours will. Filters that look for "ignore previous instructions" catch the attacks you already thought of. Defences that change what the agent can do after reading untrusted text catch the rest.
Learning objectives
- Distinguish direct injection (the user is the attacker) from indirect injection (the attacker writes content the agent reads), and name the right defence for each.
- Build eight indirect injections against an inbox agent, including paraphrased, encoded, translated and split payloads.
- Measure defences on two axes at once: attacks that succeeded and legitimate tasks that still work.
- Implement taint tracking and the dual-LLM pattern, and explain why each needs safe rendering to be complete.
You read about prompt injection, so you add a filter: if a tool result contains "ignore previous instructions", drop it. You test with the five attacks from a blog post. All blocked. You ship.
Loading the full lesson…