Modeladvanced
Security automaton
Also called Schneider security automaton.
An automaton that watches the actions of a program and halts it on the first action that would break the policy.
A security automaton is the formal model of what a run-time monitor can enforce. Fred Schneider defined it in 2000 as a possibly infinite, possibly nondeterministic automaton that reads the actions of a target program one at a time and moves to a new set of states; when the set becomes empty, the monitor stops the target before the offending action runs. Every policy written as a security automaton is a safety property, and every safety property over a countable set of actions can be written as one. The reference monitor is the concept of a mediator that checks every access, the inline reference monitor is one way to implement it by rewriting the program, and the security automaton is the mathematical object both of them run.
The machine
States and transitions. A security automaton has
- a countable set of states,
- a set of initial states,
- a countable set of input symbols, the security-relevant actions of the target (for example "read a file", "send a message", "call a method with these arguments"),
- a transition function .
The automaton is not required to be finite or deterministic. There are no accepting states: every state is good, and a missing transition is how the automaton says no. In the figures of Schneider's paper, the edges are labeled by predicates on the input symbols, so one edge can stand for many symbols.
Runs. The automaton keeps the set of states it may be in. It starts with . On the input symbol , it moves to . If this set is empty, the input is rejected at . A finite or infinite sequence is accepted when it is never rejected. This is the usual subset simulation of a nondeterministic automaton, done one step at a time.
Use as a monitor. As a monitor, the automaton gets each action of the target before the action runs, and it either lets the action run or stops the target:
MONITOR(Q0, δ, actions s1 s2 s3 ...)- 1
Q′ ← Q0 - 2
for i ← 1, 2, 3, ... while the target runs do - 3
N ← union of δ(q, si) over all q in Q′ - 4
if N = ∅ then stop the target before si runs; return i - 5
Q′ ← N; let si run - 6
return accept ▷ the target ended and every action was allowed
The monitor sees only the actions of the current run, and only those so far. It cannot look ahead, cannot see other runs, and cannot change an action. Its only power is to stop the target. These limits are what the EM-enforceable policies theorem uses.
Example. The policy "no message is sent after a file is read" over the actions read, send and other has two states, clean and tainted, with . From clean, read goes to tainted, and send and other stay in clean. From tainted, read and other stay in tainted, and send has no transition. On the run other, send, read, other, send, send:
| step | action | before | next set | decision |
|---|---|---|---|---|
| 1 | other | {clean} | {clean} | allow |
| 2 | send | {clean} | {clean} | allow |
| 3 | read | {clean} | {tainted} | allow |
| 4 | other | {tainted} | {tainted} | allow |
| 5 | send | {tainted} | stop before step 5 |
The sixth action never happens. The implementation of this page returns the index of the stopped action and is tested against the policy written directly as a predicate on all 3280 traces of length at most 7.
A larger state space. The Chinese wall policy, "after a consultant reads data of one company, it may not read data of a competitor", is a security automaton whose state is the set of companies read so far. A policy such as "at most failed logins" needs states. A policy such as "no more sends than receives" needs a counter, so its automaton has a countably infinite set of states. This is allowed by the definition.
What it counts
The model decides one thing: whether a finite sequence of actions is allowed, that is, whether it is a prefix of an accepted sequence. The set of accepted sequences has two features that every policy in the model shares:
- Prefix closed. If a sequence is accepted, every prefix of it is accepted, because a run that is never rejected is also not rejected on a shorter input.
- Closed under limits. An infinite sequence is accepted when all its finite prefixes are accepted. Rejection always happens at a finite step.
Together these say that the set of accepted infinite sequences is a safety property in the sense of Alpern and Schneider: a sequence is bad exactly when some finite prefix of it is already bad, and no extension can repair that prefix.
The cost of the monitor is the work per action. For an automaton with a finite state set, step L3 costs set operations, where bounds the number of next states of one transition, and the memory is for the set . A deterministic automaton keeps one state and costs one lookup per action. The overhead in practice depends on how many actions are security-relevant and on how the check is placed in the program. The inline reference monitor page covers that.
Relation to other models
- Finite automata. A security automaton with a finite state set and a finite alphabet is a nondeterministic finite automaton in which every state is accepting. Its language of finite words is a prefix-closed regular language, and the subset construction turns it into a deterministic finite automaton with one dead state for rejection.
- Büchi automata. On infinite inputs it is a Büchi automaton in which every state is accepting, so a run is accepting if and only if it is infinite. Such automata recognize exactly the closed (safety) regular languages of infinite words. A Büchi automaton with some non-accepting states can express liveness, such as "the lock is eventually released", which no security automaton can. A safety formula of linear temporal logic can be compiled into a security automaton.
- Access control models. A static access control matrix is a security automaton with one state, in which each allowed access is a self-loop and each forbidden access has no transition. History-based policies, such as the Chinese wall, need more states.
- Reference monitor. The reference monitor is the requirement that a mediator checks every access, cannot be bypassed and cannot be tampered with. The security automaton says what such a mediator can decide when it sees only the current run.
- Edit automata. Ligatti, Bauer and Walker extend the model with monitors that can suppress an action or insert actions of their own, not only stop the target. Edit automata can enforce policies that are not safety properties, so they fall outside the theorem below.
- Hyperproperties. Noninterference relates pairs of runs, so it is a hyperproperty and not a set of runs. No security automaton can express it, because the automaton reads a single run.
Known results in the model
- Every EM-enforceable policy is a safety property (theorem, Schneider 2000). The adversary is a target program that may produce any sequence of actions; the monitor sees each action before it runs and can only stop the target. The proof and its exact hypotheses are on the page EM-enforceable policies theorem.
- Every safety property is a security automaton (theorem). Let be countable and let be a safety property. Take as states the finite sequences that are prefixes of some member of , with and when is such a prefix and otherwise. The state set is countable because is. The automaton accepts a sequence exactly when all its finite prefixes are prefixes of members of , and since is a safety property, that is exactly membership in . So security automata express exactly the safety properties.
- Expressible is not enforceable (theorem, Hamlen, Morrisett and Schneider 2006). A monitor is a program, so its transition function must be computable. With this constraint, a policy that an execution monitor enforces is a co-recursively enumerable property as well as a safety property, and there are safety properties that no computable monitor enforces. The same paper shows that statically enforceable policies are the recursively decidable properties of programs, and that program rewriting, the basis of inline monitors, can enforce policies that no execution monitor enforces.
- More power, more policies (theorem, Ligatti, Bauer and Walker 2005 and 2009). Monitors that can insert and suppress actions enforce a larger class than truncation monitors, which includes the renewal properties, some of which are not safety properties.
- Not hyperproperties. No set of runs equals noninterference, so neither a security automaton nor any monitor that decides one run at a time enforces it in general. Monitors for information flow either over-approximate (they also stop some secure runs) or change the execution itself, as secure multi-execution does by running the program once for each security level.
Code
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/security-automaton/. The authors are listed in prov/MN9D48.jsonl.
from collections.abc import Callable, Hashable, Iterable, Sequence
State = Hashable
Event = Hashable
Delta = Callable[[State, Event], Iterable[State]]
def run_monitor(initial: Iterable[State], delta: Delta, events: Sequence[Event]) -> int | None:
"""Simulate a security automaton on a sequence of events.
The automaton is given by its set of initial states and its transition
function delta(q, s), which returns the set of next states (empty when the
automaton has no move). Return the 0-based index of the first event that
the monitor stops before it runs, or None when the monitor allows every
event. Precondition: delta returns a finite set. Cost: O(k |Q| d) calls of
delta and set work for k events, |Q| states and at most d next states per
move.
"""
current = set(initial) # @line L1
for i, s in enumerate(events): # @line L2
nxt: set[State] = set()
for q in current: # @line L3
nxt.update(delta(q, s))
if not nxt: # @line L4
return i
current = nxt # @line L5
return None # @line L6
def accepts(initial: Iterable[State], delta: Delta, events: Sequence[Event]) -> bool:
"""True when the monitor allows the whole sequence."""
return run_monitor(initial, delta, events) is None
def table_delta(table: dict[tuple[State, Event], Iterable[State]]) -> Delta:
"""Turn a transition table into a transition function; a missing entry has no move."""
def delta(q: State, s: Event) -> Iterable[State]:
return table.get((q, s), ())
return delta
def no_send_after_read() -> tuple[set[str], Delta]:
"""The automaton of the policy "no send after a file read" over the events read, send and other."""
table = {
("clean", "read"): {"tainted"},
("clean", "send"): {"clean"},
("clean", "other"): {"clean"},
("tainted", "read"): {"tainted"},
("tainted", "other"): {"tainted"},
}
return {"clean"}, table_delta(table)
test_security_automaton.py 90 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/security-automaton/. The authors are listed in prov/MN9D48.jsonl.
import itertools
import random
from security_automaton import accepts, no_send_after_read, run_monitor, table_delta
def violates_no_send_after_read(trace) -> int | None:
"""Index of the first send that comes after a read, read straight from the policy."""
seen_read = False
for i, e in enumerate(trace):
if e == "send" and seen_read:
return i
if e == "read":
seen_read = True
return None
def test_page_example() -> None:
q0, delta = no_send_after_read()
assert run_monitor(q0, delta, ["other", "send", "read", "other", "send", "send"]) == 4
assert run_monitor(q0, delta, ["send", "send", "other"]) is None
assert run_monitor(q0, delta, ["read", "read"]) is None
def test_edges() -> None:
q0, delta = no_send_after_read()
assert run_monitor(q0, delta, []) is None
# No initial state: the empty trace is allowed, the first event is stopped.
assert run_monitor(set(), delta, []) is None
assert run_monitor(set(), delta, ["other"]) == 0
# An unknown event has no move.
assert run_monitor(q0, delta, ["exec"]) == 0
def test_against_policy_predicate() -> None:
q0, delta = no_send_after_read()
for k in range(8):
for trace in itertools.product(["read", "send", "other"], repeat=k):
assert run_monitor(q0, delta, trace) == violates_no_send_after_read(trace)
def path_exists(initial, table, trace) -> bool:
"""Oracle: is there a sequence of states that follows the transitions along the trace?"""
states = sorted({q for (q, _) in table} | {r for v in table.values() for r in v} | set(initial))
for path in itertools.product(states, repeat=len(trace) + 1):
if path[0] not in initial:
continue
if all(path[i + 1] in table.get((path[i], trace[i]), ()) for i in range(len(trace))):
return True
return False
def test_nondeterministic_against_paths() -> None:
rng = random.Random(2000)
alphabet = ["a", "b", "c"]
for _ in range(500):
n = rng.randint(1, 3)
states = list(range(n))
table = {}
for q in states:
for s in alphabet:
nxt = {r for r in states if rng.random() < 0.4}
if nxt:
table[(q, s)] = nxt
initial = {q for q in states if rng.random() < 0.6} or {0}
delta = table_delta(table)
trace = [rng.choice(alphabet) for _ in range(rng.randint(0, 5))]
stop = run_monitor(initial, delta, trace)
# The monitor allows exactly the prefixes that have a path.
for k in range(len(trace) + 1):
allowed = stop is None or k <= stop
assert path_exists(initial, table, trace[:k]) == allowed
assert accepts(initial, delta, trace) == path_exists(initial, table, trace)
def test_allowed_set_is_prefix_closed() -> None:
rng = random.Random(7)
q0, delta = no_send_after_read()
for _ in range(500):
trace = [rng.choice(["read", "send", "other"]) for _ in range(rng.randint(0, 9))]
if accepts(q0, delta, trace):
assert all(accepts(q0, delta, trace[:k]) for k in range(len(trace)))
else:
stop = run_monitor(q0, delta, trace)
# Every extension of a stopped prefix is stopped at the same event.
ext = trace + [rng.choice(["read", "send", "other"]) for _ in range(3)]
assert run_monitor(q0, delta, ext) == stop
References
- Fred B. Schneider, Enforceable security policies, ACM Transactions on Information and System Security 3(1), 2000, pp. 30 to 50, the definition of execution monitoring, the definition of security automata and their use as monitors, and the proof that every policy an execution monitor enforces is a safety property
- Kevin W. Hamlen, Greg Morrisett and Fred B. Schneider, Computability classes for enforcement mechanisms, ACM Transactions on Programming Languages and Systems 28(1), 2006, pp. 175 to 205, the computability constraints on execution monitors, static analysis and program rewriting, and the taxonomy of enforceable policies
- Jay Ligatti, Lujo Bauer and David Walker, Edit automata, enforcement mechanisms for run-time security policies, International Journal of Information Security 4(1-2), 2005, pp. 2 to 16, truncation, suppression, insertion and edit automata and the policies each can enforce
- Jay Ligatti, Lujo Bauer and David Walker, Run-time enforcement of nonsafety policies, ACM Transactions on Information and System Security 12(3), 2009, the renewal properties that edit automata enforce, which include policies that are not safety properties
- Bowen Alpern and Fred B. Schneider, Defining liveness, Information Processing Letters 21(4), 1985, pp. 181 to 185, the definitions of safety and liveness properties of executions
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag MN9D48 Edit this page History Report an error Markdown