Lion Cipher Lab
Gate an AI agent's tool calls with an OPA/Rego allow-list: deny by default, constrain the arguments, and unit-test every denial
- AI Security
- Advanced
- ~75 min
- Free · no account required
Why it matters
An AI agent turns text into actions: it reads a file, sends a payment, runs a query. The model's decision about which action to take can be wrong, can be steered by text hidden in a web page or document it read, or can simply be sloppy. OWASP calls the result Excessive Agency: damaging actions performed because the system let the model do more than it needed to. Asking the model to behave is not a control. A control is a separate piece of code, outside the model, that looks at each proposed call and says yes or no from rules a human wrote and tested. Open Policy Agent (OPA) and its policy…
What you'll learn
- describing an agent tool call as a JSON document a policy engine can judge
- writing a Rego policy that is deny by default and collects a reason for every refusal
- constraining arguments: tool allow-list, path prefix, no parent-directory tricks, a numeric ceiling, an approved-recipient list, no extra arguments
- evaluating decisions with opa eval and reading the reasons
- writing opa test cases for the denials, not only the allows, and checking boundary values
- wiring the policy behind a fail-closed enforcement point that treats any error as a refusal
Steps in this lab
- Why the gate must live outside the model
- Install OPA and describe a tool call as input
- Write the policy: deny by default, collect reasons
- Evaluate real calls with opa eval and read the reasons
- Write the tests: allows, denials and the boundary
- Break a boundary on purpose and watch a test catch it
- Measure how much of the policy your tests touch
- Wire the policy behind a fail-closed enforcement point
- What this gate does not do
- Clean up
Open the full interactive lab →