Definition
Observation is the act of recording or reporting what happened. Enforcement controls whether a protected action may proceed. An observer can record an attempted change even if another component refuses it. An enforcer puts a gate in the action’s path. The gate applies a rule itself or asks another component for a decision. An allowance lets processing continue through this gate. Other checks can still refuse the action. A refusal can prevent the effect only while the gate still controls it.
The idea
A small device sends a status report every 2 ms to an address kept in a setting. A command changes that address, and the rules forbid the change. A monitoring task learns of the change from a message in a queue, decides 10 ms later that the change was forbidden, and raises an alert. The alert is accurate and useful for finding out what happened. It stopped nothing: for those 10 ms the device sent its reports to the new address, and no later alert can recall a report that has already been sent.
A smoke detector and a door lock show the two roles. The detector notices a fire and sounds an alarm; whether the fire starts does not depend on the detector. The lock decides whether someone enters, because the door does not open until the lock releases it. The analogy stops in one respect. A door has one opening, so a lock on it guards every way in, while a software enforcer guards only the actions that pass through it. Any other route to the same effect is unguarded.
The same decision logic can play either role. SELinux (Security-Enhanced Linux), an access-control §1.7 module of the Linux kernel, has two modes. In enforcing mode it refuses every operation that its policy forbids. In permissive mode it computes exactly the same decisions and writes the same “denied” messages to its log, but lets every operation proceed. Administrators use permissive mode to try a new policy without breaking a working system. The decision is identical in both modes; only whether the kernel obeys it differs.
How it works
The analysis needs four named parts.
The action is the operation whose effect a rule protects, such as changing a setting, sending a packet or erasing a region of flash memory §6.6.
The point of no return is the instant after which the effect cannot be undone, for example the moment the radio has sent the last bit of a packet.
The decision is the allow or deny result that a component computes for one specific request.
The gate is the code that performs the action and that can refuse to perform it.
A component enforces a rule for an action only when all five of the following conditions hold.
The gate asks for the decision before it performs the action, and waits for the answer. A call that returns the decision is synchronous: the caller cannot continue until it has the answer. A message placed in a queue is asynchronous: the sender continues at once, and the reader handles the message later.
The gate obeys the decision: on deny, it does not perform the action. Reporting an error to the caller is good practice, but enforcement does not depend on the report.
Before the point of no return, on every path, the gate has an answer it can act on, including when the component that decides is slow, has crashed or returns an error: a missing answer counts as deny. A gate that proceeds when no answer arrives fails open; a gate that refuses fails closed.
Every path to the same effect passes through the gate. This property is called complete mediation §1.16.
The decision describes the exact request that the gate then performs. If the bytes of the request can change between the check and the action, the check covered different data from the data used, which is a time-of-check to time-of-use §9.26 (TOCTOU) error.
If any condition fails for an action, the component does not enforce the rule for that action, whatever its code or its documentation calls it. The component may still stop the action on some paths or in some executions, but on the others a request that the rule forbids can still be performed. The component only observes the action when its decisions never change whether the action happens, for example when the gate ignores every decision.
An observer can be told before the action (a notification that the action is about to happen), after the action (a notification that it has completed), or much later (a symptom, such as a changed value found by a periodic scan). Being told before the action is not the same as enforcing. A notification placed in a queue before the action still yields a decision after the action whenever the reader of the queue is slower than the gate.
Some effects can be undone and some cannot. A changed value in memory can be put back, and a transaction §8.7, a group of changes that takes effect entirely or not at all, can be abandoned before it commits. Putting a value back after the fact is recovery, not prevention: the wrong value existed for a while, and anything that read it in that interval acted on it. In a data structure shared by threads, tasks that run at the same time and share memory, the instant at which an operation takes effect for all other threads is its linearization point §8.6; a decision made after that instant cannot stop other threads from seeing the change. A disclosed secret, a transmitted message, a motor that has moved or a payment that another party has accepted cannot be undone at all. For such effects the action itself is the point of no return, so only a decision made before the action can protect them.
Worked example
A setting byte holds the value 9. A command arrives that would set it to 0, and the rules forbid that change. The same decision function, which takes 50 microseconds to run, is placed in three designs. Times are counted from the moment the command reaches the code that writes the byte. A monitoring task wakes every 10 ms, which is 10,000 microseconds; here its next wake-up falls at 10,000 microseconds.
Design A, enforcement. At time 0 the write function calls the decision function and waits. At 50 microseconds the decision is deny. The write function returns an error and never touches the byte. The byte holds 9 at every instant, and the log says “denied”.
Design B, notification after the action. At time 0 the write function sets the byte to 0. At 1 microsecond it places a notification in the queue and returns. The monitoring task takes the notification at 10,000 microseconds, has its decision at microseconds, logs “denied” and writes 9 back.
Design C, notification before the action, not awaited. At time 0 the write function places the notification “about to set 0” in the queue. At 1 microsecond it sets the byte to 0 without waiting. The monitoring task decides at 10,050 microseconds, logs “denied” and writes 9 back.
All three logs contain the word “denied”, and in all three designs the byte ends at 9. Only design A prevented the change. In designs B and C the byte held the forbidden value 0 for about 10,050 microseconds, roughly 10 ms. In design C the notification was queued 1 microsecond before the write, yet the decision arrived microseconds after the write. Suppose the byte selects where the device sends a report every 2 ms, which is 2,000 microseconds. The window holds report times, so five or six reports, depending on where the window starts, went to the wrong destination. Writing 9 back recovers the setting; it does not recall those reports.
Stated precisely
Let be an action with a protected effect, and let be the request that asks for it. In one execution, let be the point of no return of , and let be the time at which the gate receives the decision about . A component enforces the rule for when, in every execution that the threat model §1.2 allows, passes its point of no return only if the gate received for that same request at a time . A component only observes when its output does not influence whether occurs: in every execution, removing the component, or replacing each of its decisions by allow, leaves the occurrence of unchanged.
The enforcement statement rests on four assumptions. The first two are classic properties of a reference monitor §1.17, the component that checks every access to protected objects.
Complete mediation: every path to passes through the gate.
Tamper resistance: the attacker cannot change the gate, the component that decides, or the channel between them.
Binding: the request that the decision describes is the request that the gate performs.
Failing closed: a missing, late or failed decision counts as deny.
Enforcement by watching has a known reach. Fred Schneider showed in the paper “Enforceable Security Policies” (2000) [236] that a monitor which sees each step of a program before the step takes effect, and whose only power is to stop the program, can enforce only rules that are safety properties §1.11: rules saying that some bad event never happens. A rule such as “every request is eventually answered”, a liveness property §1.12, cannot be enforced this way, because no finite part of an execution shows that the rule has been broken.
Limits and common mistakes
Running is not enforcing. A hook, a place where a program calls extra code at a chosen event, may run before an action. If the program ignores the hook’s result, the hook only observes. Likewise, a deny that refuses a request but leaves an already queued write in place has not prevented that write.
Log order is not causal order. Lines written by several tasks, held in buffers, or stamped by different clocks can show a notification before an action although the decision came after it. Evidence of enforcement is the code path that waits for the decision and refuses on deny, not the order of the log lines.
An enforcer guards only the paths it mediates. A rule enforced on writes through one function says nothing about a second function, a hardware unit that copies memory without the processor, or a debug interface that reaches the same byte.
Observation is still valuable. It provides evidence for investigation, triggers recovery of reversible state, lets a new rule be tried out (as in SELinux permissive mode), and can stop later actions: an alert can revoke a key, close a connection or block a sender. The action that triggered the alert has happened by then. Observation never refuses the action it observes. A false alarm §1.22, an alert about an action that the rule in fact allows, therefore cannot block that action; the response to the false alarm, such as revoking a key, can still refuse later legitimate work. Observation also costs time: a hook that runs before the action delays it by the hook’s running time even when the program ignores the result, and an observer task that shares the processor takes time from other work.
Enforcement has costs. The time the decision takes is added to every gated action. A wrong deny refuses legitimate work, which is a loss of availability §1.10, and a component that decides and stops answering stops every gated action when the gate fails closed.
Questions answered
Does a notification arrive before or after an irreversible action?
A notification can arrive either before or after an irreversible action: which one happens is a property of the particular design and the particular action, and it must be established from the code path, not assumed and not read from the order of log lines. To establish it, find the action’s point of no return, the instant after which its effect cannot be undone, such as the last bit leaving the radio or the end of a flash erase. Then find when the decision based on the notification reaches the code that performs the action.
If the decision reaches that code after the point of no return, the notification supports only detection and recovery: it can trigger an alert, a repair of reversible state, or a response to later actions, but it cannot prevent this action. If the decision arrives before, the notification still cannot be relied on to prevent the action unless the code that performs the action waits for the decision, refuses on deny, refuses when no decision arrives, and is the only path to the effect. A notification placed in a queue before the action, while the action proceeds without waiting, is observation: the decision arrives whenever the reader of the queue gets to it, which is typically after the action.
Related entries: Detection versus prevention (§1.21), Complete mediation (§1.16), Linearization point (§8.6), Reference monitor (§1.17), Fail closed (§1.13). Further reading: [236].