Authorization Policy Engines

Externalized decision services (OPA/Rego, Cedar, OpenFGA/SpiceDB) that take authorization out of scattered if statements 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.

EngineModelLanguage / dataSweet spot
OPA (CNCF)rule-based, general purposeRego (Datalog-derived), JSON input + dataK8s 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 + entitiesapp authz; behind Amazon Verified Permissions; analyzable, type-safe
OpenFGA (CNCF sandbox, from Auth0) / SpiceDB (AuthZed)ReBAC, Zanzibar-styletype/relation model + relationship tuplesobject-level sharing, hierarchies, “who can see this doc” at scale
Teleport ACDrole YAML + predicate languagedefault-deny role specsTeleport 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:

TestRegoCedarOpenFGATeleport
Deny enforced even when runtime errors occurFAILFAIL*PASSPASS
Undefined values don’t affect allow/denyFAILPASSPASSn/a
Negation on undefined still deniesFAILPASSPASSPASS
Built-ins have no side effects / non-determinismFAILPASS*PASS*PASS*
Resilient to DoS via recursive/expanding inputFAILPASSPASSPASS
Regex built-ins safe (perf/ReDoS)FAILn/a (no regex by design)FAILFAIL
Built-ins can’t touch host systemFAIL*PASS*PASS*PASS*
Policies can’t exfiltrate cross-app contextFAIL*PASS*PASS*PASS*
Unauthorized policy overrides don’t change decisionsFAILPASSn/aPASS
Set ops scale at 10k/100k setsPASSPASSFAILPASS

(* = 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_addr to 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 no http.send appears in policies, push data rather than letting OPA pull it (OPAL), keep policy in Git with CI, and pass minimal context in input.

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_id or role as principal/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).

Sources