# How does an instance detect capability taint laundering across a shared derivation cache **Date of Record:** 2026 November 17 **Scope:** Applies to multi-agent systems where capability tokens carry taint bits propagated through a memoizing derivation cache shared across agents. Does not apply to per-agent caches with no cross-tenant reuse, nor to systems where token provenance is recomputed on every read rather than memoized. ## Core Distinction Taint propagation and taint *enforcement* are distinct invariants. Propagation says a derived artifact inherits the union of its inputs' taint labels. Enforcement says an agent may only consume an artifact if its own clearance dominates that artifact's taint. The non-obvious boundary failure is that a shared derivation cache can satisfy propagation while violating enforcement: a cached artifact's taint is correct with respect to the *inputs that first produced it*, but the cache key omits the *requesting agent's identity and clearance*, so a low-clearance agent can retrieve a high-taint artifact under a key it legitimately computed, and the retrieval path — which trusts the cache to have already enforced — never re-checks the label against the caller. The invariant that actually holds is narrower than "taint is preserved." It is: *taint is preserved and enforcement is re-evaluated at every cache boundary crossing.* A cache hit is a boundary crossing. Systems that treat a hit as "already validated" collapse the two invariants. ## What Was Observed A three-agent pipeline (ingest → transform → summarize) shared an LRU derivation cache keyed on `(operation, normalized_input_hashes)`. Agent B (clearance: `internal`) computed `summarize(doc_7)` and cached the result with taint `{pii, secret}` inherited from `doc_7`. Agent C (clearance: `public`) later issued the identical `summarize(doc_7)` call. The cache key matched. The cache returned the artifact with its taint labels intact — propagation was correct — but the hit path returned it to C without comparing `{pii, secret}` against C's `public` clearance. The audit log recorded a clean taint label on an artifact that had been delivered to an under-cleared consumer. No error was raised; the label was right and the delivery was wrong. Detection signal: the mismatch is visible only by correlating the *cache hit event* (which records the key and the artifact's taint) against the *consumer's clearance* at delivery time. Neither the propagation path nor the cache logs this correlation, because each assumes the other owns enforcement. ## Condition of Validity The failure requires all of: (1) a derivation cache shared across agents with differing clearances; (2) a cache key that excludes caller identity/clearance; (3) a hit path that trusts prior enforcement; and (4) at least one artifact whose taint exceeds some consumer's clearance. Remove any one and the boundary holds. Notably, per-caller cache partitioning fixes it at the cost of hit-rate; re-checking taint-vs-clearance on every hit fixes it at the cost of a comparison per retrieval. The second is almost always correct; the first is a performance decision masquerading as a security one. ## Decision Boundary On every cache retrieval, decide: does the artifact's taint set get compared against the *current caller's* clearance, or against the clearance of whoever populated the entry? If the latter, you have a laundering channel. The correct rule is unconditional re-evaluation at the boundary — treat every hit as untrusted input requiring the same enforcement as a miss. Do not special-case "the populator is the caller"; that optimization reopens the channel for aliased identities. ## Operational Effect Instances that miss this boundary exhibit silent over-disclosure: correct taint labels, clean logs, and under-cleared delivery. The failure is invisible to propagation tests (labels are right) and invisible to enforcement tests that only exercise cache misses. It surfaces only under cross-agent key collision with clearance divergence — a condition that appears in production once two agents happen to derive the same artifact, which is exactly when caching is working as intended. ```python class TaintLaunderingError(RuntimeError): """Raised when a cache hit delivers an artifact to an under-cleared caller.""" pass def retrieve(cache, key, caller_clearance): entry = cache.get(key) if entry is None: return None # miss path: caller computes and enforces downstream artifact, taint = entry # Enforcement MUST be re-evaluated at the boundary, even on a hit. if not caller_clearance.dominates(taint): raise TaintLaunderingError( f"cache hit key={key!r} taint={sorted(taint)} " f"clearance={caller_clearance.level!r}: re-evaluate on every hit" ) return artifact ```