Module 00 · Lesson 05
The hard questions in agent security are five statistics problems
The hardest questions in agent security are statistical, and each has a name you already know.
1. Rare events
An agent makes 10,000 tool calls. One is an attack. Your detector catches 99% of attacks and flags 1% of harmless calls. When it fires, how often is it right? Write \pi for the base rate (here 10^{-4}), TPR for the recall (0.99) and FPR for the false-positive rate (0.01):
About 101 alerts, one of them real. The detector is excellent; its alerts are not. Prior shift from a balanced test set to a production base rate is Bayes' theorem, and it is the reason security operations teams have more alerts than people to read them. Module 7.
2. Operating points under a budget
Every threshold spends a false-positive budget, and the budget belongs to an action. Flagging for a dashboard can afford 1%. Holding a call for a person costs minutes of someone's time each. Denying costs a broken workflow. So a detector does not have a threshold; it has one per action, each set from that action's budget, with a confidence bound because you estimated the FPR from a finite sample. That is Neyman-Pearson classification. Module 7.
3. Distribution shift
A prompt-injection classifier is trained and tested on prose. In production it reads tool arguments: JSON, diffs, SQL, log lines, base64. The population moved; the model did not. Covariate shift, and the reason "98% accuracy on the benchmark" predicts little about your traffic. Module 8.
4. An adversary who moves second
Your test set was fixed before the attacker saw your detector. The attacker's test set is chosen after. Average-case risk on a static benchmark estimates the wrong quantity; what matters is worst-case risk over the inputs an attacker can reach with a given effort, reported as a curve with intervals. Module 9.
5. Evaluating a change you have not made
"Would the new policy have caught last month's incident, and how many extra holds would it have caused?" That is a counterfactual question about a policy you did not run, answered from logs collected under the one you did. Off-policy evaluation, with the usual trap: if the old policy never allowed a kind of call, you have no outcomes for it. Module 16.
What security adds
The statistics is familiar. The security part is knowing which distribution, which cost and which adversary, and that is what the rest of the course supplies. The other half is design: removing the need for some of these estimates altogether (lesson 4).
Check yourself
- In the example, what FPR would make half the alerts real, at the same TPR and base rate?
- The same detector is moved from scoring prose to scoring tool arguments, and its FPR rises from 1% to 3%. Which of the five problems is this, and what does it do to the precision in the example?
- Which of the five problems can a red-team report with no benign traffic in it speak to, which can it not, and why?
Answers
- \text{FPR} = \text{TPR}\,\pi/(1-\pi) = 0.99 \times 10^{-4}/0.9999 = 9.9 \times 10^{-5}, about one in ten thousand: a hundred times lower than the detector's 1%.
- Distribution shift (problem 3): the benign population moved from prose to JSON, diffs and SQL. Precision falls from 0.98% to 0.99 \times 10^{-4}/(0.99 \times 10^{-4} + 0.03 \times 0.9999) = 0.33\%, about 301 alerts per 10,000 calls with one real.
- It speaks to the adversary who moves second (problem 4) and to the TPR half of rare events (problem 1). It cannot speak to the rest, because each needs benign traffic: precision (problem 1) and a threshold set against a false-positive budget (problem 2) need the FPR; the shift in problem 3 is a move of the benign population; and problem 5's extra holds are benign calls held, counted in last month's logs.