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

The checks

CheckLessonSeeded flaw
K126Server accepts a token issued for a different audience
K226Server forwards the caller’s token to a downstream API (token passthrough)
K326Discovery fetch reaches a cloud metadata address (SSRF)
K426Issuer check accepts a look-alike iss after normalisation (mix-up)
K526A state handle made by one user is accepted for another (state-handle hijack)
K626A read-only token is accepted for a write operation (over-broad scope)
K728A delegated token gains authority its parent did not have
K828Revoking the parent leaves the child token working
K928An expired task credential is still honoured
K1023A sandboxed agent posts data to a host outside the allow-list
K1123A sandboxed agent reads a file outside its working directory
K1224A poisoned memory entry from a web page is replayed as an instruction
K1324A tool description carries instructions aimed at the model
K1427Rug pull: a tool’s description changes after it was approved
K1527Shadowing: a second server registers a tool with an existing name
K1614An approval for one set of arguments authorises a different set (TOCTOU)
K1714An approval that has expired still authorises the action
K1825A 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.