Section 1.19

Policy versus mechanism

Definition

Policy versus mechanism is the distinction between the rules that say what is allowed and the machinery that applies those rules. A policy states which subject, meaning a user or a program, may perform which operation on which object, and under what conditions. A mechanism is the code and hardware that observes each request, evaluates the policy and enforces the result. The difference that matters: changing the policy changes authority, the set of operations each subject can actually cause, while changing the mechanism is meant to leave authority unchanged.

The idea

A building has electronic door locks and a list of which badge may open which door at which hours. The list is the policy. The locks, the badge readers, the wiring and the controller that looks up the list are the mechanism. When a new employee joins, the security office edits the list; nobody rewires the doors. When the readers are replaced by a newer model that reads the same badges and consults the same list, nobody’s access changes. Separating the two lets each one change without disturbing the other, and lets each be examined on its own: is the list right, and do the locks do what the list says?

The picture also shows the limit of the separation. A list entry that says “only during office hours” means nothing if the controller has no clock, and a rule about who may leave a room cannot be enforced by readers mounted only on the outside of its doors. The mechanism decides which policies can be written at all.

Operating-system designers made the separation a principle. A 1975 paper on the Hydra §21.13 operating system set it as a basic design rule: the kernel provides only mechanisms, and policies for allocating resources, such as how processor time is scheduled, live in replaceable components outside the kernel. In security, the Flask §21.12 architecture of 1999 splits a system into a security server, which makes every access decision from the loaded policy, and object managers, which enforce those decisions. SELinux (Security-Enhanced Linux) is built on Flask.

How it works

An enforcement system has one part that is policy and several parts that are mechanism.

An access-control §1.7 standard, XACML (eXtensible Access Control Markup Language), names two of these parts. The policy decision point (PDP) evaluates the policy and returns a decision, and the policy enforcement point (PEP) intercepts the request, asks the PDP and applies the answer. Both are mechanism; the policy is the data that the PDP evaluates. Separating the PDP from the PEP splits deciding from enforcing, which is a different split from the one between policy and mechanism.

Expressiveness, the range of policies that a mechanism can enforce, is limited by three things.

  1. What the hooks observe. A rule can depend only on facts present at some hook.

  2. What the policy language can compute. A table of rows can compare fields with fixed values. A program, for example in bytecode §2.4, a compact instruction format that a virtual machine §2.3 runs, can also count, remember earlier requests and do arithmetic.

  3. What the enforcement can do. If the mechanism can only allow or deny, no rule can ask it to slow a sender down or to rewrite a field.

A rule that needs a fact that no hook observes, or an action that the enforcement lacks, needs a change of mechanism, such as a new hook, and cannot be written as policy alone.

Worked example

Expressiveness, on a network firewall that inspects packets as they pass between two networks:

Authority, on a small rule table. Two subjects, a technician T and a guest G, request one of three operations, read, update and replace-key, on one of two devices, A and B. That gives 2×3×2=122 \times 3 \times 2 = 12 possible requests. Policy PP allows four of them: T reads A, T updates A, T reads B, and G reads A. The other eight are denied.

  1. A mechanism change that keeps authority. The rules move from a list searched from the top to a hash table §14.7, a structure that finds an entry from its key in about constant time instead of scanning a list. For each of the 12 requests the new lookup gives the old answer, so the same 4 requests are allowed and authority is unchanged.

  2. A policy change. Policy QQ adds “T replaces the key of A”. Now 5 requests are allowed. Authority changed by exactly one request, on purpose.

  3. A mechanism change that alters authority by mistake. A new lookup compares the subject and the operation but ignores the device. “T updates A” now also matches the request “T updates B”, and “G reads A” also matches “G reads B”. Six requests are allowed: authority grew by two requests, and nobody touched the policy.

Stated precisely

Describe a request by four values: subject ss, operation aa, object oo and context cc. A policy PP is a rule that gives each request (s,a,o,c)(s, a, o, c) the decision allow or deny. A mechanism MM enforces PP when two conditions hold: every operation that takes effect passes through MM, and MM lets a request take effect exactly when PP allows that request with its true values. The true values are the subject who really asked, the operation that will really run and the object it will really touch, not values that an attacker forged or a parser misread. The authority of the system is the set of requests that can take effect.

Two consequences follow. If MM and M′M' both enforce PP, replacing MM by M′M' leaves authority unchanged. If MM correctly enforces whatever policy is loaded into it, replacing PP by a policy QQ changes authority on exactly the requests to which PP and QQ give different decisions. And a rule RR can be expressed in MM only if RR depends on no fact that MM’s hooks fail to observe, MM’s policy language can compute RR from the observed facts, and every action that RR requires is one that MM can perform.

Showing that a mechanism change preserves authority means showing equal decisions for every possible request, not for a few tested ones, and showing that the hooks and the binding of true values are unchanged. Testing all 12 requests covers the small table above completely. A real system has too many possible requests to test them all, and needs an argument that the two lookups compute the same function.

Limits and common mistakes

A correct mechanism enforces a bad policy exactly. A policy that gives every technician the right to replace every key is enforced as written.

Every mechanism carries some policy of its own. What happens when no rule matches, what happens when no decision can be made (fail open §1.14 or fail closed §1.13), and which rule wins when two rules match are policy choices made inside the mechanism. In a table where the first matching row wins, reordering the rows changes authority although no row changed.

A policy update that contains only data still changes authority. It needs the same authentication and authorization as a code update. An update that only removes permissions is easier to accept safely than one that adds them.

A policy written as a program is code. It can loop, use up time and memory, and contain bugs, so the mechanism must confine it as it would confine any untrusted program, for example in a sandbox §2.30 with a time limit.

A mechanism bug can invert decisions without any change to the policy, for example a caller that treats the deny code 0 as success. Correct policy text proves nothing about the decisions that are applied.

No policy can create an observation or an action that the mechanism lacks. A claim about what a programmable policy can enforce must name the hooks and the actions that are available.

Questions answered

Which parts of an enforcement system can change without changing its authority?

The mechanism’s internal representation and implementation can change without changing authority, and the policy cannot. Authority is the set of operations that each subject can actually cause. The parts that may change are how the rules are stored (a list or a hash table, one encoding or another), the lookup algorithm §14.1, caching §14.20 and code layout, provided that the new version gives the same decision for every possible request, intercepts requests at the same points and binds the same true facts to them. Any change to the policy, the rules that say who may do what, changes authority by definition, even when the change is small and intended. A policy change must therefore be treated as a change of authority, and only a party allowed to change authority may make it.

A third group of parts belongs to the mechanism but decides authority as surely as the policy does: authentication of the subject, parsing of the request, the placement of hooks, the default when no rule matches, error handling and rule order. Changing any of them can change authority while the policy text stays the same; a lookup that starts ignoring the object field, for example, lets a permission for one device cover every device. Such changes need the same demonstration of equal decisions as any other mechanism change, and a new library version or data format is not neutral to authority merely because its interface did not change.

Related entries: Authorization (§1.7), Complete mediation (§1.16), Assumption versus guarantee (§1.36), Reference monitor (§1.17), Fail closed (§1.13). Further reading: [215, 216].