Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
AI Agent Security 2026: Harden MCP & Block Prompt Injection
New
6 students

AI Agent Security 2026: Harden MCP & Block Prompt Injection

Hands-on lab: secure MCP servers, block prompt injection, OPA tool policies, sandboxes and OWASP Agentic Top 10 mapping
Created byNEXUS ACADEMY
Last updated 11/2026
English

What you'll learn

  • Explain AI agent security: what changes when a model can act, and draw trust zones around the model, loop, tools, memory and identity
  • Build a local agent bench with Ollama and a small tool-calling model, with every step of the agent loop logged
  • Write and harden your own MCP server, read exactly what the model sees, and validate tool inputs and outputs against schemas
  • Replace open-ended tools with narrow ones, confine file paths correctly and split read and write servers
  • Put an OPA policy decision in front of every tool call, with argument-level rules tested before they ship
  • Run tools in hardened containers with no network by default, resource limits and throwaway execution
  • Use short-lived, audience-bound tokens and scoped credentials so an agent never carries more authority than it needs
  • Defend against direct and indirect prompt injection with content marking, plan-then-execute, a guard model and policy that blocks the injected call
  • Add human approval gates bound to one request, per-user memory isolation, access-controlled retrieval and redaction
  • Enforce budgets, log every tool call, write detection rules, pin MCP servers and run a kill-switch drill
  • Map your controls to the OWASP Top 10 for Agentic Applications (ASI01-ASI10) and the NIST AI RMF

Course content

13 sections • 106 lectures • 11h 22m total length
  • Course Documents and How to Use Them6:46
  • Section 1 Intro: When Output Becomes Action3:00
  • From Chatbot to Agent: The Moment Output Becomes Action6:21
  • Anatomy of an Agent: Model, Loop, Tools, Memory and Identity7:28
  • Trust Zones: Drawing the Boundaries Around an Agent System7:24
  • The Lethal Trifecta and the Agents Rule of Two7:36
  • The Course Map: LLM06 Excessive Agency, OWASP ASI01-ASI10 and NIST AI RMF8:40
  • [LAB] A Tour of the Hardened Agent Bench You Will Build7:29
  • Section 1 Wrap: The Map and the Bench Plan3:08

Requirements

  • Comfort with Python and the command line; you can read a short script and run it
  • A machine that runs Docker; Linux is recommended because one lab uses bubblewrap. No GPU is needed: the labs run on CPU

Description

“This course contains the use of artificial intelligence.”

AI agent security is a boundary problem. Once a language model can call tools, read files, send requests and remember what it saw, prompt injection and over-privileged tools stop being theory. This hands-on course shows you how to secure AI agents and MCP servers layer by layer, on a local lab bench you build yourself. No GPU and no paid AI API are needed: the labs run on CPU with a small open model.

What you will build and test

  • A local agent bench: Ollama, a small tool-calling model and a Python agent loop that logs every step
  • Your own MCP server, hardened and validated in both directions
  • OPA/Rego policies that decide every tool call, including the call a prompt injection tries to make
  • Sandboxed tool runtimes, short-lived audience-bound tokens and human approval gates
  • Audit logs, detection rules, a kill-switch drill and a control map to the OWASP Top 10 for Agentic Applications (ASI01–ASI10) and the NIST AI RMF

You start by building that bench: Ollama in a container bound to localhost, a small tool-calling model chosen for size, speed and licence, and a minimal agent loop in Python that logs every step. From the first tool call you see how the model chooses arguments, including invented ones, and why validation has to start at the tool boundary.

Next you read the Model Context Protocol from the defender's seat. You write your own MCP server with the Python SDK, list exactly what the model will see, learn why tool annotations are hints rather than controls, and validate both tool inputs and structured results. Least privilege follows: an open-ended shell tool is replaced by narrow functions, file paths are confined correctly, and read and write access are split across separate servers.

Every tool call then passes through one decision point. You run OPA, write Rego policies with argument-level rules for paths, hosts and row limits, and test the policies before they ship. Tools run in hardened containers with a read-only filesystem, all capabilities dropped, no network by default and resource limits, and agent-written code runs in throwaway containers.

Identity gets its own section: whose authority the agent uses, MCP servers as OAuth resource servers, audience-bound tokens, why token passthrough is forbidden and how scoped credentials keep secrets out of prompts. Prompt injection, direct and indirect, is treated as a boundary problem rather than a filtering problem: untrusted content is marked and kept out of instructions, plans are fixed before untrusted data is read, a guard model screens inputs on CPU, and a policy blocks the injected action even when the model follows it.

The final sections cover the operational controls: human approval gates bound to one request, per-user memory isolation, retrieval that filters before it retrieves, redaction of secrets and personal data, step and token budgets, rate limits, structured audit logs, OpenTelemetry spans and detection rules. You pin MCP servers and audit client configuration as code, threat model the agent with MAESTRO, and finish with a kill-switch drill and a full control check of the finished bench.

47 of the 80 content lectures are hands-on labs. Twelve downloadable documents come with the course, including an MCP hardening checklist, a Rego policy guide, a sandbox checklist, a human approval policy, an audit log schema with detection rules and an incident response runbook, plus the complete agent bench as a ZIP.

Who this course is for:

  • Security engineers who are asked to review or approve AI agents and tool integrations
  • Developers and platform engineers building agents with MCP servers and tool calling
  • AppSec and cloud security teams who need practical controls for agentic AI, not just a list of risks