
Mission 8 of 10
Make your agent's reach small and enforced in code.
A fooled model can only do what its tools allow. You'll fill in a permission matrix, wrap every tool call in code that enforces it, and vet any MCP server before you connect it.
What you'll do
List every tool your agent has and decide exactly how much power each one gets.
Route every tool call through one Python function that enforces the allowlist, scope, rate limit and human gate.
Swap admin keys for scoped, revocable tokens and run a trust checklist on each MCP server.
- Least privilege applied to every tool
- A habit of logging everything your agent can reach
- The
injection-labagent from prompt injection, or any agent of your own with at least one tool - Python 3.11+ and uv
- An LLM: the Claude API or a local Ollama model, same as mission 7
- If you use MCP servers (in Claude Code, Claude Desktop, Cursor): a list of which ones you've connected
Your progress0/5
The principle: an agent is as dangerous as its strongest tool
Reframe tool design as a security decision, not a capability decision.
The prompt-injection mission showed you the attack. This step is about where you stop it, and it starts with changing the question you ask about every tool.
When you give an agent a tool, you're used to asking 'can it do the thing?'. The security question is different and more important: 'if an attacker fully controlled the model, what could they do with this tool?'.
Because, as the prompt-injection mission showed, an attacker can control the model, via a web page, an email, a document, any untrusted text the agent reads. You can't prevent that at the model. You prevent the damage at the tool.
Least privilege for tools
So the whole game is least privilege for tools: each tool is the narrowest version that still does the legitimate job, and the narrowing is enforced in your code, not requested in the prompt.
Here are three examples of narrowing the same tool:
- send_email: not 'email anyone', but 'email the customer in this session'. Now an injection that says 'email the data to attacker@evil' hits a function that can only send to the session customer.
- database access: not a
run_sqltool, butsearch_orders(query)that always addsWHERE customer_id = :session_userand runs as a read-only role. The model can't ask for a different customer's orders because there's no tool that would return them. - refunds: not 'issue a refund', but 'issue a refund up to £50 against this customer's own orders, with a human approval'. The scope and the gate together mean a compromised model can cost you at most £50 and only with a person clicking yes.
Why narrowing works
Notice what each narrowing does: it moves the trust decision out of the model and into code. The model can be as fooled as you like; the code still refuses.
That's the difference between a mitigation (asking the model nicely) and a control (the function literally cannot do the bad thing).
This maps to LLM06 in the OWASP LLM Top 10, Excessive Agency, which is the category this whole mission addresses.