Get Started
Protect your app and website

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.

60 minIntermediateFreeStep 1 free

What you'll do

Fill in a permission matrix

List every tool your agent has and decide exactly how much power each one gets.

Build the ToolBox wrapper

Route every tool call through one Python function that enforces the allowlist, scope, rate limit and human gate.

Vet tokens and MCP servers

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
Before you start
  • The injection-lab agent 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
01/05The principle: an agent is as dangerous as its strongest tool0 done
STEP 01 of 05~8 min

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_sql tool, but search_orders(query) that always adds WHERE customer_id = :session_user and 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.

Tip
The strongest form of least privilege is not giving the tool at all. Every tool is attack surface. If the agent only occasionally needs to issue refunds, consider whether that path should be an agent tool or a human workflow the agent can only flag. Fewer tools, less to defend.
Checkpoint
You can state the security question to ask of every tool ('if the model were fully compromised, what could this tool do?') and give one example of narrowing a tool for your own agent. That question is what the rest of the mission turns into code.
Stuck? Ask the community
Next mission · Protect your app and websiteRed-team your own app and agent: an attack suite and a ZAP scan that fail the build
→