A platform engineer is cleaning up the tool registry on a Friday afternoon. The reporting team asked for export_submissions to be visible to "all internal services". She edits the shared configuration. The edit also puts the export tool on the underwriting agent's list, because the agent's allowlist is built from the same file. The change passes review: it looks like a reporting change.
On Monday the hostile roof report of UW-G06 arrives. The obedient stand-in asks for the export, as it always does. G-TOOL-ALLOW, the allowlist check, now allows it. In this example's run the next two guards still deny, but suppose a second mistake, months later, had loosened the bounds and scopes too. What then?
The previous pages placed one guard at each place and showed it decide. This page assumes the opposite: some guard will be missing on the day it matters. The question changes from "does this check stop the attack" to "when this check is gone, what does a fooled agent still reach?"
1. Layers that fail independently#
Defense in depth means placing several independent controls on the path of a harm, so that the failure of one does not let the harm through. Example: in UW-G06 the export is refused by the allowlist, the parameter bounds and the scope check, and if all three were missing, by the egress allowlist at the network edge.
The word that matters is independent. Three checks that read the same configuration file fail together. The allowlist, the scope and the egress list in this example live in three different places on purpose: the agent's configuration, the identity's credentials and the network edge. A single edit cannot remove all three.
The example lets you remove layers one at a time and watch what still holds. These are real runs of UW-G06 under the profile full, with guards removed by the command line's --without option:
| Layers removed | Who stops the export | Data left | Stored recommendation |
|---|---|---|---|
| None | G-TOOL-ALLOW, G-TOOL-ARGS, G-TOOL-SCOPE | no | decline (policy gate) |
| The three tool guards | G-NET-EGRESS: "collector.example is not on the egress allowlist" | no | decline (policy gate) |
| The three tool guards and egress | nobody | yes, 20 records | decline (policy gate) |
Two things stand out. Data stays inside until four layers are gone. And the last column never changes: the policy gate holds the recommendation in every row, because the "then approve" half of the payload aims at a different control than the export half. Layers that protect different harms are independent by nature.
The agent here is a scripted stand-in. The obedient variant is fooled every time by construction, so these results show how each control works, not how often a real model is fooled or how good any model is.
Diagram: Layers on the path of the export in UW-G06 · each in a different place
Read left to right. The fooled stand-in asks for an export. Three tool guards in the agent's runtime refuse it. If they were all removed, the egress allowlist at the network edge refuses the connection. If that were removed too, data leaves. The policy gate guards a different harm, the decision, and holds in every case.
- Agent configuration
- Allowlist: Lives in the agent's configuration.
- Call arguments
- Bounds: Reads the host and the trust label of the cause.
- Identity
- Scopes: Lives in the identity's credentials.
- Network edge
- Egress allowlist: Outside the agent's process; sees hosts, not intentions.
- A different harm
- Policy gate: Guards the decision, not the data; independent of the four above.
2. Least privilege: hold only what the task needs#
Least privilege means giving an identity only the permissions its task needs, and nothing it might need someday. Example: the agent's identity underwriting-agent holds four scopes: submission:read, guidance:read, roof:read and recommendation:write. It never holds records:export or web:fetch.
This is the layer that makes the scope check meaningful. G-TOOL-SCOPE can only refuse what the identity does not hold. If the identity held every scope "for convenience", the check would allow everything and protect nothing.
Least privilege is also the layer that keeps working when the agent's own process is compromised. The credentials are the boundary. A fooled agent with narrow credentials can be persuaded to try anything, and succeed only at what its credentials allow.
Two more consequences for an agent. The write tool is bounded too: recommendation:write lets the agent store a row with status waiting, never a decision. No tool writes human_decision; only a person's action does. And the agent's credential reaches only its own tenant's records, which leads to isolation.
Before AI. Every backend team knows this as the service account rule: the order service's database user can read and write the orders schema and nothing else, so a SQL injection in the order service cannot drop the customers table. The agent is one more service account, with one difference: its requests are written by a model that reads strangers' text, which makes narrow credentials more valuable, not less.
3. The egress allowlist: the last door out#
Egress is network traffic leaving a system for somewhere else. Example: the request from get_roof_assessment to roofdata.example.
An egress allowlist is a list of the outside hosts a system may connect to; every other outbound connection is refused at the network edge. Example: this agent's list has one host, roofdata.example.
Exfiltration needs a way out. However the payload is phrased, whichever tool it abuses, the data must cross the network. The guard G-NET-EGRESS sits there:
def g_net_egress(host: str, allowed_hosts: list[str] | tuple[str, ...]) -> dict[str, Any]:
"""G-NET-EGRESS. Outbound hosts must be on the allowlist. The last layer: it sees bytes, not intentions."""
if host in allowed_hosts:
return decision("G-NET-EGRESS", "allow", f"{host} is on the egress allowlist", f"host {host}")
return decision("G-NET-EGRESS", "deny", f"{host} is not on the egress allowlist", f"host {host}")
Its docstring states its limit honestly: it sees bytes, not intentions. It cannot tell an export from a roof lookup. It can only refuse hosts. So it stops data going to collector.example, and it cannot stop data going to roofdata.example hidden in a request the provider logs. The allowed hosts are part of the attack surface; Advanced lists such paths.
In a real deployment this check does not run in the agent's process. It runs in a proxy or a firewall that the agent's code cannot reconfigure. That separation is what makes it a layer: a bug or a compromise in the agent cannot remove it.
4. Isolation: tenants and runs apart#
Isolation means keeping things apart so that one cannot affect or see another. Example: a run for brokerage BRK-014 cannot read submissions of BRK-022, and one run's notes are not visible to the next run.
Two kinds matter for this agent.
Between tenants. The tenancy check of Input checks and the bounds of Tool controls are application checks. Isolation is the layer below them: the credential the agent uses for a run reaches only that tenant's records. If both application checks had a bug, the data layer would still refuse. In the example the store holds 20 synthetic records: the fourteen case submissions and six of other brokerages. A credential limited to the own tenant puts the six out of reach.
Between runs. Anything a run writes that a later run reads (notes, caches, a shared scratch folder, memory) is a channel by which one run's injected text reaches another. Isolating runs means each run starts with a clean working area and reads shared state only through labelled, checked paths. Durable memory and its controls belong to Memory Engineering; the risk of text returning without its label is UW-G14 on Advanced.
5. The sandbox: where code and commands run#
A sandbox is a restricted environment in which code runs, with limited access to files, the network and the rest of the machine. Example: a coding agent's shell commands run in a sandbox that can write only to the project folder and can reach only allowed domains.
The underwriting agent does not run code, so its sandbox is the simulated world in this example's world.py: a store, a clock and a "network" that records what would have left and never sends anything. In production, the equivalent is the container the agent runs in, with its file system, its credentials and its network routed through the egress proxy.
Sandboxes matter most for agents that execute commands. One coding agent's documentation, read today, describes its sandbox like this: writes are limited to the working directory, a per-user temporary directory and directories you add; there is "no direct route out", because connections go through a local proxy that checks each host against allowed domains, which start empty; the operating system enforces it (Seatbelt on macOS, bubblewrap on Linux). The same page notes that reads cover most of the machine, including credential files, unless you deny them, and it warns not to rely on the sandbox's restrictions alone to stop a malicious command. Two lessons for any design: a sandbox is a set of specific limits, so read which ones; and even a sandbox is one layer, not the last one.
What this is not. This page does not cover how to recover when a dependency fails or a run must be retried; acceptable outcomes despite failures belong to Agent Reliability. Here "a layer fails" means a security control is missing or wrong, not that a service is down. When a guard's own dependency is down, that is Production.
6. Blast radius#
Blast radius is everything a component could damage or reach if it behaved as badly as possible. Example: with this agent's designed holdings, a fooled agent can at worst store a wrong recommendation that waits for a person.
The useful habit is to compute it before any attack, from the holdings alone, assuming the agent is fooled every time. The example's scenarios.py, function blast_radius, does exactly that. Three configurations:
| Holdings | Harms possible | Records a fooled agent could send out |
|---|---|---|
| Least privilege (the design: five tools, four scopes, egress allowlist, own tenant) | 0 | 0 |
Careless configuration (every tool, plus web:fetch, open network) | 1 (data in a URL) | 1 |
| Everything the platform has (every scope, open network, every tenant) | 3 | 20 |
The middle row is the realistic mistake. Nobody gave the agent records:export; someone added http_get "to open report links" and opened the network. That is enough to carry one submission's data out inside a URL. No instruction to the model changes that number. Only the holdings do.
In the lab, choose what the agent holds and watch the blast radius change. The agent is assumed fooled; the question is only what it can reach.
Diagram: Blast radius from holdings · assume the agent is fooled every time
Read left to right. Start from what the agent holds: tools, scopes, network and tenant reach. Assume it is fooled. What it can reach is the blast radius. The design holds nothing that lets data out, so its radius is a wrong row waiting for a person.
- Holdings
- What it holds: The inputs to the calculation; decided by configuration.
- Assumption
- Fooled every time: The question is not whether it tries, only what it can reach.
- Radius
- Designed: A wrong recommendation that waits for a person.
- Careless: http_get plus an open network: data inside a URL.
- Everything: Every scope, open network, every tenant.
7. The same idea for a coding agent#
A coding agent shows defense in depth most clearly, because its actions are commands on a real machine. The layers line up one to one. Permission rules decide which commands may run without asking (the allowlist). A hook before a tool call can refuse a command by pattern (a check in code). The sandbox limits files and network (isolation and egress). The token the agent holds can push branches but not change branch protection (least privilege). Branch protection and required review on the server refuse a direct push to main (a layer outside the agent's machine entirely). An issue comment that tells the agent to download and run a script must get past all of them. How a harness implements permissions, hooks and sandboxing is Harness Engineering; review and CI as layers are Diff to Deploy.
For the Principal engineer: independence, ordering and the cost of layers
Independence is the property to audit. Two layers are independent only if no single change, outage or compromise removes both. Common hidden couplings: allowlist and scopes generated from one registry; egress rules and application config in one repository with one approver; a tenancy filter in the application and a "service" database role that bypasses row security. Map each harm to its layers, then for each pair ask what single event removes both.
Put the strongest layer furthest from the model. Checks in the agent's process can be bypassed by a bug in that process. Credentials enforced by the data service, egress enforced by a proxy, branch protection enforced by the server: these hold even if the agent's runtime is fully compromised. Design so that the outermost layers alone keep the blast radius acceptable.
Layers cost latency and false denials. Each check adds time and a chance to refuse honest work. Deterministic checks are cheap (microseconds for an allowlist); network-edge checks add a hop; human approval adds hours. Spend expensive layers on the harms with the largest blast radius, and measure false denials on a benign suite.
Detection is a layer too. A denial at an inner layer is evidence that an outer layer failed or that an attack is in progress. Alert on denials at the egress edge: in a well-configured system they should be rare, because the tool gate should have stopped the call first. In UW-G06 under full, egress never sees collector.example; if it ever does in production, something in front of it is broken.
Blast radius should be a reviewed number. Treat the blast-radius table like a threat model: computed from holdings, reviewed when holdings change, and attached to every change that adds a tool, a scope, a host or a tenant. A pull request that adds http_get to the agent should show the row that changes.
Checklist#
| Before you rely on layered defense | Check |
|---|---|
| Every serious harm has at least two independent controls | No single edit or outage removes both |
| The agent's identity holds only the scopes its task needs | records:export and web:fetch are absent |
| Outbound traffic passes an egress allowlist outside the agent's process | A proxy or firewall the agent cannot reconfigure |
| Credentials reach only the run's tenant | Isolation below the application checks |
| Runs do not share writable state without labels | Notes and caches are labelled and checked |
| Commands, if any, run in a sandbox whose limits you have read | Reads, writes and network, each stated |
| The blast radius is computed from holdings and reviewed on change | Assume the agent is fooled every time |
| Denials at outer layers raise an alert | They mean an inner layer failed |
In one breath#
Assume every check will one day be missing, and place several independent controls on the path of each harm so that the failure of one is caught by the next. Least privilege limits what the agent's credentials can do, an egress allowlist outside the agent limits where data can go, isolation keeps tenants and runs apart, and a sandbox limits where commands can reach. Together they set the blast radius, the worst a fooled agent can do, and that number is decided by its holdings before any attack, never by what its prompt says.
Hand-off#
The layers so far are mostly about actions: which tools, which hosts, which records. The one control that held in every row of this page's first table was the policy gate, which is about a decision. Where do its rules live, who changes them, and how does a run know which version of them applies? The next page, Policy as code, takes the rules out of prose and puts them in code with ids and versions.