Instructions Are DataRequest a copy
Cover of Instructions Are Data: Systems, Security, and the Boundaries of Code, by Rez Khan, PhD

A book in progress by Rez Khan, PhD

Instructions Are Data

Systems, Security, and the Boundaries of Code

A practical guide to building AI agent systems when the model at the centre cannot be trusted to enforce its own boundaries. Agents read email, tickets, web pages, and code, and then they act. Anyone who can put text in front of an agent can try to direct it. This book shows how to design the system around the model so that the outcome stays acceptable when they succeed.

Advance review edition. All seventeen chapters drafted; labs and fact-checking under way.

The argument

Assume the agent can be steered. Then make that survivable.

A language model reads its operator's rules, its user's request, and a stranger's web page as one stream of text. It has no reliable way to tell an instruction from a piece of data. Agent security is therefore classic security reappearing in a new place: the confused deputy, in-band signaling, and stored cross-site scripting, with an interpreter that reads natural language and takes requests from other agents.

The book does not rely on the model resisting manipulation. It asks what the surrounding system lets a steered model do, and it builds controls that hold whatever the model has been persuaded of.

What you learn

Five ideas that carry most of the weight.

  • Gates, not only guardrails. Prompt instructions and classifiers lower the rate of successful attacks. A gate is enforced by the harness around the model: a permission, an approval, an egress rule. The book counts the two separately.
  • Source-to-sink tracing. A threat-modeling method for agents: list every place untrusted text can enter, every action that matters, and every path between them, through memory, shared stores, and other agents. Then cut, gate, or knowingly accept each one.
  • Breaking the lethal trifecta. No agent exposed to untrusted content should reach both private data and an outbound channel. Exposure tracking in the harness enforces it.
  • Attenuated delegation. Authority passed between agents can only shrink at each hop, so no message an agent is persuaded to send can grant an operation its original principal never had.
  • Typed boundaries. Untrusted content reaches privileged code only as values with narrow types, extracted by a quarantined reader. The attacker can still choose among allowed values, and the book bounds how much that choice can carry.

How it works

One fictional company, attacked and then rebuilt.

Part I

The attack surface

Why agents break the old model, how an agent system is built, and a method for tracing untrusted text to consequential actions.

Parts III and IV

Defenses and operations

Least privilege, isolation, identity and delegation, human approval, guardrails, red teaming, observability, and governance, with every attack re-run against the hardened system.

How firmly it is known

Every claim says whether it is proved, measured, documented, or judged.

Proved, and checked by machine

An appendix states the book's core rules as theorems over a model in which the language model may do anything at all with what it reads. The main results are checked in the Lean 4 proof assistant.

  • Noninterference for integrity and for confidentiality
  • The lethal trifecta rule, stated for the values that leave the system
  • A bound, in bits, on what crosses a typed boundary
  • Attenuation of delegation chains

What the proofs do not say

They say nothing about how often a model is steered. That is measured, in labs that report a rate with the number of runs, the model, and the date. They also assume the harness labels every source correctly and checks every action when it runs. The book lists those assumptions and maps each to the code that must meet it.

Who it is for

Engineers who build agent systems, and the people who review them.

Readers should program fluently in Python or TypeScript and know basic security vocabulary. No background in machine learning is needed. By the end, a reader can threat-model a multi-agent system, attack it in a lab, and ship it with controls they can defend.

Advance copies

Reviewing agent security, or hiring for it? Ask for an advance copy.