Loading
Skip to content
Miracle Minds AI
  • Try “HIPAA”, “model risk”, “FinOps” or “agentic”.

Guardrails & Policy-as-Code

Guardrails that rely on the model to police itself will fail some of the time, because no current defense stops prompt injection reliably. The controls that hold sit outside the model: what it can reach, what it is allowed to do, and a logged decision for every action.

Part of Security, Assurance & Governance, in the Build mode. 9 sources, checked .

of organizations reporting an AI-related breach lacked proper AI access controls (IBM, 2026)
92%
of organizations reporting an AI-related breach lacked proper AI access controls (IBM, 2026)
IBM X-Force (on the Cost of a Data Breach Report 2026), 2026(opens in a new tab)
of employees are regular AI users on corporate devices, up from 15% a year earlier (Verizon DBIR 2026)
45%
of employees are regular AI users on corporate devices, up from 15% a year earlier (Verizon DBIR 2026)
Verizon Business, 2026(opens in a new tab)
rank of prompt injection in the OWASP Top 10 for LLM Applications 2026
#1
rank of prompt injection in the OWASP Top 10 for LLM Applications 2026
OWASP Gen AI Security Project, 2026(opens in a new tab)

The problem

Most AI policies are still documents. IBM's 2026 breach study found that only 40% of organizations reported using access controls on AI models and data, and that 92% of those reporting an AI-related breach lacked proper AI access controls1. Verizon's 2026 DBIR found that 45% of employees now use AI regularly on corporate devices, up from 15% a year earlier, and that 67% of users reach AI services with non-corporate accounts on corporate devices2. A rule that says no customer data goes into public AI tools does nothing unless something in the path enforces it.

Filters alone will not close the gap. OWASP ranks prompt injection first in its 2026 Top 10 for LLM applications and says no reliable prevention mechanism exists today, so defense has to be architectural rather than interceptive3. NIST's adversarial machine learning taxonomy says current mitigations do not offer full protection, so designers may assume prompt injection is possible whenever a model sees untrusted input. It points to designs that limit the damage, such as models with different permissions and access to untrusted data only through well-defined interfaces4.

Agents raise the stakes because they act. OWASP, which now ranks Excessive Agency third, traces damaging agent actions to excessive functionality, permissions or autonomy. Its control is complete mediation: implement authorization in logic rather than relying on the model to decide whether an action is allowed, and route privileged calls through a deterministic policy engine3. That decision is policy, and it belongs in code that can be versioned, tested and reviewed like any other code, not in a system prompt.

Good looks like policy as code. Open Policy Agent, a graduated CNCF project, separates policy decisions from enforcement and expresses rules in a declarative language called Rego5,6. Its test framework checks policies and reports coverage before they ship7, and its decision logs record the policy queried and the input to each query for audit8. For high-risk systems, the EU AI Act asks for the same thing: automatic recording of events over the system's lifetime9.

What you get

  1. 01

    Policy-to-control map

    Each statement in your AI policy translated into a control with an enforcement point, an owner and a test, so you can show which rule blocks which behavior.

  2. 02

    Input and output filtering

    Screening for sensitive data, injection patterns and disallowed content on the way in and out, plus deterministic checks on output format before results reach users or downstream systems.

  3. 03

    Access and action rules as code

    Rules in a policy engine such as Open Policy Agent that decide what each model, agent and user can retrieve or do, enforced in the systems the model calls rather than in the prompt.

  4. 04

    Policy tests in the delivery pipeline

    Unit tests for every policy and adversarial test cases for every guardrail, run on each change so a policy edit cannot ship broken.

  5. 05

    Decision logs and evidence trail

    A record of every policy decision with its input and result, retained and searchable, for auditors, incident responders and your own assurance reports.

Where it goes wrong

The failure modes we design against from the first week, and the control for each.

  • Trusting the model to enforce the rules

    System prompts and model-based filters reduce risk but cannot guarantee it; NIST notes that many mitigations are empirical and lack provable guarantees4. The control: authorization in deterministic code, with every request to downstream systems checked against security policy before it runs3.

  • Agents with standing permissions

    An agent running under a broad service account can do anything that account can. The control: run tools in the calling user's context with minimum privileges, keep that user context across chained agent calls, and require human approval for high-impact actions3.

  • Policies that are never tested

    A policy rule without a test is a guess, and a small edit can silently open access. The control: write tests alongside each rule, run them in the pipeline and track coverage, which OPA supports out of the box7.

  • Logs that cannot answer an auditor

    Application logs rarely show why an action was allowed. The control: record each decision with the policy queried and its input, as OPA decision logs do, and keep them as long as your record-keeping rules require8,9.

Standards and rules

How to measure it

  • Share of AI policy statements enforced by a tested control
  • Policy test coverage and pass rate on each release
  • Share of agent tool calls authorized by the policy engine rather than by the model
  • Number of guardrail bypasses found in adversarial testing, and time to fix each
  • Time to answer an audit question about why a specific AI action was allowed

Questions buyers ask

What is policy-as-code for AI?

It means writing the rules in your AI policy as machine-readable policies that software evaluates at run time: who may query which data, which tools an agent may call, what output is allowed. The policies live in version control, have tests, and produce a log of every decision. That turns a policy document into something you can enforce, change safely and prove to an auditor.

Can guardrails stop prompt injection?

Not completely. OWASP and NIST both say current defenses do not prevent every prompt injection. Filters and prompt design reduce the rate, but the dependable approach is to limit what a successful injection can do: least-privilege access, authorization checks outside the model, human approval for high-impact actions, and logs that show what happened.

Should we buy a guardrail product or build our own?

Often a mix. Content filters for sensitive data, toxicity or injection patterns are widely available and worth buying. Access and action rules depend on your data, roles and systems, so they usually need to be written for you, often in an open policy engine. Whichever you choose, insist on tests, version control and decision logs you own.

Sources

Every figure on this page comes from the sources below. We checked each link on .

  1. 1.AI-powered adversaries and the enterprise risk challenge: Preparing for the new reality(opens in a new tab)IBM X-Force (on the Cost of a Data Breach Report 2026), July 29, 2026 · ibm.com
  2. 2.2026 Data Breach Investigations Report(opens in a new tab)Verizon Business, May 19, 2026 · verizon.com
  3. 3.OWASP Top 10 for LLM Applications 2026 (Version 2026)(opens in a new tab)OWASP Gen AI Security Project, August 3, 2026 · genai.owasp.org
  4. 4.NIST AI 100-2 E2025: Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations(opens in a new tab)National Institute of Standards and Technology (NIST), March 2025 · csrc.nist.gov
  5. 5.Open Policy Agent (OPA): CNCF project page(opens in a new tab)Cloud Native Computing Foundation, January 29, 2021 · cncf.io
  6. 6.Open Policy Agent documentation: Introduction(opens in a new tab)Open Policy Agent project · openpolicyagent.org
  7. 7.Open Policy Agent documentation: Policy Testing(opens in a new tab)Open Policy Agent project · openpolicyagent.org
  8. 8.Open Policy Agent documentation: Decision Logs(opens in a new tab)Open Policy Agent project · openpolicyagent.org
  9. 9.AI Act (Regulation (EU) 2024/1689), Article 12: Record-keeping(opens in a new tab)European Commission, AI Act Service Desk, 2024 · ai-act-service-desk.ec.europa.eu