GuideAdvanced

Agent Security and Sandboxing

Learn to secure an agent that takes real actions with tools over a system. This guide covers an agent's threat model, direct and indirect prompt injection, the tool contract and least privilege, sandboxing tool execution, permission models and human-in-the-loop, input and output guardrails, and secrets handling and blast radius. The case that runs through the whole guide is a Reservo agent (a coworking room-booking backend) with tools like `search_rooms`, `book_room`, and `cancel_booking`. You come out knowing how to design an agent that can't be manipulated into causing harm or leaking data, even when the model or the user input is hostile. All the security engineering (the tool validator, the sandbox, the permission gate, the guardrails, the audit log, and the injection demo with its defense) actually runs with Python 3.14 or later (stdlib), and the hardened container with Docker; the LLM's decision is presented as a concept, with realistic examples.

lessons
64
modules
8
available in
English · Spanish
certificate
Yes
access
Free
Outcomes

What you'll be able to do

  • Understand why an agent with tools is a new attack surface, using the OWASP Top 10 for LLM Applications (2026 edition) and the OWASP Top 10 for Agentic Applications as frameworks
  • Defend against direct and indirect prompt injection by treating every tool output and every external piece of data as untrusted, never as an instruction, and decide how much agency to grant with the lethal trifecta and the Rule of Two
  • Design each tool's contract with least privilege: what it receives, what it returns, and an allowlist of actions that rejects anything not permitted
  • Isolate tool execution with sandboxing: a confined `subprocess` with resource limits, a timeout, no network access, and a temporary directory, and know when to move up to a hardened container, gVisor, or a microVM
  • Implement permission models and human-in-the-loop: auto-allow what's safe, ask for confirmation on what's risky, forbid what's dangerous, with an audit log of every tool call
  • Build input and output guardrails: validate the arguments an agent passes to a tool, and sanitize what a tool returns before it re-enters the context
  • Handle secrets with least-privilege credentials per tool, and limit the blast radius of a compromised agent
  • Harden a complete agent in the final project and validate it with a red-team test (a battery of executed attacks) that the defenses block
Before you start

What you need to bring

It's for you if...

  • Devs building an agent with tools who need to make sure a hostile input can't turn into a destructive action
  • Teams evaluating how to give an agent autonomy without exposing credentials, data, or irreversible actions
  • Devs who already know agent fundamentals and want the specific security slice, not another general agents course
  • Engineers preparing for interview questions about AI agent security: prompt injection, excessive agency, sandboxing

Requirements and materials

  • Python 3.14 or later and basic knowledge of agents with tool calling; Docker is optional (a single example)
  • You don't need to have built a full agent before, though knowing the agentic engineering ecosystem helps
  • No real calls to any LLM API in this guide: all the security engineering runs with Python stdlib
Content

The syllabus, module by module

Open any of them to see its lessons.

Common questions

What people usually ask

Start whenever you like

Reviews

What students say

These reviews are from enrolled students who completed at least 50% of the course. We moderate reviews only on content grounds (spam, offensive language, personal data), never for being critical or negative.

No approved reviews yet.

Be the first to share your experience!