Policy as code stores rules in a policy language and evaluates them with external data at decision time, which is flexible for complex logic and ABAC-style policies. Policy as data stores the access relationships and rules centrally, which suits large-scale ReBAC and hierarchical permissions. The choice depends on whether logic flexibility or relationship-centric centralization matters more.
How policy as code differs from policy as data
Policy as code expresses rules in a policy language and evaluates them at decision time, usually against live context. That makes it a strong fit when conditions, exceptions, and contextual attributes matter. Policy as data centralises relationships and rules so the policy engine can reason over stored entitlements and hierarchies, which is often cleaner for relationship-heavy access models.
The practical difference is not just syntax, it is where complexity lives. With policy as code, you usually encode logic, then depend on external inputs to decide. With policy as data, the system relies more on structured records, graph-like relationships, or centrally maintained permissions. The first tends to favour expressive logic; the second tends to favour managed consistency at scale.
That split also changes how teams model access. Policy as code is often easier when the rules need to combine attributes, context, and environmental signals. Policy as data is often easier when the core question is “who is related to what, and through which path?” In practice, many platforms blend both, because pure code or pure data rarely covers every authorization scenario cleanly.
Where each approach fits best
Policy as code is usually strongest when authorization decisions depend on runtime context, such as device posture, location, time, resource sensitivity, or other attributes that change the answer at decision time. It works well when you want reusable logic, testing discipline, and a policy layer that can evolve without rebuilding the access model underneath.
Policy as data is usually strongest when the access problem is dominated by relationships, inheritance, or centrally curated entitlements. That makes it attractive for large organizations with role hierarchies, delegated ownership, business relationships, or graph-style authorization models. The advantage is clarity: the system can ask over and over, “what relationship grants this access?” rather than trying to infer it from many embedded rules.
For readers who want the authorization patterns behind those choices, the Authorisation Models Guide is a useful companion because it compares RBAC, ABAC, ReBAC and policy-based access control in one place. For the broader governance and lifecycle side, IAM and IGA Basics helps anchor the difference between access logic and access administration.
One useful way to think about the choice is operational, not ideological. If you need the policy to compute, decide, and explain itself from changing inputs, policy as code usually wins. If you need a central source of truth for relationships and permissions, policy as data usually wins. A mature program often uses both: data to define authoritative relationships, code to apply runtime guardrails around them.
What changes for implementation and governance
The implementation burden is different in each model. Policy as code demands good testing, versioning, rollout control, and clear decision logs, because a small logic change can alter many decisions at once. Policy as data demands good ownership, data quality, and review processes, because stale or inconsistent relationships can silently produce incorrect access outcomes.
That is why the surrounding control plane matters as much as the model itself. If policy is code, teams need disciplined change management and strong validation before deployment. If policy is data, teams need a reliable process for creation, review, inheritance, and cleanup of the underlying relationships. The failure mode is different, but in both cases the real risk is drift between the intended policy and the effective policy.
For policy engineering and rollout discipline, the Policy-as-Code for Authorisation Guide covers externalised authorisation patterns, decision logs, and safer release practices. If the problem is broader than access decisions and includes compliance evidence or automated control checks, the Compliance Automation Guide is relevant because it shows how policy logic and audit evidence often evolve together.
Risk and Threat Considerations
Both approaches can fail in different ways. Policy as code can introduce logic defects, unsafe exceptions, or overbroad rules that propagate quickly if the deployment process is weak. Policy as data can concentrate authority and create blast-radius risk if bad relationships, stale entitlements, or poisoned source records are trusted without sufficient review.
Failure mechanism: A policy language bug, an untested change, or an incomplete data model can cause incorrect authorization decisions at scale. In code-centric systems, the defect is often in evaluation logic or input handling; in data-centric systems, it is often in the authoritative relationship set or the inheritance path.
Impact: The outcome can be unauthorized access, excessive privilege, broken access for legitimate users, or difficult-to-detect drift between intended and effective permissions. The larger the environment, the more dangerous silent authorization drift becomes, because it is often discovered only after misuse or incident review.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST SP 800-53 Rev 5 and OWASP ASVS set the technical controls, while ISO/IEC 27001:2022 defines the regulatory obligations.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | AC-3 — Access Enforcement | Policies determine who may access what and under which conditions. |
| AC-6 — Least Privilege | Both models should minimise permissions and avoid broad standing access. | |
| AC-16 — Security and Privacy Attributes | Policy as code commonly evaluates attributes at decision time for contextual authorization. | |
| Recommendation — Enforce access decisions at the system boundary with centrally managed rules. Minimise assigned privileges and review broad permissions for reduction. Base authorization decisions on verified security attributes and context. | ||
| ISO/IEC 27001:2022 | A.5.15 — Access control | The comparison is fundamentally about how access rules are defined and governed. |
| Recommendation — Define and govern access rules so authorization remains consistent and auditable. | ||
| OWASP ASVS | V8 — Authorization | The subject is an authorization design choice between policy expression models. |
| Recommendation — Verify authorization logic against the intended access model and edge cases. | ||
Practitioner Guidance
What to verify: Check whether your hardest authorization cases are logic-heavy or relationship-heavy. If the answer depends on many live attributes, policy as code is usually the better core; if it depends on stable, centrally governed relationships, policy as data is usually the better core.
What to measure: Track policy change frequency, decision failure rates, exception volume, and drift between intended and effective access. Those signals tell you whether the chosen model is staying understandable and governable as the environment grows.
Common mistake: Treating the choice as binary. In most real systems, the best design is a split responsibility, with data defining the access graph and code applying contextual rules and guardrails on top.
Practitioner takeaway: Choose the model that matches the dominant source of complexity, then build controls around its failure mode, because authorization problems usually come from drift, not from the concept itself.
Related resources from NHI Mgmt Group
- Who is accountable when an MCP-connected coding agent changes code or data outside policy?
- What should teams do when AI tools may expose proprietary code or policy data?
- Who is accountable when Claude Code is used in ways that violate policy or expose sensitive data?
- How should teams use a foreign data wrapper to apply authorization checks in PostgreSQL without embedding policy logic in application code?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org