part II · chapter 8 of 17

Guardrails and AI security

Protecting an AI app from hostile input, leaks, unsafe output and runaway agents.

why it matters

The model cannot protect itself. This is what makes an AI feature safe to ship.

before this: chapter 7, Agents and tools

being written

This chapter is being written. Here is what it will cover; until then, the full topic list is in our notes.

  • direct and indirect prompt injection
  • output validation, PII redaction, moderation
  • least privilege and sandboxing for agents
  • data poisoning and tenant isolation
the topic list on GitHub (opens in a new tab)

you reached the end of the chapter

build this

Attack your own retrieval app (cross-user leaks, injected documents, key exposure) and add a check for each.

the maths underneath

  • maths note 9

    Statistics for evals

    p^±1.96p^(1−p^)n\hat{p} \pm 1.96 \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}

    80% on a hundred questions is somewhere between 72% and 88%. Without this, noise ships as an improvement.

check yourself

Tick what you could explain to someone else, out loud, without notes.