Securing AI agents and MCP
Tool misuse, agent identity, memory poisoning and MCP risks. Lock down an agent that has real tools.
How to use the lab files
The zip keeps the files of each lesson apart, and the lessons work in one flat folder. After you unzip it, sh kr-lab.sh LESSON FOLDER builds that folder as it stands after a lesson, for example sh kr-lab.sh 00-set-up-your-lab ~/krlab/securing-agents-mcp.
You will build
You need
A computer with Linux, macOS, or Windows with WSL. No GPU, no cloud account and no paid tool.
Next course
- 00Set up your lab for securing AI agentsCreate the lab folder and its sandbox for this courseSet-up15 min
- 01Build an agent and map where it can be attackedBuild a small agent loop with tools, a step limit and a traceBuild50 min
- 02Hijack your agent with a file, then stop itShow that text inside a file can change what your agent does50 min
- 03Make a safe tool refuse unsafe argumentsShow that a harmless tool can read files outside its folder45 min
- 04Give each tool the least power it needsBuild tools that hold one narrow capability and nothing more50 min
- 05Stop a poisoned note from changing later tasksGive the agent a memory file and poison it with one note45 min
- 06Decide what code an agent may runMeasure how often a document makes the model ask for a dangerous command50 min
- 07Build a tool server and poison its descriptionBuild a minimal tool server and a client that talk in JSON-RPC 2.0 messagesBuild55 min
- 08Pin your tool servers and catch a rug pullPin a tool server by the SHA-256 of its file and each tool by a fingerprint45 min
- 09Add approval, budgets and a kill switchSort actions into read, write and irreversible, and require approval for the last two50 min
- 10Record what your agent does and flag strange runsWrite one JSON line for every step, with the fields that an investigator needs45 min
- 11Secure a remote tool server and its tokensBuild a small HTTP tool server that checks the origin, the token, the audience and the scope55 min
- 12Build the locked-down agent and measure itPut the controls of the course into one safe agentBuild60 min
- 13Review an agent before it goes liveFind five planted weaknesses in an agent by reading its code and running testsTest90 min
Work roles
Work roles this course supports
The course helps you to prepare for these roles of the NICE Workforce Framework for Cybersecurity (NIST SP 800-181 Rev. 1). No single course covers a whole role, and KaliRange is not a certification body.
- Secure Software Development
DD-WRL-003a main skill of the roleYou add least privilege, argument checks, approval and a kill switch to an agent. - Software Security Assessment
DD-WRL-005a supporting skillYou review an agent's code and tests and find planted weaknesses.