Authorization Policy Engines
Externalized decision services (OPA/Rego, Cedar, OpenFGA/SpiceDB) that take authorization out of scattered
ifstatements and evaluate it as policy-as-code at a central Policy Decision Point (PDP). The application’s Policy Enforcement Point (PEP) only asks and obeys.
How it works
PDP/PEP split: the PEP sits in the service or API gateway, intercepts the request, and asks the PDP (principal, action, resource, context) → allow/deny. Policy lives in Git, gets reviewed, tested in CI and deployed independently of app code. This is the remedy Auth0 and OWASP point to for BAC’s “check sprawl” problem.
| Engine | Model | Language / data | Sweet spot |
|---|---|---|---|
| OPA (CNCF) | rule-based, general purpose | Rego (Datalog-derived), JSON input + data | K8s admission, Envoy, infra/config policy, complex ABAC; can return structured output, not just bool |
| Cedar (AWS, Rust) | RBAC + ABAC (+ ReBAC via entity hierarchy) | Cedar policies + schema + entities | app authz; behind Amazon Verified Permissions; analyzable, type-safe |
| OpenFGA (CNCF sandbox, from Auth0) / SpiceDB (AuthZed) | ReBAC, Zanzibar-style | type/relation model + relationship tuples | object-level sharing, hierarchies, “who can see this doc” at scale |
| Teleport ACD | role YAML + predicate language | default-deny role specs | Teleport infra access |
What each looks like
Rego, which is default-deny only if you write it that way:
default allow = false
allow { startswith(input.path, "/admin/"); is_admin }
allow { startswith(input.path, "/public/") }Cedar. Any matching forbid wins, otherwise any matching permit allows, and no match is an implicit deny:
permit (principal, action == Action::"read", resource);OpenFGA. Permissions are computed from relations:
model
schema 1.1
type user
type system
relations
define admin: [user]
type cat
relations
define system: [system]
define owner: [user]
define admin: admin from system
define can_manage: owner or admin
OpenFGA adds conditions and contextual tuples (time windows, status-driven access) on top of pure ReBAC.
Engine-level security issues
The engine becomes the security boundary, so its failure modes matter.
Trail of Bits / Teleport SPEF benchmark (dynamic tests run in per-engine containers). Selected results:
| Test | Rego | Cedar | OpenFGA | Teleport |
|---|---|---|---|---|
| Deny enforced even when runtime errors occur | FAIL | FAIL* | PASS | PASS |
| Undefined values don’t affect allow/deny | FAIL | PASS | PASS | n/a |
| Negation on undefined still denies | FAIL | PASS | PASS | PASS |
| Built-ins have no side effects / non-determinism | FAIL | PASS* | PASS* | PASS* |
| Resilient to DoS via recursive/expanding input | FAIL | PASS | PASS | PASS |
| Regex built-ins safe (perf/ReDoS) | FAIL | n/a (no regex by design) | FAIL | FAIL |
| Built-ins can’t touch host system | FAIL* | PASS* | PASS* | PASS* |
| Policies can’t exfiltrate cross-app context | FAIL* | PASS* | PASS* | PASS* |
| Unauthorized policy overrides don’t change decisions | FAIL | PASS | n/a | PASS |
| Set ops scale at 10k/100k sets | PASS | PASS | FAIL | PASS |
(* = predicted.) The takeaway: Rego’s expressiveness (undefined-as-false, network built-ins, structured output) is also its attack surface. Cedar deliberately omits regex and string formatting for analyzability.
OPA-specific risks (Tenable research, CNCF write-up):
- Malicious or untrusted Rego calling
http.send/net.lookup_ip_addrto leak env vars or cloud metadata credentials. Policy code is code execution with network access. - A Windows UNC path passed to the OPA CLI/SDK as a bundle location forces SMB authentication to an attacker share.
- Mitigations: restrict built-ins via OPA capabilities in
config.yaml(opa run --server --config-file config.yaml), add tests asserting nohttp.sendappears in policies, push data rather than letting OPA pull it (OPAL), keep policy in Git with CI, and pass minimal context ininput.
Distributed consistency (ReBAC): tuple stores can serve stale relations. Zanzibar-style systems use consistency tokens (zookies) to avoid the “new enemy” problem; see Access Control Models.
Where engines don’t help
- The PEP still has to be called on every path. A route that never asks the PDP is a Function Level Authorization bug regardless of policy quality.
- Wrong inputs give wrong answers. If the PEP passes a client-supplied
tenant_idor role asprincipal/context, the policy is evaluated against attacker data. - Point-in-time decisions can’t express sequence rules (“read secret, then send externally”). AWS Dogwood builds on Cedar with temporal conditions over prior tool calls for agents, and generates action schemas from MCP tool definitions. See AI Agent Authorization.
- RAG: SpiceDB is used to pre-filter vector search to documents the user can see (LookupResources), rather than post-filtering retrieved chunks.
Defenses / adoption checklist
- Default-deny at both PEP and policy level. Cedar is implicit-deny; in Rego write
default allow = false, and test that deny holds when evaluation errors. - Treat policy repos like code: review, unit tests (
opa test, OpenFGA CLI YAML model tests), CI gates. - Lock down engine capabilities (no network built-ins, bounded eval time), authenticate PDP endpoints, and protect the tuple store and bundle source as tier-0.
- Start by replicating the existing RBAC model, then add org-level relations, then finer-grained rules (OpenFGA migration guidance).
Related
- Authorization Security
- Access Control Models
- Broken Access Control
- Multi-Tenant Isolation
- AI Agent Authorization
- Authorization Testing Automation
Sources
- Why Broken Access Control Dominates OWASP Top 10 in 2026 · original
- Security Benchmarking Authorization Policy Engines: Rego, Cedar, OpenFGA · original
- OPA: Best Practices for Secure Deployment - CNCF · original
- OPA Rego Language Tutorial · original
- What is Open Policy Agent (OPA)? · original
- Cedar Policy Language Reference · original
- Cedar Policy Language Complete Guide · original
- Amazon Verified Permissions - Cedar · original
- Announcing OpenFGA · original
- OpenFGA: Open-Source Engine for Access Control · original
- How to Protect Your API with OpenFGA: ReBAC Concepts to Practical Usage · original
- OPA vs OpenFGA: A Technical Comparison of Policy Engines · original
- OPA, Cedar, OpenFGA: Why Are Policy Languages Trending Right Now? · original
- Policy Engine Showdown: OPA vs OpenFGA vs Cedar · original
- Policy as Code: Fine-Grained Authorization · original
- Fine-Grained Authorization: Technical Guide for Microservices · original
- Fine Grained Authorization using SpiceDB for RAG · original
- AI Agent Authorization Beyond Authentication: A Look At AWS Dogwood · original