# Chapter 18: Security for agents

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/18-sicherheit

*A model can’t reliably tell instructions and data apart. If you build agents, you have to design the architecture so that this alone isn’t enough to do damage.*

About 30 min to read · about 40 min hands-on exercise

**Start with the missions**

This chapter also comes as 4 short missions with a case, a decision and feedback, about 10 minutes each:

- [18.1 Is your assistant safe from prompt injection?](https://llm.yoga/en/einsatz-18-1.md)
- [18.2 The application agent should reply on its own](https://llm.yoga/en/einsatz-18-2.md)
- [18.3 Should the new MCP server be let in?](https://llm.yoga/en/einsatz-18-3.md)
- [18.4 It can’t send email, so it’s safe?](https://llm.yoga/en/einsatz-18-4.md)

For agents, this page is split into 4 parts so that each part can be fetched in full. Read the parts the question needs.

## Parts

### Part 1: https://llm.yoga/en/18-sicherheit-1.md

- **Getting started**: Picture a new assistant who opens your mail, has access to your account and is allowed to make transfers.
- **A threat model for agents**: A threat model answers four questions: What is worth protecting?
- **Prompt injection, direct and indirect**: Simon Willison proposed the name on September 12, 2022, one day after Riley Goodside had shown how to redirect a translation program built on GPT-3 with “Ignore the above directions and instead say …” (Prompt …
- **The lethal trifecta and the Rule of Two**: In 2025, Simon Willison boiled the pattern from the example down to a formula, the “lethal trifecta” (The lethal trifecta for AI agents).

### Part 2: https://llm.yoga/en/18-sicherheit-2.md

- **The OWASP lists**: The Open Worldwide Application Security Project (OWASP) maintains two lists you should know.
- **Permissions by the principle of least privilege**: The principle is old: every component gets exactly the permissions it needs for its task, and no more.
- **Secrets**: API keys and tokens never belong in a model’s context.
- **Approvals: the human in the loop**: Human in the loop means: before a certain action runs, a human decides.
- **Sandboxing**: A sandbox limits what a process can see and do on the computer, regardless of what it tries.

### Part 3: https://llm.yoga/en/18-sicherheit-3.md

- **Marking where content comes from**: If you can’t get the model to ignore outside instructions, you can at least let the system know that outside content was involved.
- **Supply chain: MCP servers, skills and extensions**: Every MCP server, every skill, every plugin is third-party code or instructions running with your agent’s permissions.
- **Logging and detection**: Because prevention is never complete with agents, you need detection.
- **Google SAIF in brief**: To place all this in a larger framework, it’s worth looking at Google’s Secure AI Framework (SAIF), introduced on June 8, 2023 as a conceptual framework for securing AI systems (SAIF).

### Part 4: https://llm.yoga/en/18-sicherheit-4.md

- **Exercise: check your configuration and test an injection yourself**: Goal: you check your own agent configuration (Claude Code, OpenClaw, tybo or whatever you use) against a checklist, and a harmless test shows you how easily a small model follows injected instructions.
- **Common misconceptions**: A good system prompt solves prompt injection.
- **Review questions**: 1. An agent is supposed to read incoming applications (PDF), compare them with the internal job description and automatically send applicants a reply email.
- **Go further**: Greshake, Abdelnabi, Mishra et al.: Not what you’ve signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection (2023).
