100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Tool Use, Function Calling & MCP
55 minadvanced

Sandboxing and Least Privilege for Tools

Two defenses run through this course, and they are not the same kind of defense. Careful tool descriptions, tight input schemas, and instructions that steer a model away from reading a file it doesn't need — all of that is prompt-level mitigation. It works by shaping what the model asks for, and it genuinely reduces how often something goes wrong: a well-scoped tool description gets misused less often than a vague one. But it is a probabilistic defense. It bends the odds; it does not enforce a boundary.

Least privilege is the other defense, and it operates on a completely different axis. Instead of trying to make a bad request less likely, it makes a bad request unable to do damage even when it happens. A tool that only has read permission on a directory it doesn't control can be asked to delete a file a thousand different ways — badly worded prompts, an adversarial tool result, an outright bug in the agent's planning loop — and the deletion still won't happen, because the permission to delete was never granted at the layer that actually executes code.

The two are not substitutes. Prompt-level mitigation lowers the frequency of a mistake; least privilege bounds its consequence. Lesson 22 built this idea for credentials specifically — scope a token down to `crm:read` and a compromised session can only read, never write, no matter what the model was tricked into asking for. This lesson generalizes the same principle from the credential a tool holds to the entire execution surface around the tool: the filesystem it can touch, the time and output it's allowed to consume, the hosts it can reach, and the point past which a human has to say yes. When the first defense fails — and across enough calls, it eventually does — the second one is the only thing still standing.

Analogy🏏Cricket
🏏 Think of it like cricket: When Virat Kohli walks out to face Mitchell Starc's opening spell at the WACA, correct technique — watching the ball early, getting his front foot into line, playing late under his eyes — genuinely lowers how often Starc's away-shaper finds the edge or beats the bat outright. Good technique is a real defense; it changes the odds meaningfully over a long innings. But Kohli still bats in a helmet with a titanium grille, and that helmet is doing a different job entirely. It isn't there to make the ball arrive less often — it can't do that, only technique and footwork can — it's there to bound what happens on the ball that does get through despite correct technique: the one that keeps a fraction low, or nips back off a length no one predicted. No batter treats the helmet as optional because their technique is good that day, and no coach argues technique work makes the helmet unnecessary. They are stacked, not substituted: technique reduces how often the ball beats the bat, and the helmet bounds the outcome on the delivery it does beat. A team that only worked on footwork and skipped protective gear would be one badly-timed delivery away from a crisis technique alone was never built to prevent. That is the whole relationship between prompt-level care and least privilege: one lowers the odds of trouble, the other survives the day the odds don't hold.
Lesson 24 of 35
0% complete