Skip to main content

Module avc

Module avc 

Source
Expand description

Access Vector Cache — the fast local decision cache the PEP consults per op (S4 / #570).

SELinux-style AVC: the PEP (S2) asks the AVC for a decision on every op; on a hit it returns a cached Decision with no Casbin, no signature verify, no lattice walk — just a hash lookup. On a miss it calls the TeEvaluator (the PDP) once, caches the result, and returns it. Fail-closed: any ambiguity (wrong generation, poisoned lock, evaluator absent) → DENY.

§The hot path (what must be cheap)

PEP.check(op) → AVC.decide(key) ─hit→  return cached Decision        (sub-µs, lock-free read)
                               └miss→  evaluator.evaluate(...) ; insert ; return

The cache KEY is (generation, subject_type, clearance, object_type, label, action). The TE types are interned ids and the clearance/label are S1’s structured SecurityLabels — which are Copy + Hash (a packed level/assurance/u64-bitset, S1 confirmed cheap), so the whole key is Copy and hashes cheaply with no dominance walk and no signature verify on a hit (#570 requirement). We deliberately key on the resolved context, not on raw strings/paths: string matching (Casbin’s job) is done once at compile time, never per op.

§Token = distributed AVC entry (design §2, §6)

The OAuth access token IS an AVC entry, minted by the authority and carried by the subject. It encodes {label_ceiling, op_set, ttl} (design §11). The mapping:

access token T  ──(verified ONCE at bind/refresh by the PEP)──►  AvcSeed
  T.cnf / sub      → subject_type + clearance (subject ctx, design §2)
  T.label_ceiling  → the max object label the token authorizes (per-op floor still applies)
  T.op_set         → the actions the token authorizes
  T.exp            → AvcEntry.valid_until  (ttl-bounded cache lifetime)

Verifying the token signature is a bind/refresh-time event (design §7: mint per-task, AVC caches for ttl), NOT per op. Once seeded, per-op decisions are local lookups. The token’s {label_ceiling, op_set} are an additional deny-only gate the PEP applies via TokenScope; the mandatory lattice floor + TE matrix are still evaluated independently by the PDP (a token can only narrow — design §10).

Structs§

AvcKey
Cache key: the fully-resolved, interned per-op context. All Copy ids → cheap hash. Tagged with generation so a policy reload (new generation) misses every stale entry without an explicit flush walk.
CachingAvc
Concrete AVC over a TeEvaluator PDP and a concurrent map. Lock-free reads via dashmap; the only work on a hit is a hash + ttl compare.
TokenScope
The token-derived gate the PEP applies on top of the PDP decision (design §10 / §6). Deny-only: the token can only narrow. The PDP (lattice floor + TE matrix) is evaluated independently; this just enforces what the access token authorized.

Traits§

Avc
The Access Vector Cache interface — what the PEP (S2) calls per op.