Search Knowledge

© 2026 LIBREUNI PROJECT

Operating Systems Engineering/Protection, isolation, and synthesis
Page 23 of 29

Protection and Authority

Principals, subjects, objects, access matrices, ACLs, capabilities, complete mediation, least authority, and confused-deputy repair.

Lesson briefProtection, isolation, and synthesis · 5 h 30 min · 4 outcomes

Required knowledge

  • Processes, system calls, file descriptors, and pathname resolution
  • Kernel/user privilege separation and virtual memory permissions
  • Basic threat modeling: assets, adversaries, trust, and attack surfaces

Learning outcomes

  • Model protection decisions as authority over named objects and operations rather than as vague privilege levels.
  • Derive ACL and capability representations from an access matrix and compare delegation, attenuation, and revocation.
  • Trace and repair confused-deputy and time-of-check/time-of-use failures.
  • Distinguish object capabilities from Linux's per-thread capability privilege units and from authentication credentials.

Assessment target

Given an unfamiliar service and authority graph, identify ambient and delegated authority, construct a concrete exploit trace, then redesign and evaluate the boundary under explicit revocation and failure assumptions.

Scope boundary

  • Mandatory information-flow control, noninterference proofs, covert channels, cryptographic authentication protocols, and complete seL4 verification are deferred to security and formal-methods study.
  • Protection mechanisms reduce authority; they do not prove that authorized code is correct or that hardware has no side channels.

A privileged document converter receives an input descriptor and a caller-supplied output pathname. It also needs write access to /var/lib/converter/accounting. A malicious caller chooses that accounting pathname as the output. The converter faithfully opens the requested name with its own authority and overwrites the file it was supposed to protect.

No memory-safety violation is required. Authentication succeeded, permissions behaved as configured, and the converter performed a permitted write. The failure is authority confusion: the converter could not tell whether a write request exercised authority delegated by the caller or ambient authority held for its own bookkeeping.

Name the actors and the authority

Protection answers whether a subject may perform an operation on an object in a state. The vocabulary must remain separate:

termprecise roleexample
principalentity to which accountability or policy attachesuser, service identity, tenant
subjectactive execution context acting for one or more principalsprocess, thread, protection domain
objectprotected resource with stable identityinode, endpoint, address space, device
operationrequested state transition or observationread, map, signal, send, delegate
permissionpolicy relation allowing one operationread on object 17
authorityusable power to affect an object, including powers obtained by delegationdescriptor granting write to object 17
credentialevidence used to establish a principal or attributesUID, signed token, certificate

Authentication establishes or supports a claim about a principal. Authorization decides whether the acting subject has the required authority. Auditing records a decision or action. None substitutes for the others.

For subjects SS objects OO and operation set RR an access matrix is

A:S×O→P(R).A:S\times O\rightarrow\mathcal{P}(R).

A[s,o]A[s,o] is the set of operations subject ss may invoke on object oo The matrix is a specification, not usually a dense implementation. An access-control list stores a column by object: which subjects have which rights. A capability list stores a row by subject: which object references and rights the subject possesses.

Object capability. An unforgeable reference that designates an object and carries authority to invoke a bounded set of operations on it. Possession supplies both designation and authorization.

Unforgeability can come from kernel-managed table entries, tagged hardware, cryptographic construction under a stated threat model, or another protected representation. A pathname string is not an object capability: it is forgeable data requiring a fresh namespace lookup and separate authorization.

Worked representation: one matrix, two indexes

Suppose:

subject / objectupload Ucache directory Caudit endpoint L
parser Pread—send
renderer Rreadcreatesend
janitor J—list, remove—

Object C’s ACL is {R:create, J:list+remove}. R’s capability list is {U:read, C:create, L:send}. Both encode cells from the same abstract matrix, but their engineering costs differ:

  • answering “who can remove from C?” is local in C’s ACL;
  • handing R attenuated create authority to one worker is local with a delegable capability;
  • revoking all access to C is direct at a central ACL check;
  • revoking one copied capability requires indirection, versioning, a revocation tree, object destruction, or another explicit mechanism.

The words ACL and capability do not decide policy quality. A capability carrying broad directory mutation can exceed least authority; an ACL can be narrowly scoped and completely mediated.

Retrieval checkpoint: designation versus authorization

Why can open("/tenant/report", O_WRONLY) be vulnerable even when every pathname component passes a permission check?

Reveal the missing distinctionExpand

The caller supplied a designation—a string interpreted in a mutable namespace. Permission checks answer whether the converter’s subject may traverse and write the object that the string resolves to. They do not establish that the caller was authorized to choose that object for this operation. A confused deputy exploits the converter’s broader authority. A sound protocol must bind caller-conferred authority to the designated object, for example by accepting an already opened descriptor with bounded rights or resolving beneath a directory capability supplied for this request.

Access control matrices, capabilities, and confused deputies

0 / 4 answered

Evaluate each statement regarding access control models, capabilities, and system authority:

Classify each option as correct or incorrect, or leave uncertain options unanswered (“I don't know”) and verify at any time.

1
Passing explicit unforgeable object descriptors over IPC eliminates confused-deputy ambient authority vulnerabilities.
2
Linux thread capabilities like CAP_CHOWN act as fine-grained object capabilities for individual designated files.
3
Access control lists represent columns of an access matrix, whereas capability lists represent rows held by subjects.
4
Calling access before open eliminates time-of-check to time-of-use races for pathnames in world-writable directories.

Derive the reference monitor obligations

A protection decision is trustworthy only if every relevant access path passes through a mechanism that policy controls.

Reference monitor obligations and failure modes:

ObligationArchitectural implementation mechanismConcrete failure mode when violated
Complete mediationHardware MMU checks every memory access; syscall trap checks all requestsPeripheral DMA bypasses CPU MMU; or stale cached capability permits revoked access
Tamper resistanceHardware privilege rings (U-mode vs S-mode); kernel memory protectedStack buffer overflow overwrites kernel PC; or writable mapping aliases page table
VerifiabilityMinimal trusted computing base with formalized state invariantsTens of millions of lines in a monolithic kernel preclude formal correctness proofs

Complete mediation does not require a slow policy database lookup on every byte. A successful open can create a kernel-protected descriptor that embodies the authorized object and access mode; subsequent read operations mediate possession and rights of that descriptor. The cached decision is valid only while the policy contract permits it. Revocation semantics must say whether existing descriptors continue working.

Saltzer and Schroeder’s related design principles sharpen the mechanism:

  • fail-safe defaults: authority is absent unless granted;
  • least privilege/least authority: a subject receives only powers needed for the current task and duration;
  • least common mechanism: minimize shared mechanism on which mutually distrusting subjects depend;
  • separation of privilege: require independent conditions when one condition is too dangerous; and
  • economy of mechanism/open design: make the trusted mechanism analyzable rather than relying on design secrecy.

These are design tests, not slogans. “Use least privilege” is incomplete until the object set, operations, duration, delegation, and failure state are enumerated.

Worked exploit: the pathname deputy

The converter runs with write authority to:

/var/lib/converter/accounting
/srv/jobs/<tenant-output>

Its API is convert(input_fd, output_path). It validates document syntax, then opens output_path itself. The attack trace is:

stepsubject and authoritytransition
1caller controls string but cannot write accountingpasses /var/lib/converter/accounting
2converter has ambient write authorityresolves string under converter credentials
3kernel authorizes converterreturns writable descriptor to accounting object
4converter writes outputaccounting object is corrupted

The permission system did exactly what its input requested. The API discarded provenance: it could not express “use only write authority delegated by this caller for this job.”

Code
left to right direction
rectangle "untrusted caller" as CALLER
rectangle "converter\nambient account + job authority" as DEPUTY
rectangle "mutable pathname namespace" as NS
rectangle "accounting inode" as ACCOUNT
rectangle "job directory capability" as JOBDIR
rectangle "worker\ninput fd + output fd only" as WORKER
CALLER --> DEPUTY : attacker-controlled path string
DEPUTY --> NS : open with deputy credentials
NS --> ACCOUNT : resolves protected name
CALLER --> JOBDIR : request is authorized for tenant scope
JOBDIR --> DEPUTY : broker opens bounded output object
DEPUTY --> WORKER : delegate input/output descriptors
WORKER --> ACCOUNT : no authority path
note bottom of NS
Vulnerable path: designation from caller,
authorization from deputy&#039;s ambient authority.
end note
note bottom of WORKER
Redesigned path: worker receives only
object-specific authority for this conversion.
end note
untrusted callerconverterambient account + job authoritymutable pathname namespaceaccounting inodejob directory capabilityworkerinput fd + output fd onlyVulnerable path: designationfrom caller,authorization from deputy'sambient authority.Redesigned path: workerreceives onlyobject-specific authority for thisconversion.attacker-controlled pathstringopen with deputycredentialsresolves protected namerequest is authorized fortenant scopebroker opens boundedoutput objectdelegate input/outputdescriptorsno authority path

Repair A: descriptor-oriented delegation

An authorized broker opens the output under the tenant’s approved directory, verifies object type, and passes the descriptor to a worker. The worker receives input-read, output-write, and bounded audit-send authority. It never receives a pathname-based ability to open arbitrary files.

The API becomes conceptually convert(input_fd, output_fd, audit_endpoint). The worker can corrupt the designated output if its conversion logic is faulty; it cannot select accounting unless the broker delegated that object.

Repair B: attenuated directory authority

If the worker must create a name, give it a descriptor for one tenant directory and use relative, confinement-aware resolution. Restrict mutation operations, final-component policy, symbolic links, and mount crossings according to the service contract. On capability systems, derive a child capability with reduced rights; on POSIX-like systems, compose directory descriptors, process credentials, namespaces, and kernel resolution controls.

Neither repair proves content safety, kernel correctness, or durability. It removes a specific authority path.

Application checkpoint: verify least authority

The worker needs to read one input, create one output in a tenant directory, and emit one audit record. It receives a read-write descriptor for the entire tenant root and a network socket able to contact any address. Identify excess authority and propose an attenuated set.

Reveal the authority deltaExpand

Excess powers include reading or overwriting unrelated tenant objects, traversing subdirectories, deleting or renaming names if the descriptor and APIs permit it, and sending arbitrary network traffic. A narrower set is: an input descriptor with read-only access; either an already opened output descriptor with write-only/truncate semantics or a create-only authority scoped to one directory and validated name; and a connected or brokered audit endpoint that accepts only the expected message form. Close or revoke each after the conversion.

The answer must discuss operations as well as object scope. Replacing “tenant root” with “tenant output directory” while retaining remove, rename, and read authority may still exceed the task.

Delegation, attenuation, and revocation

Capabilities make delegation explicit: subject A transfers or derives a reference for B. Safe derivation is monotonic attenuation—the child authority is no greater than the parent in object scope, operation set, or an enforced constraint such as time or quota.

Let a capability be modeled as c=(o,R,g)c=(o,R,g) where oo is an object, RR rights, and gg an optional guard. A derived capability c′=(o′,R′,g′)c'=(o',R',g') is attenuated only if the kernel-enforced meaning satisfies

Authority(c′)⊆Authority(c).Authority(c')\subseteq Authority(c).

Matching object identifiers and checking R′⊆RR'\subseteq R is insufficient if a new guard broadens name resolution or if the derived reference reaches an alias outside the parent’s object scope.

Revocation is not automatic:

  • an ACL check can reject future opens after an entry is removed, while already open descriptors may remain valid by policy;
  • a direct object capability copied to many subjects may require deleting the object, traversing a derivation tree, or routing through a revocable proxy;
  • time-limited signed capabilities rely on clock and key assumptions; and
  • revocation that races an in-flight operation needs a defined linearization point.

Worked trace: delegated read with revocation proxy

Subject A owns object X and creates proxy P. B receives capability read(P), while P holds read(X).

  1. Before revocation, B invokes P; P checks its live state and forwards read to X.
  2. A marks P revoked under P’s lock.
  3. A later read beginning after that transition is rejected.
  4. A read already forwarded to X may complete unless the contract includes cancellation.

The proxy adds an indirection and a failure/availability dependency. It supplies a crisp future-use revocation point that an unmediated copied capability lacks. Destroying X revokes more broadly but may violate other clients’ availability.

Transfer checkpoint: choose the revocation contract

A signing service delegates “sign at most ten artifacts before 18:00” to a build worker. List the kernel or trusted-service state required to enforce both constraints, and explain why a bearer token containing those words is insufficient by itself.

Reveal the enforcement obligationsExpand

The operation count needs non-forgeable, race-free mutable state shared by all copies or a trusted online mediator that decrements a counter atomically. The deadline needs a trusted clock and a policy for clock rollback and in-flight operations. The object and key must remain bound to the authority; the worker must not possess an unrestricted signing-key copy. A bearer token is only serialized policy input until a trusted component verifies it and controls every signing path. Copying a ten-use token to two workers must not create twenty uses.

ACLs and capabilities fail in different ways

Consider an object store with one million objects and short-lived workers:

questionACL-centered pressurecapability-centered pressure
enumerate all users of one objectlocal to object policymay require tracking distributed copies
delegate one object to a workerupdate policy or mint scoped credentialtransfer/derive object reference
revoke all future accessupdate central policyrevoke proxy/version/object or derivation subtree
avoid ambient object namingnaming and authorization remain separabledesignation and authority can be one reference
audit principal intentidentity policy is directpossession may need explicit principal/audit binding

A system can combine them. The relevant review question is which component mediates which path and what state survives delegation, caching, process creation, and revocation.

Linux capabilities are not object capabilities

Linux divides powers traditionally associated with superuser into per-thread capability units such as CAP_CHOWN or CAP_NET_ADMIN. Permitted, effective, inheritable, ambient, and bounding sets govern their availability across operations and execve under detailed rules.

Despite the name, CAP_DAC_OVERRIDE is not an unforgeable reference to one file. It is broad privilege to bypass a class of discretionary access checks within the relevant namespace context. Granting it may increase ambient authority over many objects. By contrast, a descriptor opened to one file is closer to an object-specific capability: it designates one kernel object and carries bounded access mode, though surrounding APIs, ioctls, delegation, and revocation semantics still require review.

Similarly, a UID is a credential attribute, not a reference to every object that policy might allow that UID to access. “Use capabilities” is ambiguous until the mechanism is named.

Boundary checkpoint: seccomp and authority

A worker may call only read, write, close, and exit under a system-call filter. It inherits a writable descriptor for the host’s audit database. Is it least-authority with respect to that database?

Reveal the counterexampleExpand

No. write remains permitted and the inherited descriptor designates the database with write authority. Reducing syscall surface does not attenuate the descriptor. The worker needs the descriptor closed or replaced with a narrower endpoint. Conversely, closing the descriptor does not eliminate every kernel attack path; syscall filtering and object authority address different dimensions.

Section Exercises

Deep Practice

Solve these problems to test and consolidate your understanding. Complete worked solutions and diagnostic hints are available for each problem.

Exercise 7.1.1: Access Matrix Row and Column Duality for ACLs and Capabilities

Verificationapplication

An access matrix AA defines permissions for three subjects {S1,S2,S3}\{S_1, S_2, S_3\} across three objects {O1,O2,O3}\{O_1, O_2, O_3\}

  • A[S1,O1]={read,write}A[S_1, O_1] = \{\text{read}, \text{write}\} A[S1,O3]={read}A[S_1, O_3] = \{\text{read}\}
  • A[S2,O2]={read,execute}A[S_2, O_2] = \{\text{read}, \text{execute}\} A[S2,O3]={read,write}A[S_2, O_3] = \{\text{read}, \text{write}\}
  • A[S3,O1]={read}A[S_3, O_1] = \{\text{read}\} A[S3,O2]={read}A[S_3, O_2] = \{\text{read}\}
  1. Write the Access Control Lists (ACLs) associated with objects O1,O2,O3O_1, O_2, O_3
  2. Write the Capability Lists associated with subjects S1,S2,S3S_1, S_2, S_3
  3. Explain which representation is more efficient when revoking all access to O3O_3 versus revoking all access held by S2S_2
HintExpand

ACLs partition matrix A by columns; capability lists partition matrix A by rows.

Worked solutionExpand
  1. Access Control Lists (Columns of AA
    • ACL(O1)={(S1,{read,write}),(S3,{read})}\text{ACL}(O_1) = \{(S_1, \{\text{read}, \text{write}\}), (S_3, \{\text{read}\})\}
    • ACL(O2)={(S2,{read,execute}),(S3,{read})}\text{ACL}(O_2) = \{(S_2, \{\text{read}, \text{execute}\}), (S_3, \{\text{read}\})\}
    • ACL(O3)={(S1,{read}),(S2,{read,write})}\text{ACL}(O_3) = \{(S_1, \{\text{read}\}), (S_2, \{\text{read}, \text{write}\})\}
  2. Capability Lists (Rows of AA
    • CapList(S1)={(O1,{read,write}),(O3,{read})}\text{CapList}(S_1) = \{(O_1, \{\text{read}, \text{write}\}), (O_3, \{\text{read}\})\}
    • CapList(S2)={(O2,{read,execute}),(O3,{read,write})}\text{CapList}(S_2) = \{(O_2, \{\text{read}, \text{execute}\}), (O_3, \{\text{read}, \text{write}\})\}
    • CapList(S3)={(O1,{read}),(O2,{read})}\text{CapList}(S_3) = \{(O_1, \{\text{read}\}), (O_2, \{\text{read}\})\}
  3. Revocation efficiency:
    • Revoking all access to object O3O_3 Trivial with ACLs: the kernel modifies the single entry ACL(O3)\text{ACL}(O_3) directly at the object. With capabilities, finding all references to O3O_3 requires traversing the capability lists of all subjects in the system (unless indirect capability indirection or generation counts are maintained).
    • Revoking all access held by subject S2S_2 Trivial with capabilities: destroying S2S_2‘s capability list revokes all its access in one step. With ACLs, the kernel must scan every object’s ACL in the entire filesystem to purge entries naming S2S_2

Exercise 7.1.2: Tracing and Repairing a Confused-Deputy Attack Scenario

Constructionapplication

A compiler daemon runs as root (uid 0) to compile user programs and write billing metrics to /var/log/billing.log. The user invokes the compiler with: compile --src main.c --out /var/log/billing.log.

  1. Trace how the compiler becomes a confused deputy and overwrites the billing log.
  2. Explain why checking the caller’s permissions via access(out_path, W_OK) before opening fails to solve the architectural problem.
  3. Formulate the capability-based architectural repair that eliminates the vulnerability.
HintExpand

The deputy combines client-chosen designation with server ambient authority. Pass an open descriptor instead.

Worked solutionExpand
  1. Exploitation trace:
    • User inputs destination path /var/log/billing.log.
    • The compiler exercises its ambient root authority and calls open("/var/log/billing.log", O_WRONLY | O_CREAT | O_TRUNC).
    • Because root possesses write authority over /var/log, the open succeeds.
    • The compiler writes compiled machine code over the billing log, destroying audit history. The compiler was confused: it used its own ambient authority to access an object designated by an untrusted client.
  2. Failure of access() check:
    • First, access() creates a time-of-check to time-of-use (TOCTOU) race condition: an attacker can replace the path with a symlink between access() and open().
    • Second, it relies on global ambient path lookup rather than conferring explicit authority.
  3. Capability-based repair: The client must open the destination file in its own user context and pass the resulting open file descriptor to the compiler service over a Unix domain socket (SCM_RIGHTS). The compiler writes exclusively through the provided descriptor. If an unprivileged user specifies /var/log/billing.log, the user’s initial open() fails with EACCES before the compiler is ever invoked. Designation and authority are bundled into an unforgeable descriptor.

Exercise 7.1.4: Contrasting Linux Thread Privileges with Fine-Grained Object Capabilities

Descriptionapplication

Contrast Linux thread capability bits (CAP_SYS_ADMIN, CAP_NET_RAW, CAP_DAC_OVERRIDE) with object-capability systems (such as Capsicum or seL4). Explain why granting CAP_DAC_OVERRIDE to a service increases ambient authority rather than enforcing least authority.

HintExpand

Linux capabilities are coarse privilege flags; object capabilities are unforgeable handles to specific resources.

Worked solutionExpand
  • Architectural distinction:
    • Linux capabilities (capabilities(7)): Partition the monolithic root UID into approximately 40 coarse-grained privilege categories associated with a thread credential. They act as global permission flags checked by the kernel when an unprivileged operation is attempted.
    • Object capabilities (Capsicum / seL4): Unforgeable, fine-grained references that pair the identity of a specific resource (e.g., file descriptor 4, endpoint 0x10A) with a restricted bitmask of allowed methods (CAP_READ, CAP_SEEK). A thread can invoke operations only on resources for which it holds an explicit capability.
  • Ambient authority hazard of CAP_DAC_OVERRIDE: CAP_DAC_OVERRIDE instructs the VFS to bypass all discretionary file read, write, and execute permission checks across the entire filesystem hierarchy. Granting CAP_DAC_OVERRIDE to a service that needs to modify a single configuration file does not restrict it to that file; it grants the ambient power to read or overwrite every file, shadow password, and device node on the system. It maximizes ambient authority rather than enforcing least authority.

Exercise 7.1.5: Proving Confinement and Attenuation in Capability Sandboxes

Proofsynthesis

Let a parent process hold capability C=(O,{read,write,grant})C = (O, \{\text{read}, \text{write}, \text{grant}\})

  1. Define the principle of capability attenuation and prove that a sandboxed child created with derived capability C′=(O,{read})C' = (O, \{\text{read}\}) cannot forge or recover write authority over OO
  2. Formulate Lampson’s confinement problem: why can a child restricted to read-only capabilities still leak data to an external collaborator?
HintExpand

Capability derivation allows monotonically decreasing rights; confinement must prevent covert channels.

Worked solutionExpand
  1. Proof of attenuation safety:
    • Attenuation rule: A subject holding capability C=(O,R)C = (O, R) can derive a new capability C′=(O,R′)C' = (O, R') if and only if R′⊆RR' \subseteq R The derivation operation is monotonic: rights can be surrendered, never added R′⊅RR' \not\supset R
    • Because capability registers or tables are maintained exclusively in kernel space (or protected by hardware tags), user-mode code cannot alter the rights bitmask directly.
    • When the parent derives C′=(O,{read})C' = (O, \{\text{read}\}) and executes the child in a sandbox lacking the original capability CC and lacking grant authority, the child’s capability table contains only C′C'
    • The kernel reference monitor validates every system call against the supplied capability descriptor. Any attempt by the child to issue a write request on C′C' is rejected because write∉{read}\text{write} \notin \{\text{read}\} Since the child has no interface to mint or expand capabilities, write authority cannot be recovered.
  2. Lampson’s confinement problem (1973): Even if the child is completely deprived of write and network capabilities, it can transmit confidential data read from OO to an unconfined conspirator process via covert channels (e.g., modulating CPU scheduling bursts, varying memory footprint to induce page faults, lock contention on shared hardware resources, or thermal throttling). Preventing unauthorized data release requires eliminating all observable side-channel modulations, a much harder problem than discretionary access control.

References & Further Reading