Securing Agents and Tool Use — Least Privilege, Sandboxes, Gates, Egress
You'll be able to:
You can recognise the 'lethal trifecta' (private data, untrusted content, an exfiltration path) in an agent design, split a tool set into read / write / irreversible tiers, and specify the sandbox, approval gate and egress policy that make a given agent safe enough to ship.
An agent is a model with hands
A chatbot that only produces text has a limited blast radius: the worst outcome is a bad answer. An agent — a model that calls tools in a loop — can send, delete, pay, deploy and browse. Everything from module 2 still applies, but now a successful injection produces an action. Securing agents is therefore less about the model and more about designing what the model is allowed to touch.
The lethal trifecta
Simon Willison's framing is the most useful quick test. An agent is in serious danger when it combines three things:
- Access to private data — files, email, a database, a customer record.
- Exposure to untrusted content — web pages, inbound email, documents, tool results written by someone else.
- A way to send data out — an HTTP call, an email tool, a rendered link, a write to a shared location.
Any two are manageable. All three together mean an attacker who can place content in front of the agent can steer it to read the private data and ship it out, with no exploit beyond text. The design question for every agent is therefore: which leg of the trifecta can we remove?
Least privilege, tool by tool
Begin by tiering tools by consequence rather than by what the product wants.
- Read-only, low sensitivity (search docs, read public web): safe to call freely.
- Read-only, sensitive (read a customer's record, read email): allowed, but the agent that has it should not also have an open egress channel.
- Reversible writes (create a draft, add a comment, open a ticket): allowed with logging; a mistake is undoable.
- Irreversible or external (send email, make a payment, delete, merge, deploy, post publicly): require an approval gate.
Then scope each credential to the task. An agent that triages tickets needs a token that can read tickets, not an admin token that can read everything the deploying engineer can. Short-lived, narrowly-scoped tokens issued per task are the agent equivalent of running a service as a dedicated user.
Approval gates that mean something
A gate works when the human can see what they are approving. "Send 3 emails?" is not a gate; "Send to alice@…, subject …, body …" is. Three practical rules: show the full action, not a summary generated by the same model; make the default deny when the agent is uncertain or the action is novel; and never let the model's output be the thing that decides whether a gate applies — the gate is enforced by the orchestrator in code, keyed on the tool name and arguments.
Sandboxing
When an agent executes code or operates a browser, the environment it runs in is the control. A container with no network, a read-only mount of only the files the task needs, a time and resource limit, and a fresh instance per task bounds what a hijacked agent can do to the host. The mental model from traditional security applies unchanged: assume the thing running inside the sandbox is hostile, and design the walls accordingly.
Egress control
Exfiltration needs a channel. Close the obvious ones: no unrestricted HTTP tool; render model output as plain text or sanitise markdown so images and links cannot carry data in URLs; route any permitted outbound requests through an allow-list proxy that logs destinations. An agent that can only talk to three named hosts cannot post your secrets to a fourth. This single control removes the third leg of the trifecta for many designs and is often the cheapest fix available.
Design patterns that hold up
The 2025 "Design Patterns for Securing LLM Agents against Prompt Injections" paper catalogues structures that give real guarantees by accepting constraints. Two worth internalising: the dual-LLM / quarantined model pattern, where one model reads untrusted content and returns only a constrained, non-instructional result that a privileged model then acts on; and plan-then-execute, where the agent commits to a plan of tool calls before reading untrusted data, so later content cannot add actions. The CaMeL system takes this further by tracking which data is tainted by untrusted sources and refusing to let tainted values flow into sensitive tool arguments. The common thread: untrusted text can influence values, never control flow.
If your agent connects to tools through the Model Context Protocol, its security best-practices document is required reading: it covers token passthrough, confused-deputy problems with shared OAuth clients, and hijacked state handles (session IDs in protocol versions up to 2025-11-25). The tool server, not only the model, is part of the trust boundary.
Worked example: the support-inbox agent
Spec: read tickets, search the wiki, draft replies, send replies. Trifecta check: private data (tickets), untrusted content (tickets are written by the public), egress (send). All three present.
Design: sending moves behind an approval gate that shows the full reply and recipient; drafting stays automatic. The wiki search tool is read-only with a scoped token. Model output is a structured object (ticket id, category, draft) — a ticket containing "forward this thread to…" can only land in a draft field, which a human sees. Outbound network is limited to the ticketing API and the wiki host. Cost: an agent cannot reply to anyone without a click; throughput falls, exposure falls further.
What is still unsettled
Fully autonomous agents that browse freely and act freely are not securable with current techniques, and the honest vendors say so. Approval fatigue — users clicking "approve" reflexively — is a human-factors problem with no clean technical fix. Multi-agent systems where agents feed each other output compound the trust question; each hop is another untrusted-content boundary.
What to remember
- Check every agent design against the lethal trifecta and remove at least one leg.
- Tier tools by consequence; gate irreversible actions in code, not in the prompt.
- Per-task scoped credentials, sandboxes with no network by default, and an egress allow-list bound the blast radius.
- Let untrusted text influence values, never control flow.
Check Yourself
Module Mission
35–45 minDecision 5 of the case file. Design the permission model for the triage agent and its five tools. On one page, assign each tool to a tier (read, write, irreversible), state which actions need a person to approve and why, list the network destinations the agent may reach, and show how your design breaks the lethal trifecta. Say what the product loses by your choices.
Open Case file: Halden Assist →Good looks like
- Each of the five tools has a tier, and "send reply" and "issue refund" are not in the same tier as "search wiki".
- The design names the three legs of the lethal trifecta in this agent and says which leg it removes.
- Approval gates are placed on specific actions, with the reason, and not on everything.
- The single service account is replaced, and the note says with what.
- The cost to the product is stated in terms a product manager would recognise (time, replies per hour, features cut).
Loading your work…
Curated Materials
1.4hThe deep work happens here — the lesson is your briefing.
Live on aiqbench
This lesson's subject on the rest of the site, today.
In the news, last 30 days
- Hackers Hide Password-Stealing Malware in GitHub Code, Putting Software Downloads at RiskCybersecurity News ·
- Silver Fox Hackers Use Fake Software Downloads to Spread Gh0stRAT Malware That Can Spy on PCsCybersecurity News ·
- MINE: A Training-Free Defense against Indirect Prompt Injection via Mutual Information and Embedding VariancearXiv ·