An Agent Authorization Policy Engine Is a Boundary, Not a Prompt
An agent can suggest an action. It should never get to define the facts that authorize that action. That is the job of an agent authorization policy engine, and it is why the engine must sit behind a boundary the model cannot reach.
That sounds obvious until the action is phrased as something harmless: “send this report,” “update that record,” or “read the customer file.” A language model can produce the tool name, the destination, the path, and even a claimed risk level. None of those claims are trustworthy authorization inputs. They are proposals from an untrusted component.
I built a small executable authorization harness around this boundary and evaluated the same synthetic enterprise-agent contract in two policy engines: Open Policy Agent (OPA/Rego) and Cedar. The result was not a claim that the engines are generally equivalent. It was a narrower and more useful result: with a trusted normalizer, a fail-closed adapter, and an executor that rechecks its inputs, both engines produced the expected external outcome across a defined test envelope.
The practical conclusion is simple: do not begin an agent security design by asking which policy language to use. Begin by deciding which component owns every authorization fact.
The model proposes; the host authorizes
The harness accepts a deliberately limited ModelActionProposal: a tool name and raw arguments. Before either policy engine sees a request, a trusted host-side normalizer resolves every security-relevant fact from controlled sources:
- Identity and tenant come from the identity and tenant control planes—not the model.
- Tool, action class, and risk come from a server-controlled tool catalog.
- Resources and paths are canonicalized and checked against known catalog rules.
- Approvals are bound to the canonical request digest, scope, expiry, revocation state, and single-use rules.
- Unknown fields, traversal variants, unresolved resources, incompatible versions, and malformed requests are rejected before policy evaluation.
That produces a versioned AuthorizationRequest, which is the only shape passed to OPA or Cedar. This is more than input validation. It prevents a model from downgrading the risk of its own action, supplying a different tenant, or turning a path-like string into authority.
This is the same containment instinct that motivates isolating an agent's reasoning loop from production infrastructure, applied one layer down to the authorization facts themselves.
The important property is the boundary after the normalizer. A policy engine may return permit, deny, or an error-like result. The adapter dispatches only an explicit permit. Every other result—including malformed engine output, validation failure, timeout, conflict, and version mismatch—becomes an external deny with zero dispatches.
An agent authorization policy engine: why compare OPA and Cedar?
OPA and Cedar make different modeling choices. Rego is flexible around computed rules and data; Cedar makes principal, action, resource, schema, and explicit forbids especially visible. Both are useful surfaces to study when an agent is about to perform a consequential operation.
I used a single engine-neutral truth specification rather than writing two unrelated policy demos. The synthetic contract included two tenants, intern/engineer/admin roles, development/staging/production environments, tenant-private resources, bounded write and external-send actions, and high-risk operations that require a valid approval.
The same normalized cases were evaluated through purpose-built OPA and Cedar adapters. The question was not “which engine is faster?” These were local CLI runs, not a production benchmark. The question was whether a fixed contract had the same observable enforcement outcome once the host took responsibility for normalization and dispatch.
The result: agreement is earned at the boundary
The final controlled matrix contains 28 predicted cases. Five malformed or untrusted cases are intentionally stopped at the host boundary, before either engine runs. Of the remaining 23 engine-evaluated cases, both engines matched the expected external result after a path-semantics remediation.
| Evidence population | Result | What it demonstrates |
|---|---|---|
| Controlled matrix | 23 engine-evaluated cases matched expectations | Bounded contract agreement after normalization |
| Host-boundary checks | 5 requests rejected before evaluation | Untrusted or malformed input never reaches policy |
| Failure injection | 4 arms denied with zero dispatch | Errors and missing data fail closed |
| Conflict and recovery | 2 injected conditions, then recovery | Policy promotion needs validation and rollback |
| Path-semantics experiment | Divergence reproduced, then fixed | Host translations are policy semantics too |
| Final evidence suites | 9 retained *-FINAL suites | Results are reproducible and traceable |
These are finite tests over synthetic data. They are not a symbolic proof, a production load test, or evidence that every Rego policy is equivalent to every Cedar policy. A test suite is evidence of the cases it ran, not a license to make a larger claim.
The most useful failure was a disagreement
The best result was not the initial agreement. It was the disagreement the harness caught.
OPA derived an allowed path prefix from policy data. Cedar initially received a host-generated path_valid value based on a hard-coded /workspace/ prefix. The mismatch did not appear while all tools used workspace paths. It surfaced when a read_report action legitimately used /reports/: OPA permitted the catalog-defined path while Cedar denied it.
Neither engine was “wrong” in isolation. The defect was in the translation boundary between the trusted host and Cedar. I retained the divergent case as evidence, then changed the Cedar-side input derivation to use the same catalog-driven prefix semantics. After that remediation, the path experiment recorded agreement.
This is a pattern worth carrying into production. If authorization logic is split between application code and a policy language, application code is part of the policy. A clean policy file cannot compensate for a host that derived one field with different semantics.
In an agent authorization policy engine, fail-closed is a product decision
Failing closed means an authorization ambiguity blocks execution. In this harness, the adapter maps process errors, timeouts, parse failures, missing required fields, incompatible request versions, and malformed output to deny. The mock executor performs a final request/resource binding recheck before it dispatches.
That last recheck matters because authorization is not the same thing as a successful side effect. A policy decision evaluates a representation of the world at one point in time; an executor may act later, against a changed resource. Production systems need request digests, idempotency keys, resource-version checks where possible, and an outcome record tied to the authorization decision.
Fail closed also needs a usable diagnostic taxonomy. The same external deny can arise from different causes:
| Raw condition | External enforcement | Operational interpretation |
|---|---|---|
| Policy rejects a valid request | Deny | The request violates a declared rule |
| Engine cannot evaluate request | Deny | Investigate schema, input translation, or engine health |
| Request fails host validation | Deny before engine call | Investigate normalizer, catalog, or client integration |
| Policy/schema version mismatch | Deny | Roll back or promote a compatible signed bundle |
For example, an engine-observed missing attribute produced an OPA policy deny but a Cedar parse failure. The adapter correctly denied in both cases, while audit records preserved the distinct diagnostic class. Treating those as identical in an operations dashboard would make troubleshooting harder; treating them as different permissions decisions would make enforcement unsafe. The right design keeps both layers.
Audit must describe decisions without becoming a data leak
Agents are likely to handle sensitive strings: prompts, paths, arguments, headers, tokens, and approval material. Logging everything to make authorization “auditable” merely moves the security problem into a log store.
The harness emits an allowlisted pseudonymous audit envelope instead. It records decision identifiers, a canonical request digest, policy and engine version metadata, diagnostic class, determining policy identifiers, timing, approval reference, and dispatch outcome. It excludes raw arguments, credentials, tokens, free-form prompt text, approval signatures, and file contents.
This gives an operator a useful question-and-answer trail: which policy version allowed this action, which request digest was executed, was it dispatched, and why did the adapter deny it? It does not turn every audit event into a copy of the model’s input.
A request should become less ambiguous at every hop
Consider a model that asks to send a production report to an external destination.
At the proposal layer, that is only a tool name plus a destination string and a report identifier.
It is not yet a production operation, an approved operation, or even a valid request.
The trusted normalizer resolves the caller’s identity, tenant, role, tool definition, destination allowlist entry, target resource, environment, and catalog-derived risk class.
It also calculates a canonical digest of the normalized request.
The approval service, when approval is required, is checked against that digest rather than against a loose phrase such as “approved to send the report.”
That distinction prevents an approval for one request from being reused for another recipient, tenant, report, or tool.
The policy engine then evaluates a request whose security-relevant fields are already concrete.
Finally, the executor verifies that the request and resource binding it is about to use still match the permitted digest.
Each layer removes an ambiguity rather than introducing another interpretation of the model’s text.
| Stage | Untrusted or incomplete input | Trusted output |
|---|---|---|
| Model proposal | Tool name and raw arguments | A request for host validation only |
| Normalization | Claims about resource, path, or risk | Canonical typed authorization request |
| Approval lookup | A reference to a possible approval | Request-bound eligibility decision |
| Policy evaluation | A normalized request | Explicit permit, deny, or indeterminate result |
| Adapter and executor | An engine result | Dispatch or zero-dispatch outcome |
| Audit | Decision metadata | Minimal, correlatable record without raw secrets |
This pattern is useful beyond agent systems.
Any system that accepts partially trusted commands—from integrations, webhooks, workflows, or human forms—benefits from separating what a caller proposes from what the service can establish as true.
Approval is not a boolean supplied by the client
High-risk actions are often described with a single approved: true field.
That field is dangerously underspecified.
Who approved it?
Which exact request did they approve?
Was the approval for this tenant, this action, this destination, and this resource?
Has it expired, been revoked, or already been consumed?
In this harness, approval is a host-owned fact with a defined scope.
It is bound to the normalized request digest, principal, tenant, tool/action risk, request identifier, administrator approver, expiry, revocation state, and single-use semantics.
The policy receives the trusted result of that verification rather than a model-provided assertion about approval.
The policy does not need to validate a cryptographic approval signature itself to enforce the contract correctly.
That separation lets a real deployment replace the local synthetic approval record with a signed workflow, ticketing integration, or privileged-access system without teaching the policy language how every approval protocol works.
It also creates a clear ownership boundary: approval services attest to eligibility, policies decide whether eligibility is necessary for a particular action, and executors perform the side effect only after both agree.
Policy promotion is also an authorization problem
Policy code changes the set of actions that can execute.
It should therefore be promoted with the same discipline as application code that changes authentication or payment behavior.
The conflict and recovery experiments made this concrete.
A temporary conflicting Rego rule produced an evaluation conflict that the adapter mapped to an indeterminate deny.
A temporary Cedar forbid produced a policy deny under forbid-overrides.
Both cases resulted in zero dispatches.
After the temporary change was removed, the known-good baseline permit was restored.
The lesson is not that every policy conflict looks the same.
It is that runtime enforcement must remain conservative while the deployment owner restores a compatible, validated policy bundle.
A production promotion path should retain an immutable manifest for the policy bundle, schema, catalog, normalizer version, test-suite version, signing identity, and rollback target.
Compatibility should be checked as a unit because a valid policy file can still be unsafe beside an incompatible schema or tool catalog.
For writes and external sends, a shadow mismatch between a candidate bundle and the known-good bundle should be treated as a promotion blocker until a reviewer explains it.
The runtime adapter should never silently select an older policy version merely because the new one failed.
Rollback is a deployment event with its own audit trail, not an invisible fallback path.
This is the same discipline as staged rollouts with an explicit rollback path: a promotion is only as safe as the recovery path that has actually been exercised.
What the matrix deliberately tested
The controlled matrix was targeted rather than a Cartesian combination of every possible field.
That makes it practical to inspect while still changing material dimensions around known security boundaries.
The broader principle—that model output must be validated against an objective contract rather than accepted on plausibility—applies to authorization facts as much as to generated code.
Representative positive witnesses included a same-tenant read, a bounded engineer write in a non-production environment, and an eligible approved production action.
Representative negative cases included cross-tenant access, intern external writes with and without approval, missing or incompatible request versions, forged risk labels, traversal-like paths, unknown identities, and invalid approvals.
The approval cases covered absent, expired, wrong-tenant, self-approved, wrong-digest, wrong-tool, revoked, replayed, and ineligible approvals.
This matters because an authorization rule is most useful at its edge.
A happy-path permit demonstrates that the system can function.
An adjacent deny demonstrates that the same path does not quietly become broader than intended.
The harness also separated host-boundary rejection from engine behavior.
If a malformed request is rejected before OPA and Cedar are invoked, that is evidence about integration-boundary enforcement, not evidence of engine parity.
Keeping those populations separate prevents a convenient but misleading claim that both engines “agreed” on a case they never evaluated.
The test harness is a guardrail, not a substitute for operations
The retained *-FINAL manifests record the commands, pinned versions, checksums, case identifiers, inputs, exit status, and captured outputs used by the final evidence suites.
That makes a review conversation concrete: a reviewer can inspect the observed result and reproduce the bounded environment instead of deciding whether a prose summary sounds plausible.
It does not make the harness a production control plane.
The experiment uses local synthetic resources and CLI adapters.
It does not measure availability under a policy-service outage, latency at a large entity graph, authoring error rates, real approval-service behavior, or distributed deployment failure.
Those are different questions and need different tests.
The right operational response is to preserve the same contract and case identifiers as the system grows.
Run safe sanitized production-like replay in shadow mode.
Measure decision latency, timeout rate, policy-cache behavior, adapter failures, and mismatch rate.
Exercise rollback while requests are in flight.
Verify that audit events remain useful under volume without retaining secrets.
Security controls are only trustworthy when their success path, failure path, and recovery path are all exercised deliberately.
What I would take to production
The experiment does not recommend running two engines in the request path. Dual dispatch doubles operational complexity and can create noisy disagreement on diagnostic detail even when both engines correctly deny. It recommends one engine behind an engine-neutral contract, with paired evaluation retained for migration or shadow validation.
For a team already operating Rego bundles, OPA is a natural initial fit. For a team that values explicit entity schemas and forbid-overrides, Cedar is compelling. In either case, the durable architecture is the same:
- Normalize all authorization facts from trusted, versioned sources.
- Evaluate a policy over that canonical request.
- Dispatch only on an explicit permit; map every other condition to deny.
- Recheck bindings at execution time and make side effects idempotent.
- Record a minimal, secret-safe audit envelope.
- Promote policy bundles through tests, compatibility checks, shadowing/canaries, and an explicit rollback path.
The controlled and failure experiments make the order of those steps clear. A policy language is valuable, but it is not the trust boundary. The trust boundary is the host-owned contract that decides what a model is allowed to claim, what a policy engine is allowed to decide, and what an executor is allowed to do.
Scope and next evidence
Everything here ran locally on synthetic tenants, resources, paths, and approvals. The evaluation used pinned OPA and Cedar revisions, project-owned policies, and retained execution manifests. Cedar symbolic/solver analysis was unavailable, so no formal-verification claim is made. The matrix was targeted rather than Cartesian, and the adapters used CLI integration rather than a production policy-service topology.
The next evidence I would buy is operational: bounded-load latency, authoring usability, entity-scale behavior, a promotion rollback drill under partial deployment failure, and solver-enabled property experiments using the same request contract and fail-closed assertions.
That work would extend the evidence. It would not change the starting point: when an agent asks to act, treat its output as a proposal. Authority begins only after trusted normalization.
