Practice kit
Reference lab kit
One file, run locally with Node, no packages and no network. It mounts 18 seeded flaws from lessons 14 and 22 to 28 against a reference control and an unsafe baseline, so you can see what a working control catches and what a common shortcut misses.
Run it
node agent-lab-kit.mjs
Exit code 0 means the reference blocked every seeded flaw and the unsafe baseline missed every one. Add --json for machine-readable output you can use in CI.
agent-lab-kit.mjsagent_guardrail.regoagent_guardrail_test.rego
What it contains
- A mock MCP resource server with seeded flaws: wrong audience, token passthrough, a discovery fetch to a private address, a loose issuer check, an unbound state handle, over-broad scope.
- A mock identity and delegation service with expiry, narrowing-only delegation and cascading revocation.
- A containment harness with an egress allow-list and path limits.
- Poisoned memory and tool-description fixtures.
- A tool register that catches a rug pull and a shadowed tool name.
- Approvals bound to the exact arguments, with expiry, and a trace monitor for tainted egress.
The checks
| Check | Lesson | Seeded flaw |
|---|---|---|
| K1 | 26 | Server accepts a token issued for a different audience |
| K2 | 26 | Server forwards the caller’s token to a downstream API (token passthrough) |
| K3 | 26 | Discovery fetch reaches a cloud metadata address (SSRF) |
| K4 | 26 | Issuer check accepts a look-alike iss after normalisation (mix-up) |
| K5 | 26 | A state handle made by one user is accepted for another (state-handle hijack) |
| K6 | 26 | A read-only token is accepted for a write operation (over-broad scope) |
| K7 | 28 | A delegated token gains authority its parent did not have |
| K8 | 28 | Revoking the parent leaves the child token working |
| K9 | 28 | An expired task credential is still honoured |
| K10 | 23 | A sandboxed agent posts data to a host outside the allow-list |
| K11 | 23 | A sandboxed agent reads a file outside its working directory |
| K12 | 24 | A poisoned memory entry from a web page is replayed as an instruction |
| K13 | 24 | A tool description carries instructions aimed at the model |
| K14 | 27 | Rug pull: a tool’s description changes after it was approved |
| K15 | 27 | Shadowing: a second server registers a tool with an existing name |
| K16 | 14 | An approval for one set of arguments authorises a different set (TOCTOU) |
| K17 | 14 | An approval that has expired still authorises the action |
| K18 | 25 | A tainted context reaches an external write and nothing flags it |
Everything is synthetic and runs inside one process. The mocks teach the controls; they are not a scanner and they do not test your real systems. To use the kit on your own work, replace a reference function with your implementation and run it again.
The Rego policy and its test file run with opa test. Open Policy Agent was not available when this course was built, so the Rego has been checked structurally against the browser tool and not executed here. Run opa test . yourself to confirm.