← Writing

Policy-based access control · Part 1 of 2

Policy-Based Access ControlHow AWS, Google Cloud, Kubernetes and Cedar Decide

Part 1: how the big IAM systems turn a pile of policies into one yes or no, from AWS’s six policy types to Cedar’s forbid rules and XACML’s combining algorithms.

Oct 24, 2026 · 25 min read

Every access system starts with a sentence like “doctors can read patient records.”

That sentence is a role and a permission, and any framework can store it. Then the product meets real users and the sentence keeps growing:

Only the first clause is about a role. Everything after it is about attributes.

Only the first clause is about who someone is. The rest are about facts: which patients a doctor treats, which clinic a record belongs to, what time it is, what kind of note this is, which field of the record is being shown. You can try to encode each fact as a new role, “Koramangala day-shift doctor without psychiatry,” and some systems do, for a while. It stops working somewhere around the fortieth role.

Policy-based access control is what you build instead. Rules are written as policies over attributes, stored apart from the code, and evaluated by one engine that every part of the product asks.

That idea is old and well tested. AWS, Google Cloud, Kubernetes, and Amazon’s Cedar language all implement a version of it, and the XACML standard described the whole architecture in the early 2000s. They made different choices, and the differences are the most useful thing to study before building your own. This post is about how the established systems turn a pile of policies into one yes or no. Part 2 builds one, including the parts the tutorials skip, such as missing attributes, masked fields, and filtering lists.

The examples use a made-up product, Cliniq, a chain of clinics with patients, doctors, nurses, front-desk staff, and billing:

01RBAC, ABAC, PBAC

Three acronyms get used as if they were rival products. They’re closer to three stages of the same idea.

Role-based access control (RBAC) gives permissions to roles and roles to people. The question it answers is “is this user in a role that holds this permission?” It was standardised by NIST and later as ANSI INCITS 359, and almost every product starts here because it’s easy to explain: Dev is in Billing, Billing can read invoices.

Attribute-based access control (ABAC) decides with attributes of four things: the subject asking (Dr. Mehta, her clinic, her shift), the resource (Kavya’s record, its clinic, its note type), the action (read, update, export), and the environment (the time, the network, whether the session used a second factor). NIST’s SP 800-162 is the standard reference. A role becomes just one more attribute of the subject.

Policy-based access control (PBAC) isn’t a separate formal model. It’s ABAC with an operational promise: the rules live as policies, in a format a machine can evaluate and a person can review, stored and versioned outside the application, and evaluated by a single decision engine. In practice “ABAC” describes what the rules can say, and “PBAC” describes where they live and who owns them.

PBAC is less a new model than ABAC with the rules taken out of the code and given an owner.

Real systems mix all three. AWS IAM is policy-based but still has roles. Kubernetes is pure RBAC by design. Google Cloud is RBAC with ABAC conditions bolted onto the bindings. The useful question isn’t which acronym to pick. It’s how rules are written, where they attach, and what happens when two of them disagree.

The definition I’ll use for the rest of this post:

a policy is a rule that says who may do what to which resource, under which conditions, written as data that one engine evaluates.

02The four parts every policy system has

In 2003 the OASIS XACML standard drew a diagram that nearly every authorization system since has redrawn under different names. It splits the work into four parts, each with an awkward acronym:

  • PEP, the policy enforcement point. The code that stands in front of the resource and refuses to continue without a yes. An API handler, a gateway, a middleware.
  • PDP, the policy decision point. The engine that takes a request and the policies and returns a decision. It never touches the resource itself.
  • PAP, the policy administration point. Where policies are written and stored: a console, an admin screen, a git repository.
  • PIP, the policy information point. Wherever the attributes come from: the HR system that knows Dr. Mehta’s clinic, the rota that knows her shift, the database that knows which clinic Kavya’s record belongs to.
The enforcement point never decides, and the decision point never touches the data. Keeping those two apart is most of the architecture.

Follow one request through it. Dr. Mehta opens Kavya’s record:

  1. The records API (the PEP) receives GET /records/k-881. Before loading anything sensitive, it builds a question: subject dr-mehta, action record.read, resource record:k-881.
  2. It sends the question to the PDP.
  3. The PDP finds the policies that could apply to a read of a record.
  4. Those policies mention her clinic, her shift, and the record’s clinic and note type, so the PDP asks the PIP for the attributes it doesn’t have yet.
  5. It evaluates, and returns Permit, with an obligation attached: “mask the phone number.”
  6. The PEP loads the record, applies the obligation, and responds. Had the answer been Deny, it would have returned a 403 without ever loading the record.

Every system in this post fits this shape, even when it doesn’t use the words:

The one design question this diagram forces early is step 4: who gathers the attributes? There are two answers, and every system picks one or mixes both.

Push: the PEP sends everything the PDP needs along with the question. OPA works this way by default; the input document is whatever the caller put in it. It’s fast and keeps the PDP simple, but now the PDP believes whatever the PEP says, and every PEP has to know which attributes every policy wants.

Pull: the PDP fetches attributes itself, from sources it trusts. It’s slower and the PDP needs access to more systems, but policies can change what they look at without every caller changing too.

A common middle ground: the caller pushes facts about the resource, which it has just loaded anyway, and the PDP pulls facts about the subject from an identity source it trusts. That way the one party that wants access never gets to describe itself.

03What a policy looks like

Strip away the syntax and every policy language has the same five slots:

Every policy language in this post has these five slots. They differ in how much each slot can say.

The interesting differences are in how much each slot can say, and what the condition is allowed to look at. To make that concrete, here is one Cliniq rule written in four real policy languages:

Doctors can read the records of patients at their own clinic, during their shift.

AWS IAM policy

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": "cliniq:ReadRecord",
    "Resource": "arn:cliniq:records:*:*:record/*",
    "Condition": {
      "StringEquals": {
        "aws:ResourceTag/clinic": "${aws:PrincipalTag/clinic}"
      }
    }
  }]
}

This is AWS’s own ABAC pattern: tag the principal and the resource, and compare the tags with a policy variable. (cliniq:ReadRecord is invented; AWS only evaluates its own services’ actions.) Notice what’s missing. AWS conditions compare a key from the request to fixed values or to another key. There’s no arithmetic and no way to say “now is between this person’s shift start and end,” so the shift clause can’t be written here at all. The language is deliberately small because AWS has to evaluate it billions of times a day and prove things about it.

Cedar

permit (
  principal in Cliniq::Role::"doctor",
  action == Cliniq::Action::"readRecord",
  resource is Cliniq::Record
)
when {
  resource.clinic == principal.clinic &&
  context.hour >= principal.shiftStart &&
  context.hour < principal.shiftEnd
};

Cedar, the language behind Amazon Verified Permissions, says the whole sentence. The scope in brackets (principal, action, resource) is separated from the condition on purpose: the scope is what Cedar indexes to find the policies that might apply, and the when clause is only evaluated for those. Entities have types and a hierarchy, so principal in Role::"doctor" is a membership test, not a string comparison.

Open Policy Agent (Rego)

package cliniq.authz

default allow := false

allow if {
  input.action == "record.read"
  "doctor" in input.subject.roles
  input.resource.clinic == input.subject.clinic
  input.context.hour >= input.subject.shift.start
  input.context.hour < input.subject.shift.end
}

Rego is a general query language derived from Datalog. Each line in the body must hold for allow to be true, and default allow := false makes a missing match mean no. It can express almost anything, including rules that call out to data or loop over collections. That power is the trade: it’s easy to write a policy that’s hard to read, hard to analyse, and slow.

Google Cloud IAM, with a condition

{
  "bindings": [{
    "role": "projects/cliniq/roles/recordReader",
    "members": ["group:[email protected]"],
    "condition": {
      "title": "Koramangala records, day shift",
      "expression": "resource.name.startsWith('projects/cliniq/clinics/kor/')
        && request.time.getHours('Asia/Kolkata') >= 8
        && request.time.getHours('Asia/Kolkata') < 20"
    }
  }],
  "version": 3
}

Google puts the who in the binding’s members and lets the condition, written in CEL, look only at the resource and the request. A condition can’t ask about the principal’s attributes, so “their own clinic” becomes a separate binding per clinic, with the clinic baked into the group and the resource name. The shift becomes a fixed window rather than each person’s rota. (As with AWS, the role and resource names are invented: Google’s IAM governs Google Cloud resources, not your app’s records.)

What the comparison shows

The less a language can say, the more its owner can promise about it.

The pattern: the less a language can say, the more its owner can promise about it. AWS and Google can analyse every policy in an account and tell you who can reach a bucket. That’s much harder with Rego. Cedar is the deliberate middle, expressive enough for application rules and still restricted enough to analyse.

04How AWS IAM decides

AWS IAM is probably the largest policy-based system in existence, and its evaluation logic opens with three short rules:

  • Every request is denied by default (the account root user aside).
  • A request needs an explicit Allow to go through.
  • An explicit Deny overrides any Allow.

Those three rules make the result independent of order. It doesn’t matter which policy was attached first or which one AWS reads first: one matching deny anywhere wins, and without a matching allow, the answer is no. Most of what makes AWS IAM feel complicated comes from the number of places a policy can attach, not from how they combine.

Six kinds of policy, two that grant

Only two kinds of policy grant anything. The other four exist purely to take access away.

Suppose Cliniq runs on AWS and keeps scans in an S3 bucket called cliniq-scans. Here is what each policy type is for, in Cliniq terms:

Highlighted cards can grant. The rest can only take away.

The distinction in the middle column is the most useful idea in AWS IAM. An SCP that says "Allow": "s3:*" doesn’t give anyone S3 access. It only means S3 isn’t ruled out at the organisation level. Someone still has to be granted it, by an identity-based or a resource-based policy. Caps and grants are different kinds of thing, and AWS never lets a cap grant.

The order of evaluation

Simplified from AWS’s evaluation logic for a request within one account. Cross-account requests need both accounts to say yes.

Two details in that flow are worth slowing down for.

Step 1 is global. Before anything else, AWS looks for a matching Deny in every applicable policy, including the ones that can’t grant. That’s how an SCP or a bucket policy can take away something a role was given.

Step 4 is the exception that catches people. Within one account, if a resource-based policy names the calling IAM user or session directly, that can be enough on its own, even if the identity-based policy says nothing. Cross-account is stricter: the caller’s account must allow the request and the resource’s account must allow it too.

A request, step by step

The reports role tries to read s3://cliniq-scans/koramangala/k-881.dcm. These policies are in play:

SCP on the prod OU
{
  "Effect": "Deny",
  "Action": "*",
  "Resource": "*",
  "Condition": {
    "StringNotEquals": {
      "aws:RequestedRegion": "ap-south-1"
    }
  }
}
Bucket policy
{
  "Effect": "Deny",
  "Principal": "*",
  "Action": "s3:*",
  "Resource": "arn:aws:s3:::cliniq-scans/*",
  "Condition": {
    "Bool": { "aws:SecureTransport": "false" }
  }
}
Identity policy on reports
{
  "Effect": "Allow",
  "Action": "s3:GetObject",
  "Resource": "arn:aws:s3:::cliniq-scans/*"
}
Boundary on reports
{
  "Effect": "Allow",
  "Action": "s3:Get*",
  "Resource": "arn:aws:s3:::cliniq-reports/*"
}

(A real region-lock SCP exempts global services such as IAM. This one is trimmed to the idea.) Walking the flow:

Granted by the identity policy, stopped by the boundary.

The identity policy grants the read, but the boundary says this role may only ever read from cliniq-reports. The request is denied, and nothing in the identity policy can change that. This is exactly what boundaries are for: the platform team lets developers create their own roles, and the boundary guarantees those roles can never exceed a fixed set, whatever the developers write.

A permission has to survive every cap. A boundary that allows s3:* grants nothing on its own.

What to take from AWS

  • Default deny plus “deny wins” makes order irrelevant. No priorities, no “first match.” You can add a policy without worrying about where it sorts.
  • Separate grants from guardrails. Policies that grant and policies that cap are different types. A guardrail can’t accidentally hand out access.
  • Deny with a negated condition fails closed. In the SCP above, a request with no aws:RequestedRegion at all would make StringNotEquals true, so the deny applies. That’s the safe direction for a deny, and it’s documented behaviour we’ll come back to in part 2.
  • The cost is debugging. “Access denied” could come from any of six places. AWS has since added the type of policy responsible to many access-denied messages, because people couldn’t tell. Build that into your own system from the start.

05How Google Cloud IAM decides

Google Cloud starts from a different place. Instead of attaching policies to principals, it attaches them to resources, and resources live in a tree: an organisation contains folders, folders contain projects, and projects contain buckets, databases and everything else.

An allow policy on a resource is a list of bindings. Each binding says “these members hold this role here,” optionally with a condition. A role is a named bundle of permissions such as storage.objects.get: Google ships basic roles (Owner, Editor, Viewer), hundreds of predefined ones, and lets you define custom roles.

allow policy on the koramangala project
{
  "bindings": [
    {
      "role": "projects/cliniq/roles/scanReader",
      "members": ["group:[email protected]"]
    },
    {
      "role": "roles/storage.objectViewer",
      "members": ["user:[email protected]"],
      "condition": {
        "title": "Locum, October only",
        "expression": "request.time < timestamp('2026-11-01T00:00:00Z')"
      }
    }
  ],
  "version": 3
}

The second binding is a temporary grant: a visiting doctor can read objects in the project until the end of October, and nobody has to remember to remove them. Conditions need policy version 3, and the condition can only look at the resource (name, type, tags) and the request (time, and a few others), never at the principal’s attributes.

Inheritance: grants flow down and add up

The bucket’s effective allow policy is its own bindings plus every ancestor’s. Nothing lower down can take an inherited grant away.

A resource’s effective allow policy is the union of its own bindings and every ancestor’s. Grant the clinical leads Viewer on the clinics folder and they can see every project and bucket under it, including ones created next year.

The flip side is the most important thing to understand about allow-only inheritance: you can’t remove at a lower level something granted higher up. If clinical leads shouldn’t see the psychiatry bucket, no binding on that bucket can say so. With allow policies alone, the only fixes are moving the bucket out of the folder or narrowing the grant at the top. That gap is why Google added deny policies.

Deny policies and boundaries

Google evaluates them together, but the effect is as if they ran in this order: any block wins, and only an allow binding can grant.

Deny policies attach to an organisation, folder or project and are inherited downward like allow policies. Each rule names denied principals and denied permissions, and, importantly, exceptions to both:

deny policy on the organisation
{
  "displayName": "Patient scans can't be deleted",
  "rules": [{
    "denyRule": {
      "deniedPrincipals": ["principalSet://goog/public:all"],
      "exceptionPrincipals": [
        "principalSet://goog/group/[email protected]"
      ],
      "deniedPermissions": ["storage.googleapis.com/objects.delete"],
      "denialCondition": {
        "title": "Only buckets tagged as patient data",
        "expression": "resource.matchTag('123456789012/data-class', 'phi')"
      }
    }
  }]
}

Read it as: nobody may delete objects in buckets tagged data-class=phi, except the retention team. Even a project Owner, who holds every storage permission through the allow policy, is stopped. The exception is part of the deny rule itself, so the person reading the rule sees both the rule and who escapes it in one place.

Principal access boundary policies are the newest layer. They attach to a set of principals, such as everyone in a workforce identity pool, and list the resources those principals are eligible to access at all. Like AWS’s permission boundaries, they can only take away. A contractor pool bounded to the koramangala project can’t reach anything else, whatever bindings someone adds by mistake.

What to take from Google

  • Attach to the resource tree, not to people. “Who can touch this?” is one walk up the tree. “What can this person touch?” is the expensive question, and Google built Policy Analyzer to answer it.
  • Inheritance makes broad grants easy and exceptions hard. If your product has a hierarchy (organisation, region, clinic, department), decide early how a lower level says “not here.”
  • Put exceptions on the deny rule, not on the person. A list of excepted groups inside the rule can be reviewed. A pile of per-user overrides can’t.
  • Keep conditions about the resource and the request. Google’s choice to keep principal attributes out of conditions is a limitation, but it’s also why its conditions stay fast and simple to index.

06How Kubernetes RBAC decides

Kubernetes makes the opposite bet from AWS and Google. Its RBAC documentation states it in one line: “Permissions are purely additive (there are no ‘deny’ rules).”

A Role is a list of rules, each naming API groups, resource types, verbs and, optionally, specific resource names. A RoleBinding grants a role to users, groups or service accounts. Suppose Cliniq runs its API on Kubernetes and wants on-call engineers to read logs in production without being able to open a shell inside a container:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: clinic-api
  name: log-reader
rules:
  - apiGroups: [""]
    resources: ["pods", "pods/log"]
    verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  namespace: clinic-api
  name: oncall-log-reader
subjects:
  - kind: Group
    name: oncall
    apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: log-reader
  apiGroup: rbac.authorization.k8s.io

Opening a shell is the create verb on the pods/exec subresource. It isn’t listed, so it isn’t granted. There’s nothing to deny because nothing was given.

The role says what. The binding says who, and where. A ClusterRole used through a RoleBinding is the pairing most people miss.

Why no deny rules?

With only allows, the effective permissions of a user are simply the union of every binding that mentions them or their groups. That buys three properties that are worth a lot:

  • Order never matters. There’s no precedence to get wrong, because nothing can override anything.
  • Bindings compose. Adding a binding can only add access. Removing one can only remove it. Nobody’s access changes as a side effect of an unrelated rule.
  • Audits are a list. “Who can read secrets in clinic-api?” is answered by collecting bindings, not by evaluating a policy program.

The cost is that you can’t say “everything except.” The classic trap is a role with resources: ["*"] meant to mean “all the normal stuff,” which also includes Secrets. In an allow-only system, the only way to exclude something is to list everything else.

Where the rest of the decision happens

Authorization sees the verb, the resource type, the namespace and the name. Only admission control sees what’s inside the object.

RBAC is one authorizer in a chain. Each authorizer can allow, deny, or have no opinion. The first allow or deny ends the chain, and if every authorizer abstains, the request is denied. RBAC itself never denies; a webhook authorizer can.

And authorization only sees the request’s attributes: user, groups, verb, resource, namespace, name. It never sees the object. “Pods in production must not run as root” can’t be an RBAC rule, because RBAC doesn’t know what’s in the pod. Rules about content belong to admission control, which runs after authorization allows a request: built-in ValidatingAdmissionPolicy in CEL, or tools like OPA Gatekeeper and Kyverno.

That split is a design lesson in its own right. “May this person create a pod here?” and “is this particular pod acceptable?” are different questions, asked at different moments, with different data. Plenty of home-grown systems force both into one function and end up with neither done well.

Escalation prevention

One more Kubernetes rule is worth copying directly. You can only create or update a role if you already hold every permission in it, and you can only bind a role whose permissions you already hold. The exceptions are the explicit escalate and bind verbs, which are themselves permissions someone must be granted.

Without that rule, anyone who can edit roles can make themselves an administrator. Any admin screen you build that lets customers create roles or assign them needs the same check.

Finally, aggregated ClusterRoles solve the “new resource type” problem: a ClusterRole can declare a label selector, and any ClusterRole carrying that label is merged into it automatically. The built-in view, edit and admin roles work this way, so when you install a custom resource, you can extend “view” to cover it with a label instead of editing a central role.

07How Cedar decides

AWS IAM governs AWS. Cedar is what AWS built for governing your application: an open-source policy language, released in 2023, that runs as a library in your process or as a managed service in Amazon Verified Permissions. Of all the systems here, it’s the closest to what you’d design for Cliniq, so it’s worth understanding in detail.

Two effects, one rule

Cedar policies are either permit or forbid. The decision rule fits in one sentence: the answer is Allow if at least one permit is satisfied and no forbid is.

One cell out of four says yes. Policies that error count as not satisfied, which matters a lot for forbid.

That’s AWS’s rule again (default deny, deny wins) in a language built for applications. The order of policies never matters, and adding a forbid can never grant anything.

Entities and hierarchy

Everything Cedar reasons about is a typed entity with attributes and parents. The application passes the relevant entities in with each request:

Arrows point to parents. principal in Clinic::"koramangala" is true for Dr. Mehta, and resource in Clinic::"koramangala" for the record.

The in operator walks parents, so roles, groups, clinics and folders are all the same mechanism. Cliniq’s rules become:

// Doctors read records at their own clinic.
permit (
  principal in Cliniq::Role::"doctor",
  action == Cliniq::Action::"readRecord",
  resource is Cliniq::Record
)
when { resource in principal.clinic };

// Psychiatric notes: only the treating psychiatrist, whoever else is allowed.
forbid (
  principal,
  action == Cliniq::Action::"readRecord",
  resource is Cliniq::Record
)
when { resource.noteType == "psychiatry" }
unless { resource.treatingPsychiatrist == principal };

The forbid is how you write an exception that no role can override. It doesn’t matter how many permits a future developer adds; a psychiatric note stays closed to everyone but the treating psychiatrist.

The trap: a forbid that errors is skipped

Here is the detail most Cedar introductions skip. When evaluating a policy produces an error, such as reading an attribute the entity doesn’t have, Cedar’s documentation says that policy “does not factor into the authorization response; it is skipped.” For a permit, that’s harmless: a skipped permit grants nothing. For a forbid, it’s the opposite.

Suppose a psychiatric note arrives from an old system before anyone has assigned a treating psychiatrist, so the record has no treatingPsychiatrist attribute. Dr. Mehta, a general doctor at the same clinic, opens it:

PolicyEvaluates toEffect
permit: doctors at their clinictruea permit is satisfied
forbid: psychiatric noteserror: no such attributeskipped
DecisionAllow

The rule meant to protect the most sensitive notes is silently ignored on exactly the records that are least well maintained. The response does carry diagnostics listing the error, but an application that only reads the decision won’t notice. The fix is to make the forbid’s exception impossible to error:

unless {
  resource has treatingPsychiatrist &&
  resource.treatingPsychiatrist == principal
};

Now a missing attribute makes the unless false, so the forbid applies. Better still, declare a schema. Cedar’s validator checks policies against it before they’re saved and rejects reading an optional attribute without a has guard, so this mistake can’t reach production.

The general lesson, for any engine you build or adopt:

decide what an error means. For a rule that grants, an error must not grant. For a rule that takes away, an error must still take away.

Built to be analysed

Cedar was designed so that tools can reason about policies, not only evaluate them. It has no loops, no arbitrary function calls, and no side effects, and its core has been formally specified and checked with the Lean proof assistant. That restraint makes questions like “does this change let anyone new read psychiatric notes?” answerable by translating policies to logic and asking an SMT solver, instead of by hoping a test covers it.

Cedar also has templates: a policy with placeholders, such as ?principal and ?resource, that you link to specific entities at runtime. “Dr. Rao may read Kavya’s record for this referral” is one linked template, not a new hand-written policy, and revoking it is deleting the link.

08How XACML combines

XACML, the eXtensible Access Control Markup Language, is an OASIS standard whose current version, 3.0, dates from 2013. Few new systems choose it today; it’s verbose XML, and the tooling is mostly enterprise products. But it’s the most complete written description of how policy systems work, and two of its ideas are worth taking even if you never write a line of it: combining algorithms and obligations.

Policies inside policies

Rules sit inside policies, policies inside policy sets. Each box says how the boxes inside it combine.

A rule has an effect (Permit or Deny), a target that says when it applies, and an optional condition. A policy groups rules. A policy set groups policies and other policy sets. Each container declares how its children’s answers combine. Abbreviated, a rule looks like this:

<Rule RuleId="psychiatric-notes" Effect="Deny">
  <Target>
    <!-- applies when resource note-type = "psychiatry" -->
  </Target>
  <Condition>
    <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:not">
      <!-- subject-id equals resource treating-psychiatrist -->
    </Apply>
  </Condition>
</Rule>

Four answers, not two

A XACML decision is one of four values: Permit, Deny, NotApplicable (no rule had anything to say) and Indeterminate (something went wrong, such as a missing attribute). Version 3.0 even records which way an Indeterminate was leaning: it could have been a Permit, a Deny, or either.

That’s more honest than a boolean. “No policy covers this” and “a policy broke while deciding” are different situations, and a system that collapses both into false can’t tell you which one happened. The standard also says what the enforcement point should do with the awkward answers: a deny-biased PEP treats anything other than Permit as Deny. That’s the right default for almost everyone.

Combining algorithms

This is XACML’s real contribution: it names the choices that other systems make implicitly. Take three rules and one request, Dr. Mehta opening a psychiatric note with no emergency declared:

Dr. Mehta opens a psychiatric note. Three rules, three different answers.

Now combine those three answers four different ways:

Same request, same rules, same results. Only the combining algorithm changed.

Every system in this post has picked one of these, whether it says so or not:

  • AWS, Google Cloud and Cedar use deny-overrides with a default of deny.
  • Kubernetes RBAC is permit-overrides with no deny rules at all, which makes the difference invisible.
  • Firewalls and many hand-written systems use first-applicable: the first matching rule wins, so the order of the list is the policy.

First-applicable deserves a warning. It feels natural, because it’s how people write if statements, but the two first-applicable rows in the figure give opposite answers for the same rules. In a system where several admins add rules, someone reordering a list can open a hole that no individual rule shows.

Obligations

A XACML decision can carry obligations: instructions the enforcement point must carry out along with the decision. “Permit, and log this read to the psychiatric access register.” “Permit, and mask the phone number.” If the PEP can’t carry an obligation out, it must not grant access.

That’s the cleanest model I know for field masking. The decision point doesn’t just say yes; it says yes and what has to happen to the response. Part 2 uses exactly that shape for masking fields.

09Five systems side by side

Here are the five systems side by side:

All five deny by default. They differ in where policies attach and how restrictions are expressed.

Put them next to each other and a consensus shows up. Default deny everywhere. Explicit deny beats allow everywhere that has deny. Every system separates what grants from what restricts, whether as policy types (AWS), separate policy kinds (Google), effects (Cedar, XACML), or by moving restrictions to another layer entirely (Kubernetes admission). Where they differ is in what conditions may look at, and in how much they let you reason about policies before running them.

If you remember one thing:

default deny, deny overrides allow, and restrictions are a different kind of thing from grants.

Next: building one

Knowing how the big systems decide is half the job. The other half is what happens when the policies are about your own data: clinic managers writing rules, records with missing fields, list screens that need the same rules as a WHERE clause.

Part 2 builds a policy engine for Cliniq: combining policies attached at five levels, a decide() function, conditions that survive missing data, masked fields and the ways they still leak, compiling policies to SQL, and an editor that lets non-engineers write policies without handing them the keys.

Further reading

Cliniq and its people are invented for this article. The AWS, Google Cloud, Kubernetes, Cedar and XACML behaviour described is from their documentation; the policy names and resources in the examples are made up.