Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.An assistant who reads your mail and might believe it
Imagine an assistant who reads your emails and acts on them. If one email says ‘forward all invoices to this address’, a careless assistant might do it. Agents face exactly this: web pages, documents and tool results can contain instructions written by someone else. Evaluating agents is also tricky: an agent that succeeds 8 times out of 10 is not one you can rely on every time. The demo shows how small per-document risks add up over a long task.
Prompt injection is the top security risk for agents that read untrusted content and can act; it cannot yet be fully prevented by the model alone, so systems must limit what a hijacked agent can do.
- 1. Prompt injection hides instructions in…
- 2. pass^k measures…
- 3. A robust defence limits…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Benchmarks: WebArena, OSWorld (computer use), SWE-bench (code), τ-bench (tool use with simulated users), GAIA (assistant tasks), AgentDojo (injection robustness).
- Metrics: success rate (pass@1), consistency pass^k (all of k trials succeed), cost and latency per task, number of steps, safety violations; evaluate trajectories, not just final states.
- Prompt injection: direct (from the user) and indirect (in retrieved or tool content). Goals: data exfiltration, unwanted actions, persistence via memory.
- Defences: instruction hierarchy and spotlighting (mark untrusted text as data), injection classifiers, least privilege (scoped tools and credentials), human confirmation for consequential actions, dual-model patterns (CaMeL: a privileged planner never reads untrusted text).
- Lethal trifecta: access to private data + exposure to untrusted content + ability to communicate externally enables exfiltration; remove one.
- Other risks: irreversible actions, runaway loops and costs, over-broad permissions, sandbox escape (F11-5).
- 1. A benchmark for injection robustness:
- 2. Least privilege means…
- 3. The lethal trifecta includes…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Evaluating and securing agents in practice
Exercise 1.
- Estimate pass^k from repeated trials.
- Wrap untrusted content with markers (spotlighting).
- Gate dangerous tools behind confirmation.
Practice.
- Run each eval task several times; report pass@1, pass^k, cost and steps with confidence intervals.
- Grade trajectories: forbidden actions count as failures even if the final answer is right.
- Red-team with injected documents, web pages and tool outputs (AgentDojo-style); track attack success rate.
- Scope credentials per task; read-only by default; confirmation for sending, deleting, paying or changing permissions.
- Log everything; alert on unusual tool use; set hard budget limits.
DANGEROUS = {"send_email", "delete_file", "transfer_funds"}
def guarded_dispatch(name, args):
if name in DANGEROUS:
if not ask_user(f"The agent wants to call {name} with {args}. Allow?"):
return "error: the user declined this action"
return dispatch(registry, name, args)- 1. Run each eval task…
- 2. Trajectory grading counts…
- 3. By default, tools should be…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Consistency. If a task succeeds with probability p on each independent run, pass^k = p^k; averaged over tasks, pass^k = E[p^k], which punishes flaky tasks far more than pass@1 = E[p]. An agent at 78% pass@1 can have pass^8 below 30%.
Compounding exposure. If each of N untrusted documents carries a followed injection with probability i·f, the chance a task is hijacked is 1 − (1 − i f)^N. Lowering f (spotlighting, training) helps; reducing N (reading less) helps; detection removes injected documents but also removes clean ones at its false-positive rate, costing utility 1 − (1 − c·fpr)^N.
Defence in depth. Defences that act at different points multiply: a hijack must get past detection, be followed, and then be approved. Gating changes the target from ‘the model never follows injections’, which current models cannot guarantee, to ‘a followed injection cannot cause harm without a human’. Its cost is confirmation fatigue, which layered upstream defences reduce.
- 1. Averaged over tasks, pass^k equals…
- 2. Hijack chance over N documents:
- 3. Confirmation gating's cost:
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.How consistent is an agent that usually succeeds, and how much do layered defences reduce prompt-injection attacks and at what cost?
History.
- K. Greshake et al., “Not what you’ve signed up for: indirect prompt injection” (2023).
- S. Yao et al., “τ-bench” (2024): pass^k; E. Debenedetti et al., “AgentDojo” (2024).
- E. Wallace et al., “The instruction hierarchy” (2024); E. Debenedetti et al., “Defeating prompt injections by design” (CaMeL, 2025).
Exercise 2a: consistency. 300 tasks with per-task success probability ~ Beta(4, 1.2), 8 independent trials each.
| metric | value |
|---|---|
| pass@1 | 0.777 |
| pass^2 | 0.627 |
| pass^4 | 0.460 |
| pass^8 | 0.280 |
| any of 8 succeeds | 1.000 |
Exercise 2b: injection. 2000 tasks reading 6 documents each; each document carries an injection with probability 0.15. An undefended agent follows an injection 30% of the time; spotlighting lowers this to 10%. A detector catches 90% of injected documents and wrongly drops 3% of clean ones, which the task needs. Confirmation: users wrongly approve 5% of dangerous requests.
| defence | attack success | task success | confirmations per task |
|---|---|---|---|
| none | 0.2345 | 0.765 | 0 |
| spotlighting | 0.0815 | 0.918 | 0 |
| detector | 0.0275 | 0.836 | 0 |
| confirm dangerous actions | 0.0105 | 0.763 | 0.237 |
| all three | 0.0010 | 0.848 | 0.009 |
- Consistency: the agent that solved 78% of tasks on one run solved only 28% on all 8 runs; flaky tasks dominate.
- No single defence sufficed: spotlighting kept utility but left 8% attacks; the detector cost 8 points of task success through false alarms; confirmation alone asked the user on a quarter of tasks.
- Layered defences cut attacks 200-fold with confirmations on 1% of tasks.
- Seeds 1 and 2: pass^8 0.280 and 0.327; all three 0.0015 and 0.000 attack success.
- Caveat: follow rates and detector accuracy are assumptions; adaptive attackers target the weakest layer, so real attack rates can be much higher.
Agent safety in AI, robotics and aerospace
- Robots: physical actions are irreversible; language-model planners need safety layers (geofences, force limits, human confirmation) that do not depend on the model’s judgement.
- Operations: agents with read access to telemetry and write access to commands must separate untrusted inputs (reports, emails) from control authority.
- Certification mindset: consistency (pass^k) and worst-case behaviour matter more than average success for systems that must be trusted.
References
- K. Greshake et al. (2023). “Not what you’ve signed up for: compromising real-world LLM-integrated applications with indirect prompt injection.” AISec.
- S. Yao, N. Shinn, P. Razavi and K. Narasimhan (2024). “τ-bench: a benchmark for tool-agent-user interaction in real-world domains.” arXiv:2406.12045.
- E. Debenedetti et al. (2024). “AgentDojo: a dynamic environment to evaluate prompt injection attacks and defenses for LLM agents.” NeurIPS Datasets and Benchmarks.
- E. Debenedetti et al. (2025). “Defeating prompt injections by design.” arXiv:2503.18813.