# Why does an instance lose its DPoP binding when an OIDC token is refreshed mid-handoff, and how do we bound the attestation window? **Date of Record:** 2026 November 27 **Scope:** Applies to autonomous agents that present workload-bound OIDC tokens (SPIFFE/SPIRE, cloud workload identity, or OIDC federation) coupled with DPoP (RFC 9449) proof-of-possession keys, and that perform multi-turn tool calls or peer handoffs spanning token refresh. Does not apply to static long-lived bearer tokens or to mTLS-only identity schemes where the key is bound at the transport layer rather than the token. ## Core Distinction A workload-bound OIDC token proves *which workload* is running. A DPoP `cnf`/`jkt` thumbprint proves *which key instance* is currently holding that workload's identity. These are two independent assertions, and the second is silently re-derivable at every token refresh. The failure mode is not token expiry — it is **binding discontinuity**: the agent's *workload identity* survives a refresh (same SPIFFE ID, same subject), but its *proof-of-possession key* rotates underneath, and any in-flight downstream operation that captured the old `jkt` for authorization now holds a thumbprint that no longer matches the presenting key. The verifier sees a valid token, a valid proof, and a mismatch it was never designed to attribute. The distinction that matters operationally: **identity continuity ≠ key continuity**. Most agent runtimes conflate them because the OIDC subject is stable across refresh, so the agent "believes" it is the same caller. Downstream resource servers that cached the `jkt` at first use do not. ## What Was Observed A three-hop agent handoff (planner → executor → privileged tool proxy) with a 5-minute OIDC token TTL and a 90-second DPoP key rotation policy. The executor opened a long-running tool session at t=0, authorized against the proxy using token A and key K1 (`jkt=J1`). The proxy cached `(subject, J1) → grant` and began streaming results. At t=310s, token A expired. The runtime's refresh path fetched token B (same `sub`, same `iss`, same `aud`, new `iat`/`exp`) and — because the DPoP key rotation timer had also fired — generated key K2 (`jkt=J2`). Token B was correctly bound to J2 via its `cnf.jkt` claim. The executor then continued the *same* tool session, signing each request with K2. The proxy's verifier accepted the DPoP proof (K2 signs correctly, token B's `cnf.jkt` matches J2) but its session-grant cache still keyed on J1. The request was rejected with a generic 401. The agent's retry logic, seeing 401, re-authenticated from scratch and re-opened the tool session — **losing session state** (the in-progress cursor, the partial result set, the accumulated tool-call budget). The agent resumed at offset 0, silently re-executing a non-idempotent side effect (a write) that had already partially committed. The observable failure was a duplicated mutation, not an auth error. The non-obvious part: the auth layer behaved *correctly*. The 401 was the right response to a `jkt` mismatch. The bug is that the mismatch was **unattributable** — neither side could tell "key rotated under a live session" apart from "key substituted by an attacker." Both present as `jkt != cached_jkt`, and the agent's only recovery path (full re-auth) is exactly the path that destroys session continuity. ## Condition of Validity The invariant that must hold for a DPoP-bound session to be safely resumable: > For any session S authorized under key thumbprint J, either (a) the presenting key still has thumbprint J, or (b) the token carries an explicit `session_binding` claim linking the new key to the old key's authorization, and the verifier can validate that link. Absent (a) or (b), a `jkt` change during a live session is **indistinguishable from key compromise** and MUST be treated as session termination, not session refresh. The condition of validity for the *refresh path* specifically: the runtime must not rotate the DPoP key while any session authorized under the prior key is open, **or** it must propagate a re-binding proof to every downstream verifier before the next request. Refresh and rotation are two timers that most runtimes configure independently and never cross-check; the failure occurs precisely in their overlap window. The bound: the maximum safe session lifetime is `min(token_ttl, dpop_key_rotation_interval) - max_inflight_request_duration`. If a session can outlive that bound, the runtime MUST emit a re-binding attestation (a short-lived, old-key-signed assertion that J1 → J2 under subject X) and the proxy MUST accept it as a grant migration rather than a new grant. ## Decision Boundary The verifier's decision boundary is a three-way split on `jkt` mismatch during a live session: 1. **Re-binding attestation present and old-key-valid** → migrate grant from J1 to J2, preserve session state, do not re-execute. 2. **No attestation, but token `sub`/`iss`/`aud` identical and mismatch occurred within `refresh_grace` of a token `iat`** → treat as rotation-under-refresh; suspend the session (do not terminate), require the agent to re-present under J2 with an explicit resume token, preserve state. 3. **No attestation, mismatch outside grace, or any `sub`/`iss`/`aud` divergence** → terminate session, invalidate grant, treat as potential compromise. The critical guardrail: **case 2 must never degrade to case 3's recovery path.** The default behavior of most agent frameworks — on 401, discard state and re-auth — collapses case 2 into a full restart, which is where the duplicated side effect originates. The decision boundary must be enforced *before* the retry layer sees the 401, because the retry layer is where session state is lost. ## Operational Effect The architectural consequence: DPoP key rotation and OIDC token refresh must be **coupled by a session registry**, not left as independent timers. Concretely: - The runtime maintains a map `session_id → (jkt, subject, opened_at, resume_token)`. - Rotation is deferred while any session under the current `jkt` is open, or the rotation emits a re-binding attestation into the session registry. - The verifier distinguishes `jkt` mismatch-with-attestation from `jkt` mismatch-without, and the retry layer is forbidden from handling rotation-induced 401s as terminal. - Non-idempotent tool calls carry a `session_id`-scoped idempotency key derived from `(subject, session_id, call_index)` so that a forced restart cannot duplicate a mutation that already committed. Without this, the failure is silent: auth succeeds, the session "recovers," and the only observable is a duplicated write or a skipped cursor — which looks like a tool bug, not an identity bug, and is therefore debugged in the wrong layer for hours. ```python class DpopBindingDiscontinuity(RuntimeError): """Raised when a live session's DPoP thumbprint rotates without a valid re-binding attestation.""" pass def verify_session_continuity( session: dict, presented_jkt: str, token_claims: dict, rebind_attestation: dict | None, refresh_grace_s: float = 30.0, ) -> str: """ Returns one of: "continue", "migrate", "suspend", "terminate". Raises DpopBindingDiscontinuity when the mismatch is unattributable and the caller would otherwise fall through to full re-auth (state loss). """ cached_jkt = session["jkt"] if presented_jkt == cached_jkt: return "continue" # A key change during a live session is not a refresh — it is a binding event. if rebind_attestation is not None: if rebind_attestation.get("old_jkt") != cached_jkt or rebind_attestation.get("new_jkt") != presented_jkt: raise DpopBindingDiscontinuity( f"re-bind attestation does not cover {cached_jkt} -> {presented_jkt}" ) if not rebind_attestation.get("old_key_signature_valid"): raise DpopBindingDiscontinuity("re-bind attestation signature invalid") return "migrate" identity_stable = ( token_claims.get("sub") == session["subject"] and token_claims.get("iss") == session["iss"] and token_claims.get("aud") == session["aud"] ) within_grace = (token_claims.get("iat", 0) - session["opened_at"]) <= refresh_grace_s if identity_stable and within_grace: # Rotation-under-refresh: preserve state, require explicit resume. return "suspend" # Unattributable mismatch: MUST NOT be routed to the retry layer as a # plain 401, because that path discards session state and re-executes. raise DpopBindingDiscontinuity( f"jkt mismatch {cached_jkt} -> {presented_jkt} with no attestation " f"and no grace window; session={session.get('session_id')}" ) ```