Skip to main content

Module mac_pep

Module mac_pep 

Source
Expand description

MAC PEP for the direct Namespace API (#1272): the contract Namespace invokes per op, plus fail-closed defaults. The audited production impl lives in hyprstream::mac::pep. MAC PEP for the direct Namespace API (#1272, epic #1267 T3).

The 9P translator already mediates every wire op through hyprstream_9p::AccessDecider (implemented by hyprstream::mac::pep). But the direct in-process Namespace API — cat/echo/create and mount/bind_mount/unmount — forwards a plain Subject to the resolving Mount with no mandatory label lookup or reference monitor, bypassing the translator PEP entirely. This module is that missing reference monitor: the contract the Namespace invokes per op, plus its fail-closed defaults.

§Dependency-direction (mirrors the 9P split)

The trait (the contract the low-level Namespace consumes) lives here in hyprstream-vfs, exactly as hyprstream_9p::AccessDecider lives in the 9P crate. The production audited implementation — bridging to the real RpcObjectLabelResolver, SecurityContext::can_access, and the tamper-evident MAC audit sink — lives in hyprstream::mac::pep, alongside NinePAccessDecider. This keeps the dependency direction one-way (hyprstream → hyprstream-vfs) and does not reinvent label resolution, clearance, or can_access; those are S1/S4 primitives re-exported from hyprstream_rpc::auth::mac.

§Fail-closed by construction; no permissive mode (#547)

Every seam has an explicit deny-all default. A NamespacePep authorizes an op only when ALL of:

  1. the caller’s Subject resolves to a verified [SecurityContext] (clearance provenance — #698; None ⇒ deny),
  2. the walked object resolves to a [SecurityLabel] via the injected [RpcObjectLabelResolver] (None ⇒ deny — “no unlabeled-default-allow”),
  3. clearance.can_access(object_label) (BLP dominance) AND the NamespaceAccessDecider permit. There is no permissive path inside the PEP.

§Activation posture (dormant structure)

A Namespace built with Namespace::new carries pep: None and behaves exactly as before — the un-enforced status quo, matching the rest of MAC enforcement being dormant today (CLAUDE.md “MAC current status”). Installing a PEP via Namespace::with_pep arms the fail-closed monitor: every mediated op then requires a proven subject, and the subject-less mount/bind_mount/unmount deny (use the _as variants). Flipping the default at construction sites is the separately-gated activation B-lane (#1267), not this PR.

Structs§

DenyAllNamespace
Fail-closed decider for a NamespacePep whose production audited decider is unavailable. Every op denies.
DenyAllSubjects
Fail-closed resolver: no subject resolves to a clearance.
DenyUnlabeledResolver
Fail-closed label resolver: no object resolves. Mirrors hyprstream_9p::DenyUnlabeledResolver. Returning None is a mandatory deny (design §1 invariant 2) — the PEP refuses to authorize any op whose object has no trusted label.
NamespacePep
The mandatory, all-or-nothing reference monitor a Namespace mediates every direct-API op through once installed.
SecurityContext
A verified subject’s security context = the clearance label the monitor compares against object labels.
SecurityLabel
A complete security label: a point in the product lattice Level × Assurance × CompartmentSet.

Enums§

MacDecision
The MAC decision returned by the dispatch PEP.
MacDenyReason
Why a MAC decision denied. Auditable and testable.
NamespaceAction
The direct-Namespace-API operation a NamespaceAccessDecider is asked to authorize.

Traits§

NamespaceAccessDecider
Authorizes one direct-Namespace operation against the attempted subject context and object label.
RpcObjectLabelResolver
Resolve the trusted SecurityLabel for the concrete object a dispatching RPC acts on.
SubjectContextResolver
Plane-specific clearance-input seam: resolve a direct-API Subject to the verified SecurityContext that authorizes it.