Defending AI Agents
עברית Join waitlist
Menu

Module 00 · Lesson 04

Two kinds of defence, and which to trust first

Every control in this course is one of two kinds.

By design. What the system cannot do, whatever the model says. The agent holds no credential for the payments API. The shell runs in a container with no network. Text read from an e-mail is labelled untrusted, and no tool call with an untrusted argument may send mail. These are statements about the system, and they hold for every input on the paths they cover, including inputs nobody imagined. A design control either removes a capability (the credential, the network) or is a deterministic rule on a fact the system itself established: the destination's domain, or where a value came from, as with the e-mail's label.

By detection. What a classifier flags. An injection detector scores the e-mail at 0.93. A behavioural model notices this agent has never written to that bucket before. These are statements about a distribution, and they hold on average, for inputs like the ones the classifier was measured on.

By design By detection
Guarantee Structural: holds for every input Statistical: holds on the measured population
Against an adaptive attacker Unaffected by how the attack is phrased Degrades: the attacker searches for the miss
Cost Lost capability: tasks the agent can no longer do False positives: work denied or held for review
Failure mode Too rigid, so people route around it (loud); or incomplete, missing a path it never modelled (silent) Silent misses, and alert fatigue
When it is the right tool The harm is clear and the rule is cheap to state The harm depends on content no rule can describe

The order of trust

Design first, detection second, and a person for what is left.

This is not because detectors are bad. Detectors are what you have when a design rule would cost too much capability, and most of the course is about building and judging them properly. It is because the two fail differently. A design rule that is too strict fails loudly: a task stops working, and someone complains. A detector that fails, fails quietly: an attack that scored 0.48 against a threshold of 0.5 looks exactly like a normal day. A design rule can fail quietly too, in one way: a path it never modelled. EchoLeak's way out was a fetch by the client, not a tool call, so a rule on tool calls never saw it. That failure is in the design, so you find it by reviewing the paths (Module 2's doors), never by watching the rule fire.

A useful reflex: for any detector you propose, ask what design change would make it unnecessary, and what that change would cost. Sometimes the answer is "nothing much", and you have just saved yourself a classifier.

A third thing that is not a defence

"The model was told not to" belongs to neither column. System-prompt instructions shift probabilities in a way nobody has measured on your inputs. Use them, and count them as zero.

Check yourself

  1. Classify each as design or detection: an allow-list of e-mail domains; a regex for AWS keys in outbound text; a rule that git push to a public remote needs approval; a model that scores whether a tool call matches the user's task.
  2. The AWS-key regex is deterministic. Is it a design control? What distinguishes "deterministic" from "by design"?
Answers
  1. Allow-list of e-mail domains: design. Regex for AWS keys: detection. Approval for git push to a public remote: design. A model scoring whether a call matches the task: detection.
  2. No. Deterministic means the same input always gets the same verdict; by design means the guarantee holds for every input on the path, however it is written. The regex catches keys written in the form it knows, so a key that is base64-encoded, split or paraphrased passes: its verdict depends on the attacker's phrasing, which makes it detection.