Agent tool sandboxing and least privilege
Treat the model as an untrusted user acting with delegated authority: designing narrow tools, per-user scoped credentials, confirmation gates, code-execution sandboxes, network egress control, MCP server risks, and audit trails for agent actions.
01The model is an untrusted user with your keys
- Apply a threat model in which the model is an untrusted principal acting with delegated authority
- Design narrow tools with per-user, scoped credentials to avoid confused-deputy bugs
- Sandbox code execution and control network egress for agents
- Assess MCP servers and tool descriptions as supply-chain risk
- Build confirmation gates and audit trails for agent actions
An agent is a loop: the model picks a tool and arguments, your code runs it, the result goes back into the context, repeat. Whatever the tools can do, an injected or simply mistaken model can do. OWASP calls the failure excessive agency (LLM06:2025): too much functionality, too many permissions, or too much autonomy. The working threat model is simple: treat every tool call as if an untrusted user had typed it, with the same validation and authorisation you would apply to a public API.
| Excess | Example | Fix |
|---|---|---|
| Functionality | A support agent given a generic run_sql tool to look up orders | A get_order(order_id) tool that only reads the caller's orders |
| Permissions | The agent's database user can write every table | Read-only role scoped to the tables the tools need |
| Autonomy | Refunds issued without review | Refunds above a threshold need human approval |
| Identity | All users' requests run with one service account | Act with the end user's own delegated, scoped token |
This is an advanced module
AI & LLM security engineering is part of the Pro pass. 4 more sections — the deep dives, the final design, follow-ups and the test — unlock with it.
Already a cyart.io or studio.cyart.io member? Your pass code is in your Studio account.