systemdesign.academyAI EngineeringFree lessonsSign inGet the course
  1. Home
  2. AI Engineering: Evaluation, LLM Ops and Security
Previous lessonDefending Against Prompt Injection: The Layered PlaybookNext lessonAgent Identity and Authorization: Whose Authority Is It?

System Design

  • Foundation
  • Intermediate
  • Advanced
  • Capstone

AI Engineering

  • Foundation
  • Data, RAG and Agents
  • Evaluation, LLM Ops and Security

systemdesign.academy

  • Home
  • Glossary
  • Interview prep
  • Reviews
  • About
  • Pricing
  • Privacy
  • Terms
  • Refunds
  • Delivery
  • Contact
  • AI Security and Agent Safety
  • Tool and Sandbox Security: Locking Down What an Agent Can Do
  • AI Engineering · Security

    Tool and Sandbox Security: Locking Down What an Agent Can Do

    Free preview: the first part of this 11-part lesson.

    Already bought the course? Sign in to read the whole lesson.

    this lesson is part of

    AI Engineering

    Unlock this lesson and the 199 other paid lessons

    • 210 lessons in 16 chapters
    • 118 lessons built on a lab that really ran
    • An AI tutor beside every lesson that answers and draws
    • Lifetime access, every new lesson included

    $49 once, by PayPal

    See the AI Engineering course

    The rest of this lesson

    1. What Does Least Privilege Mean for a Tool?
    2. How Do You Actually Sandbox Code the Model Wrote?
    3. Container, gVisor, or microVM? Picking the Boundary
    4. The One Control That Matters Most: Egress
    5. The Confused Deputy: When the Agent Has Too Much Authority
    6. Never Pass Raw Model Output to a Shell
    7. Isolating the Code Interpreter
    8. Time, Cost, and Rate Limits: The Self-Inflicted Threats
    9. What Does One Fully Locked-Down Tool Call Look Like?
    10. Knowledge Check

    read the rest of this lesson in

    AI Engineering

    Unlock this lesson and the 199 other paid lessons

    • 210 lessons in 16 chapters
    • 118 lessons built on a lab that really ran
    • An AI tutor beside every lesson that answers and draws
    • Lifetime access, every new lesson included

    $49 once, by PayPal

    See the AI Engineering course

    Continue this lesson

    in Security

    This lesson is part of the AI Engineering course. Unlock the full course, a separate one-time payment, for lifetime access.

    One-time payment. Lifetime access. No subscription.
    Global
    $49/lifetime

    One-time payment via PayPal

    Get Lifetime Access
    Foundation lessons free, try before you buy
    India Special
    India
    ₹999/lifetime

    One-time payment: UPI, card or netbanking

    Get Lifetime Access
    Foundation lessons free, try before you buy
    Every ML Platform lesson, Foundation to Advanced
    Real architecture diagrams with real tool logos
    MLOps, LLMOps, and data engineering in depth
    Quizzes with instant feedback
    Built and reviewed by senior engineers
    Lifetime access, all future content included

    Foundation lessons of this course are free, no payment needed. Try them now

    Why Is an Agent More Dangerous Than a Chatbot?

    A chatbot can only say something wrong. An agent can do something wrong.

    That one difference is the whole reason this lesson exists. The previous lesson was about , where an attacker plants instructions in text the model reads. On a plain chatbot the damage stops at a bad sentence. Someone reads a wrong answer, notices it is wrong, and moves on. The moment you give the model tools, a shell to run code, an HTTP client to fetch URLs, a database connection, an email sender, that same injected instruction stops being words and becomes an action you cannot take back. A deleted row. A leaked key. A refund issued to an attacker's account. A request sent to a server you have never heard of, carrying data you never meant to share.

    So the security question changes shape. It is no longer only "can the model be tricked into saying something." It is "what can the model actually do, and to what, if it is fully under an attacker's control." That framing matters because it forces you to stop hoping the model behaves and start assuming it will not. You have to assume the model will be steered, because prompt injection is not fully solvable with prompting alone, and then design so that a steered model still cannot cause real harm.

    Attack surface map: the model sits in the middle, steered by injected text and holding the keys to every connected tool, with six tools drawn as doors, a shell that risks remote code execution, a db_query that risks the whole database, an http_get that opens an exfiltration path, a read_file that exposes secrets and keys, a send_email that can silently BCC an attacker, and a code_exec that can do anything, each labeled with its worst case

    Count the tools connected to your agent. That number is your attack surface. Every one is a door, and the model, which can be pushed around by text it reads, is holding the keys to all of them. This is why teams that ship an impressive demo are often one injection away from an incident: the demo proves the doors open, not that they close when someone malicious knocks. The rest of this lesson is a set of controls that shrink each door to the smallest opening the job actually needs, and add walls behind the doors so that getting through one does not get you everything.

    The controls fall into two families. The first shrinks what a tool is allowed to do at all: least privilege, argument validation, and per-request authorization. The second contains the damage when a tool is abused anyway: sandbox isolation, resource limits, and egress control. You want both, because the first family reduces how often something goes wrong and the second reduces how bad it is when it does. Neither family alone is enough, and treating either as optional is how the ugly incidents happen.