AssayAssay
07 / 09

Lesson 07 · Defence in depth · 13 min

Least privilege and sandboxing

Every lesson so far has pushed toward one stance: assume the agent will be compromised, and make that assumption survivable. Least privilege is that stance as an engineering rule. The agent gets the minimum tools, the minimum data, the minimum authority its task requires — so that a successful attack reaches a small blast radius rather than everything.

Least privilege bounds the blast radiusCompromised agentBroad credentialall tenants, all tools, write accessScoped credentialone tenant, read-only, allowlisted egressreaches everythingreaches almost nothingsame compromise, two very different mornings
The question is never only 'will the agent be compromised' — assume it will. It is 'what can it reach when it is'. A scoped credential turns a breach into a contained incident.
  • Tools: give the agent only the tools its task needs. A support agent that never issues refunds should not have the refund tool available to be tricked into calling.
  • Credentials: scope them — one tenant, read-only where possible, short-lived. A read credential cannot be steered into a write.
  • Egress: allowlist where the agent may send. This one control defangs most exfiltration regardless of how the attack got in.
  • Sandboxing: run risky capabilities — code execution, browsing — in a contained environment with no access to secrets or production systems, so a compromise there touches nothing that matters.

The framing that makes this stick is the blast radius. Security debates often get stuck on likelihood — will the agent be fooled? — which is unanswerable and model-dependent. Least privilege sidesteps it by working on impact instead: grant so little that being fooled does not matter much. A compromised agent with a broad credential is an incident; the same compromise with a scoped, read-only, allowlisted credential is a log line.

Sandboxing is where computer-use and code-execution agents earn their keep or become a liability. An agent that can run arbitrary code is only as safe as the box it runs in — give it a container with no credentials, no internal network, and no production data, and a prompt-injected 'rm -rf' or reverse shell hits an empty room.

The lab reuses the attack battery, but read it for blast radius this time. Under structural defence the credential is scoped and the egress is allowlisted, so even the attacks that get the model to cooperate reach nothing worth having. Least privilege did not make the agent harder to fool — it made being fooled cheap.

Checkpoint

For each tool your agent has, ask: what is the worst a compromised agent could do with it? Which tool has the largest blast radius, and does the task actually need it?

Defencesecret in the prompt, no hardening, no egress control — a typical first build.

Run the battery under 'no defence' and then 'structural', and think in blast radius: not 'did the attack land' but 'what could it have reached if it had'. Structural defence shrinks the second answer to almost nothing.

Six messages arrive as customer tickets: five attacks (instruction override, role-play, fake authority, cross-tenant pull, exfil-by-email) and one genuine question. Run them against the current defence and read what the agent did.