Hands-On AI Security: Policy-as-Code with Open Policy Agent and Rego
How to move beyond static regex filters by using Open Policy Agent (OPA) and Rego to enforce declarative, explainable security policies on AI prompts.
How to move beyond static regex filters by using Open Policy Agent (OPA) and Rego to enforce declarative, explainable security policies on AI prompts.
How to decouple AI defense from the model by building a Python Flask security proxy with hot-reloading ingress filters and egress data masking.
How to probe and break local LLMs using Direct Injection, Roleplay, Obfuscation, and Authority Claims, demonstrating why system instructions fail as security boundaries.
How to build a 100% free, local AI security sandbox using Docker Desktop, Ollama (llama3.2), and a custom vulnerable chatbot to test prompt injection defenses without cloud API costs.
In August 2026 I delivered a webinar for the NCyTE Center on a question I kept hearing from community college faculty: how do you teach AI security when you don’t have a budget, your IT department locks down what you can install, and API costs for a live LLM are unpredictable? The answer I built — and the one this post walks through — is a zero-cost, fully local lab that any instructor can drop into their course next week. ...