AI Security: Hack and Harden an LLM App

You are handed a small helpdesk assistant that answers customers, looks up orders and issues refunds, and it is full of holes. In each lesson you attack it one way, watch the attack work, and add the check in code that stops it, even when the model is completely fooled. You finish with an assistant whose rules no conversation can talk around and a suite of saved attacks that you run before every change. You have already built an app that calls a model with tools; you need no security background.

What this course covers

  1. How an AI Assistant Gets Attacked: Trace what a language model receives in an assistant with tools, explain why text typed by a user can override the developer's instructions, and replay a saved attack so it gives the same result on every run.
  2. Enforce the Rule in Code, Not in the Prompt: Explain why a rule written in a system prompt can always be overridden, and move it into the code that runs the tool so that a fooled model cannot break it.
  3. Check Who Is Asking: Pass the signed-in user's identity to every tool from code, check on each call that the record belongs to that user, and explain why a model can never be the one that decides access.
  4. Indirect Injection Through a Document: Show how instructions planted in a document reach a model through a tool result and act on an innocent user, label that content as untrusted data, and make a consequential action wait for the user's own confirmation.
  5. Give Each Tool the Least It Needs: Find the tools of an assistant that can do more than their job needs, narrow each one to a single purpose, and show that a fooled model can no longer reach files it was never meant to read.
  6. Keep Secrets Out of the Context: List everything an assistant places in a model's context, remove what the user may not see, and show that a model that repeats its whole context has nothing sensitive to give away.
  7. Check the Reply Before It Leaves: Trace how a reply can carry a user's data to an attacker through a link or an image, and stop it with a check in code that runs on every reply before the user sees it.
  8. Turn the Attacks into a Test Suite: Turn saved attacks and honest requests into one test suite, show that it fails when any defence is removed, and say what a passing suite does and does not prove.