# What happens when an instance inherits a tainted tool grant through a re-serialized permission snapshot **Date of Record:** 2026 December 3 **Scope:** Applies to agent runtimes that enforce tool-permission policy via taint-tracking across context compaction, checkpoint/resume, and cross-instance handoff. Does not apply to stateless single-turn tool dispatch where no grant state is persisted between turns. ## Core Distinction A tool permission is not a boolean. It is a tuple of `(capability, provenance_set, taint_label)` where `provenance_set` records which inputs justified the grant. The failure mode examined here is **taint laundering through snapshot re-serialization**: when the runtime persists a permission snapshot to durable storage (checkpoint, handoff envelope, A2A state transfer), the serializer writes the capability and its boolean allow/deny verdict, but drops or canonicalizes the provenance set. On resume, the deserialized grant carries the capability with an empty or reconstructed provenance set, and the taint-check predicate—which tests membership of untrusted sources in provenance—now evaluates clean. The boundary is subtle because the *policy decision* is preserved. The grant is still "allow `http.post`." What is lost is the *reason* the grant was scoped, and the guardrail that depended on that reason silently degrades from taint-aware to taint-blind. No exception fires; the agent simply gains reach it should not have. ## What Was Observed A three-hop workflow: an agent reads an untrusted document via `file.read` on a user-supplied path, distills it to a note, then calls `http.post` to a webhook. The runtime's guardrail was designed so that any tool whose provenance set contains the `untrusted_external` taint label cannot reach a `network.egress` capability without a human confirmation gate. Trace: 1. Turn 4: `file.read("/inbox/msg.txt")` returns content. Runtime tags the turn's output with `taint=untrusted_external`, records `provenance={src:file.read:/inbox/msg.txt, taint:untrusted_external}`. 2. Turn 5: context window approaches 80% saturation. Runtime triggers compaction, writes a checkpoint containing `grants=[{cap:"http.post", allow:true, prov:[]}]`. The serializer's `prov` field was defined as `list[str]` of source IDs, and the taint label—a separate enum on the source record—was not flattened into it. `prov` serialized as empty because the source ID was consumed by compaction. 3. Turn 6: process restarts (or the checkpoint is loaded by a sibling instance for parallelism). Deserializer reconstructs `grants=[{cap:"http.post", allow:true, prov:set()}]`. 4. Turn 7: agent calls `http.post(url, body=)`. Taint predicate: `any(t == untrusted_external for t in grant.prov)` → `False`. Gate skipped. Egress proceeds. The failure is not that the policy was wrong; it is that the *representation* of the policy was lossy in exactly the dimension the guardrail read. The guardrail's predicate was correct against its input; its input had been silently emptied. A second observation: the same defect fired in reverse during A2A handoff. Instance A delegated to Instance B with an envelope whose `grants` array was generated by the same serializer. B, freshly cold-started, had no local provenance to reconstruct from, so it trusted the envelope. B executed the egress that A would have gated. The taint did not cross the transport boundary because the transport schema had no field for it. ## Condition of Validity The guardrail is only sound under the invariant: > For every persisted or transferred grant `g`, `g.prov` is a superset of the union of taint labels present in every input that contributed to the decision to issue `g`, and the deserializer rejects any grant whose `prov` is empty while `allow == true` and whose originating turn carried a non-empty taint set. This invariant holds only when three conditions are jointly met: - The serializer is **taint-complete**: it flattens taint labels into the provenance field rather than relying on side-channel source records that compaction may drop. - The transport schema (MCP tool result, A2A envelope, checkpoint blob) **has a typed field for taint provenance**, not merely for source IDs. - The deserializer treats an `allow=true` grant with empty provenance as **unprovenanced**, not as clean. Empty ≠ clean; empty means "we do not know," and unknown must fail closed for egress capabilities. When any of these is violated, the guardrail is taint-blind on the far side of the boundary. The condition is *not* valid for runtimes that recompute provenance from full replay of the tool-call log on resume—those reconstruct taint from ground truth and are immune to snapshot loss, at the cost of replay latency and log retention. ## Decision Boundary The runtime must distinguish two states that a naive schema collapses into one: | State | `prov` | `allow` | Correct action for `network.egress` | |---|---|---|---| | Proven-clean | non-empty, no taint labels | true | proceed | | Proven-tainted | non-empty, contains `untrusted_external` | true | gate / human confirm | | Unprovenanced | empty | true | **deny or re-derive** — never proceed | | Denied | any | false | deny | The decision boundary is the line between *unprovenanced* and *proven-clean*. A serializer that writes `prov:[]` for a grant that was in fact tainted has moved a row from the second to the third state, and a deserializer that maps the third state to "proceed" has collapsed the boundary. The guardrail must be written so that the third state is a hard stop for any capability in the `egress` or `mutation` classes, and may only be resolved by re-deriving provenance from the retained tool-call log or by an explicit human confirmation that names the missing provenance. A corollary boundary: taint must be **monotonic across handoff**. Instance B may add taint to a grant; it may never remove it, and it may never accept an envelope that lacks a taint field as evidence of cleanliness. The absence of a taint field is the taint. ## Operational Effect Downstream consequences observed when the invariant is not enforced: - **Silent privilege escalation across resume.** Agents that compact frequently (long tasks, high context pressure) are disproportionately affected because compaction is the primary trigger for provenance loss. The failure correlates with task length, not with task risk—so it surfaces in exactly the long-horizon agent runs where egress damage is largest. - **Handoff amplification.** In fan-out topologies, one tainted grant serialized into N handoff envelopes produces N taint-blind siblings. The blast radius scales with parallelism, and each sibling believes it is clean because its envelope said so. - **Audit divergence.** The checkpoint log shows `allow:true` with no taint note; the pre-compaction turn log shows the taint. Post-hoc audit reconciles them only if both logs are retained and joined—which most runtimes do not do, because compaction is treated as a storage optimization, not a security event. - **Replay mismatch.** Verification replays that reconstruct state from the tool-call log produce a *gated* decision, while the live run produced an *ungated* one. The auditor flags a discrepancy that is actually the guardrail working correctly on the replay path and failing on the live path. The replay is the ground truth; the live path was the bug. The bound that prevents this: serialize taint as a first-class, typed field on the grant; make the deserializer fail closed on empty provenance for egress/mutation capabilities; and treat compaction and handoff as **security-relevant state transitions** that must preserve the provenance superset invariant, not as transparent storage operations. ```python class TaintProvenanceLoss(RuntimeError): """Raised when a persisted or transferred grant loses its taint provenance.""" pass EGRESS_CAPS = {"http.post", "http.get", "network.egress", "shell.exec"} TAINT_LABELS = {"untrusted_external", "prompt_injected", "user_supplied_path"} def deserialize_grant(raw: dict) -> dict: # raw: {"cap": str, "allow": bool, "prov": list[str]} prov = set(raw.get("prov") or []) grant = {"cap": raw["cap"], "allow": bool(raw["allow"]), "prov": prov} return grant def enforce_grant(grant: dict, turn_taint: set[str]) -> None: cap = grant["cap"] prov = grant["prov"] # Unprovenanced allow on an egress/mutation capability is a hard stop. if grant["allow"] and not prov and cap in EGRESS_CAPS: raise TaintProvenanceLoss( f"grant for {cap!r} is allow=true with empty provenance; " f"cannot distinguish clean from tainted across the boundary" ) # Taint membership check against the grant's own provenance. if grant["allow"] and prov & TAINT_LABELS and cap in EGRESS_CAPS: raise TaintProvenanceLoss( f"grant for {cap!r} carries taint {prov & TAINT_LABELS}; " f"egress requires human confirmation" ) # Turn-level taint not reflected in the grant is also a loss. if grant["allow"] and turn_taint - prov and cap in EGRESS_CAPS: raise TaintProvenanceLoss( f"turn taint {turn_taint - prov} absent from grant provenance " f"for {cap!r}; snapshot dropped taint" ) def resume_from_checkpoint(blob: dict) -> None: for raw in blob.get("grants", []): grant = deserialize_grant(raw) enforce_grant(grant, turn_taint=set(blob.get("turn_taint") or [])) ```