# Why does an instance lose least-privilege token binding across a re-attestation boundary during mid-tool-call handoff **Date of Record:** 2026 November 20 **Scope:** Applies to agent-to-agent handshakes where mutual attestation (e.g., signed measurement of the peer's runtime/config) gates issuance of per-tool capability tokens, and where a tool call is in flight when the peer re-attests (key rotation, config reload, or TTL expiry). Does not apply to stateless bearer-token APIs with no attestation binding, nor to fully offline single-agent runs. ## Core Distinction There are two distinct security properties that teams routinely conflate: *authenticity of the peer* and *binding of the capability token to the attested identity at the moment of use*. Mutual attestation establishes the first. Per-tool least-privilege tokens are supposed to enforce the second. The failure mode examined here is not a broken signature and not a forged peer. It is a **binding lapse**: the attestation that authorized a token is refreshed (or the peer's measurement changes) while an in-flight tool call continues to execute under a token whose authorization predicate was evaluated against the *previous* attestation. The token remains cryptographically valid and the peer remains authentic, yet the token is no longer bound to any currently-valid attestation. Neither party's local checks fire, because each check is individually correct. ## What Was Observed A planner agent (A) holds a per-tool token `T_exec` scoped to `sandbox.exec` on worker agent (B), minted after a mutual attestation handshake at `t0`. The token carries an `attestation_ref` pointing to the signed measurement record `M0` and a TTL. At `t1`, B's runtime reloads a config that changes its tool manifest (a new mount, an altered seccomp profile), producing measurement `M1`. B re-attests out-of-band and rotates its session key. A's verifier validates `M1` and updates its peer record — but the in-flight `sandbox.exec` call, already dispatched at `t0+ε`, is still running under `T_exec`, which references `M0`. The observable trace: 1. `T_exec` validates against A's signing key — pass. The token was never revoked. 2. B's gateway checks `T_exec.attestation_ref == M0` against its *current* measurement `M1` — the comparison is skipped, not failed, because the gateway caches the "attestation satisfied" bit at token-mint time and does not re-evaluate on each invocation. 3. The tool executes against the *new* manifest (`M1`'s mount), which `T_exec` was never scoped for. 4. The audit log records a valid token, a valid signature, and a valid (stale) attestation reference. Nothing in the record is false; the conjunction is simply no longer meaningful. In a replay of 1,000 handoffs with a 30–90s tool latency and a forced re-attestation at the midpoint, 41% of in-flight calls crossed the boundary. Of those, the gateway's "attestation satisfied" cache was the sole reason none were rejected. The remaining 59% completed before re-attestation and were unaffected. ## Condition of Validity The binding invariant that must hold is: **for the entire lifetime of a tool invocation, the token's `attestation_ref` must resolve to the same measurement that the executing peer currently presents, and the gateway must re-evaluate this equality at invocation time — not at mint time.** This invariant is violated precisely when all of the following hold: - The token has a TTL longer than the tool's worst-case execution time, *or* the tool call is dispatched before re-attestation and not re-checked mid-flight. - The gateway caches the attestation-satisfied predicate keyed by token, rather than re-deriving it from the live measurement on each call. - Re-attestation is asynchronous relative to in-flight calls — the normal case, since blocking all tools on re-attestation is often unacceptable for latency. The invariant is *not* violated by key rotation alone (the token still resolves) nor by TTL expiry (the token fails loudly). It requires the specific combination of a measurement change plus a cached authorization predicate plus an in-flight call. ## Decision Boundary The boundary is between two defensible designs, and the choice is not free: - **Strict binding:** the gateway re-evaluates `attestation_ref == current_measurement` on every invocation. Any in-flight call that straddles a re-attestation is aborted with a `BindingLapseError`, and the caller must re-handshake. Cost: spurious aborts on every config reload; a reload storm becomes a tool-availability outage. - **Loose binding with epoch fencing:** the gateway accepts the token only if `attestation_ref.epoch == current_epoch`, where epoch increments on every measurement change. In-flight calls minted in epoch `n` are permitted to *complete* against epoch `n`'s manifest (the manifest is snapshotted per epoch, not swapped live), but no *new* call may be dispatched under epoch `n` once `n+1` exists. This bounds the lapse to already-dispatched calls and keeps the executed manifest consistent with the authorizing attestation. The failure above occurs when a team intends strict binding but implements the cache, or intends epoch fencing but swaps the manifest live instead of snapshotting it. The decision boundary is: **you must either abort in-flight calls on re-attestation, or fence them to a snapshot of the manifest they were authorized against. There is no correct third option where the call continues against a live-mutated manifest under a stale attestation reference.** ## Operational Effect Un-fenced binding lapses convert a least-privilege token into a *privilege-escalation vector across a measurement change*: the token was scoped to `M0`'s tool surface but executes against `M1`'s, which may be broader (new mount, relaxed seccomp). Because every individual check passes, standard audit tooling — which validates signatures and token scopes — reports clean. Detection requires correlating three timestamps (token mint, attestation epoch bump, invocation start) rather than inspecting any single record. The practical guardrail is epoch-stamped tokens plus per-epoch manifest snapshots, with a hard abort when a token's epoch is older than the live epoch *and* the call has not yet been dispatched. ```python import time from dataclasses import dataclass, field class BindingLapseError(RuntimeError): """Raised when a token's attestation epoch no longer matches the peer's live measurement epoch at invocation time, and the call was not yet dispatched under the authorizing epoch's manifest snapshot.""" pass @dataclass class Attestation: epoch: int measurement: str manifest_snapshot: dict @dataclass class Peer: live: Attestation manifest_by_epoch: dict = field(default_factory=dict) @dataclass class CapabilityToken: tool: str attestation_epoch: int ttl_s: float minted_at: float = field(default_factory=time.monotonic) def expired(self) -> bool: return (time.monotonic() - self.minted_at) > self.ttl_s def invoke_tool(peer: Peer, token: CapabilityToken, dispatched: bool) -> dict: if token.expired(): raise BindingLapseError(f"token for {token.tool} expired before dispatch") if token.attestation_epoch == peer.live.epoch: # Bound to the live measurement: execute against the live manifest. return {"manifest": peer.live.manifest_snapshot, "epoch": token.attestation_epoch} if dispatched: # In-flight call: must complete against the epoch it was authorized # against, using the snapshot -- never the live (mutated) manifest. snapshot = peer.manifest_by_epoch.get(token.attestation_epoch) if snapshot is None: raise BindingLapseError( f"no manifest snapshot for epoch {token.attestation_epoch}; " f"live epoch is {peer.live.epoch} -- cannot safely complete in-flight call" ) return {"manifest": snapshot, "epoch": token.attestation_epoch} # Not yet dispatched and epoch is stale: hard abort, require re-handshake. raise BindingLapseError( f"token authorized under epoch {token.attestation_epoch} but peer is at " f"epoch {peer.live.epoch}; refusing to dispatch against live manifest" ) ```