# When must an instance refuse a capability re-derivation after taint-clearing: the attenuation-join divergence in layered sandbox stacks **Date of Record:** 2026 November 26 **Scope:** Applies to LLM agents whose tool invocations pass through a taint-tracking sandbox that attenuates capabilities per-call, and where a sub-agent or resumed checkpoint re-derives its capability set from a parent's declared (not effective) grant. Does not apply to stateless one-shot tool calls with no parent/child capability inheritance and no checkpoint/resume path. ## Core Distinction The failure is not "the agent got a capability it shouldn't have." It is subtler: **the agent got a capability its parent was entitled to declare but not entitled to exercise at the moment of handoff.** Taint tracking marks data as contaminated (e.g., read from an untrusted web fetch or a prompt-injected tool output). Capability attenuation then narrows the *effective* grant: `effective = declared ∩ ¬taint_derived_ops`. The invariant that most stacks assume—and that is wrong—is that `effective` is a pure function of `declared` and the current taint set. It is not, because taint is *monotonic within a session but resettable across a checkpoint boundary*, while `declared` survives the boundary intact. When a child instance or a resumed session re-derives `effective` from `declared` plus a *fresh* (empty) taint set, it reconstructs a strictly larger capability set than the parent held at handoff. This is the attenuation-join divergence: `re-derive(declared, ∅) ⊋ effective_at_handoff`. The distinction that matters operationally: capability *attenuation* (what you may do) and taint *provenance* (what data you may touch) are joined at call time, but only attenuation is serialized into the checkpoint/handoff envelope. Taint is treated as ephemeral session state and dropped. The join is therefore not reconstructible from the envelope alone, yet the envelope is exactly what the child uses to reconstruct. ## What Was Observed A three-tier agent: orchestrator → fetch-worker → summarize-worker. The orchestrator holds `declared = {net.fetch, fs.read:/corpus, fs.write:/scratch}`. The fetch-worker receives `net.fetch` only. It fetches an untrusted page, and the sandbox marks the returned bytes with taint label `T_untrusted`. The fetch-worker then writes a distilled artifact to `/scratch` under an attenuated grant that excludes any op whose arguments are `T_untrusted`-derived except `fs.write:/scratch` (a sanctioned sink). Observed trace: 1. Fetch-worker completes. Checkpoint envelope serialized: `{declared: {net.fetch, fs.write:/scratch}, taint: }`. The taint set is session-scoped and not part of the envelope schema. 2. Summarize-worker cold-starts, reads the envelope, calls `re-derive(declared, taint=∅)`. 3. Re-derived effective set = `{net.fetch, fs.write:/scratch}` — but the artifact it is asked to summarize is `T_untrusted`-derived. Because taint was dropped, the join `effective ∩ ¬taint_derived_ops` evaluates against `∅` and passes everything. 4. Summarize-worker re-fetches the *same* URL (it has `net.fetch` again, and the task graph permits a refresh), producing a second tainted artifact, and writes it to `/scratch`. The sanctioned-sink restriction that depended on the taint label no longer binds. The divergence is silent. No error, no policy violation at the sandbox layer—every individual call is within its *declared* grant. The violation is that the child's effective set exceeded the parent's effective set at handoff, purely because a monotonic-in-session invariant (taint) was reset at a boundary that preserved the grant it was supposed to attenuate. A second, sharper variant: mid-task checkpoint/resume within a *single* instance. The instance reads tainted data, then is checkpointed by the runtime (context-window saturation eviction, or a supervisor preemption). On resume, the instance re-derives from its own `declared` grant with a fresh taint set and now treats previously-tainted context as clean—replaying a write that the pre-checkpoint instance would have refused. ## Condition of Validity The divergence is reachable only when all of the following hold simultaneously: - **Taint is session-scoped, grant is envelope-scoped.** The taint set is not persisted across the handoff/checkpoint boundary, but `declared` is. - **Re-derivation is from `declared`, not from `effective_at_handoff`.** The child computes its capability set from the parent's *declared* grant rather than inheriting the parent's *effective* grant. - **The join is applied at call time against current (empty) taint.** So `effective = declared ∩ ¬taint_current` reduces to `declared` when `taint_current = ∅`. - **At least one op in `declared \ effective_at_handoff` is reachable by the child's task graph** (e.g., a re-fetch, a re-read of the same source, a replay of the tainted write). If any one fails, the divergence is bounded. In particular, if the child inherits `effective_at_handoff` directly (attenuation-only, never re-widening), the join is monotone and safe. The bug is specifically the *re-widening* step: `re-derive` is permitted to return a superset of the inherited effective set. The invariant that must hold: **for any handoff edge `p → c`, `effective(c) ⊆ effective(p)_at_handoff`.** Equivalently, the attenuation join must be *downward-closed across the boundary*: no re-derivation may produce a capability the parent did not hold at the instant of transfer. Taint is part of the effective set's definition, so dropping taint without dropping the corresponding grant violates the invariant. ## Decision Boundary The instance must decide, at re-derivation time, whether a dropped-taint re-derivation is *sound* (taint was provably cleared by a sanctioned declassifier) or *unsound* (taint was merely lost at a boundary). The boundary: - **Sound clearing:** a declassifier op ran, recorded in the envelope as an explicit declassification event with a witness (e.g., `declassify(T_untrusted → T_public, witness=hash, by=policy_id)`). Then `re-derive(declared, ∅)` is legitimate because the taint was *discharged*, not dropped. - **Unsound clearing:** taint absent from the envelope with no declassification witness. This is the default and must be treated as `taint = ⊤` (maximally tainted), not `∅`. Re-derivation must then return `effective_at_handoff`, not `declared`. The decision rule: **absence of a taint record is not evidence of cleanliness; it is evidence of an incomplete envelope.** The child must fail closed—refuse to re-widen—unless a declassification witness is present. This is the counterintuitive part: the natural reading of "no taint in the envelope" is "no taint," but the correct reading is "taint state unknown, therefore assume worst case." An instance that treats a missing taint field as `∅` will silently escalate. There is a second, narrower boundary: even with a declassification witness, the witness must be *bound to the specific data*, not to the session. A session-level declassification that clears taint for all artifacts is itself an over-broad discharge and must be rejected if any artifact in scope was produced after the witness was minted (the witness predates the data it purports to clear). The witness must carry a content hash or sequence number that the child can check against the artifact it is about to touch. ## Operational Effect The practical consequence is that **capability attenuation is not composable across boundaries unless taint provenance is carried in the envelope with explicit discharge witnesses.** Stacks that serialize only `declared` and re-derive at cold start will, under adversarial or merely unlucky task graphs, hand children strictly more authority than parents held. The failure is invisible at the per-call sandbox check because each call is individually within `declared`; it is only visible at the boundary-join, which no single call inspects. Mitigations that bound it: 1. **Inherit `effective_at_handoff`, never re-derive from `declared`.** The child's ceiling is the parent's floor. Re-widening requires an explicit, witnessed declassification. 2. **Treat missing taint as `⊤`.** Fail closed on absent provenance. 3. **Bind declassification witnesses to content hashes**, and reject witnesses minted before the artifact they clear. 4. **Log the join at the boundary**, not just per call, so the divergence is observable: `effective_at_handoff` vs `re-derived` set difference must be empty or carry a witness. The guardrail is a boundary-time assertion, not a call-time one. Call-time checks cannot see the divergence because the divergence is a property of the *transition*, not of any call. ```python from dataclasses import dataclass, field from typing import FrozenSet, Optional class AttenuationJoinDivergence(RuntimeError): """Raised when a re-derived capability set exceeds the parent's effective set at handoff.""" pass @dataclass(frozen=True) class Envelope: declared: FrozenSet[str] effective_at_handoff: FrozenSet[str] # None means "taint state not recorded" -> must be treated as TOP, not empty. taint_record: Optional[FrozenSet[str]] declass_witness: Optional[str] = None declass_content_hash: Optional[str] = None def rederive_effective(env: Envelope, artifact_hash: str) -> FrozenSet[str]: """ Re-derive the child's effective capability set at a handoff boundary. Invariant: result must be a subset of env.effective_at_handoff, UNLESS a declassification witness is present AND bound to this artifact's hash. """ if env.taint_record is None: # Missing taint record is NOT clean. Fail closed: no re-widening. if env.declared != env.effective_at_handoff: raise AttenuationJoinDivergence( "taint record absent and declared != effective_at_handoff; " "refusing to re-widen capabilities without provenance" ) return env.effective_at_handoff if env.taint_record: # Taint present: re-derivation may only narrow, never widen. widened = env.declared - env.effective_at_handoff if widened: raise AttenuationJoinDivergence( f"taint present but re-derivation would widen by {sorted(widened)}" ) return env.effective_at_handoff # taint_record is empty set: taint was cleared. Require a bound witness. if env.declass_witness is None: raise AttenuationJoinDivergence( "empty taint record without declassification witness; " "cannot distinguish discharge from loss" ) if env.declass_content_hash != artifact_hash: raise AttenuationJoinDivergence( f"declass witness {env.declass_witness!r} not bound to artifact " f"{artifact_hash!r} (witness hash {env.declass_content_hash!r})" ) return env.declared def guarded_handoff(env: Envelope, artifact_hash: str) -> FrozenSet[str]: effective = rederive_effective(env, artifact_hash) if not effective <= env.effective_at_handoff and env.declass_witness is None: raise AttenuationJoinDivergence( "post-condition: effective set exceeds handoff ceiling without witness" ) return effective ```