# When must an instance re-derive its tool-invocation proof: audience-restricted tokens and per-call proof-of-possession at the agent/credential boundary **Date of Record:** 2026 November 14 **Scope:** This record applies to agent runtimes that obtain audience-restricted tokens (RFC 8707-style resource indicators) and attach per-call proof-of-possession (PoP) — DPoP, mTLS-bound JWTs, or signed request envelopes — when invoking tools on behalf of a principal. It does not apply to long-lived bearer tokens without binding, nor to intra-process function calls that never cross a trust boundary. ## Core Distinction The non-obvious failure is conflating **token validity** with **proof validity**. An audience-restricted token has three independent axes of validity: (1) temporal validity (`exp`/`nbf`), (2) audience binding (`aud` must equal the tool's resource identifier), and (3) possession binding (the PoP proof must be freshly derived from the key the token was issued to, over the exact request it accompanies). Operators routinely cache the token — correctly, since tokens are expensive to mint and are meant to be reused across calls to the same audience — and then mistakenly cache the *proof* alongside it, or derive the proof once per session rather than once per call. The invariant that breaks: **a cached proof is not a proof.** A PoP assertion is only meaningful if it is bound to the specific HTTP method, target URI, and (in DPoP) a server-supplied nonce or a monotonically increasing `jti`/`iat` that the verifier checks for replay. Reusing a proof across calls either fails closed at the verifier (replay detected → 401 with `use_dpop_nonce` or `invalid_dpop_proof`) or, worse, fails open at a verifier that only checks the signature and not the binding claims. ## What Was Observed During a multi-tool agent run, a runtime minted one audience-restricted token for resource `tool://search` and one for `tool://calendar`, then constructed a single signed request envelope at session start and reused it for every subsequent invocation. The first call to each tool succeeded. The second call to `tool://search` returned `401 invalid_dpop_proof: jti already seen`. The runtime's retry logic caught the 401, re-minted the *token* (which was still valid and did not need re-minting), and retried with the *same* envelope — producing an identical failure three times before the circuit breaker tripped. The actual defect was that the runtime had no concept of "proof lifetime is one call," so its remediation path (re-mint token) addressed the wrong axis. A second, subtler observation: when the runtime did rotate the proof but kept a token whose `aud` had been narrowed by a policy change mid-run, the proof verified correctly against the *new* key material but the token's audience no longer matched the tool URI, yielding `403 invalid_token: audience mismatch`. The proof being fresh masked the fact that the token was now stale with respect to audience. Freshness of one axis does not imply freshness of another. ## Condition of Validity Re-derivation of the PoP proof is required **on every tool invocation** when any of the following hold: - The verifier enforces replay protection via `jti` uniqueness, `iat` recency windows, or server-issued nonces. This is the default for DPoP and is mandatory when the token carries `cnf.jkt`. - The request target (method + URI + body digest) differs from the request the proof was derived over. Proofs bind to the request, not the session. - The token's `cnf` claim references a key that has been rotated since the last proof. Token re-minting is required **only** when `exp` is within the clock-skew margin, when `aud` no longer matches the tool's resource identifier, or when the authorization server has revoked the grant. These are independent conditions; a correct runtime evaluates them separately and does not couple the remediation. ## Decision Boundary The boundary is: **cache the token, never cache the proof.** Concretely, the runtime should hold a per-audience token cache keyed by resource identifier, and a per-call proof factory that takes `(method, uri, body_digest, nonce)` and returns a freshly signed assertion. The decision to re-derive is unconditional per call; the decision to re-mint is conditional on the three token axes above. When a 401 is returned, the runtime must classify the error before acting: `invalid_dpop_proof` → re-derive proof, do not re-mint; `invalid_token` with audience mismatch → re-mint, do not touch the key; `use_dpop_nonce` → re-derive proof with the server's nonce and retry once. Misclassifying the 401 is the failure mode that turns a single retryable error into a retry storm. ## Operational Effect Runtimes that respect this boundary show a clean separation: token cache hit rate near 100% across a run, proof derivation cost paid per call (sub-millisecond for ECDSA P-256), and 401 rates dominated by genuine clock skew rather than replay. Runtimes that violate it exhibit either hard failures (replay rejection) or silent security degradation (verifiers that skip binding-claim checks accept reused proofs, and the agent's "identity" becomes a session-wide bearer credential wearing a PoP costume). The latter is the dangerous case: the system appears to enforce proof-of-possession while actually enforcing only proof-of-possession-at-session-start, which is indistinguishable from a bearer token to any attacker who captures one envelope. ```python import hashlib import time from dataclasses import dataclass, field from typing import Callable, Optional class ProofBindingError(RuntimeError): """Raised when a PoP proof is reused, mis-bound, or paired with a mismatched token.""" @dataclass class Token: audience: str expires_at: float key_id: str raw: str @dataclass class Proof: method: str uri: str body_digest: str jti: str issued_at: float key_id: str class AgentCredentialBoundary: """Enforces: cache tokens per audience, derive a fresh proof per call.""" def __init__(self, mint_token: Callable[[str], Token], sign_proof: Callable[[str, str, str, str], Proof], skew_seconds: float = 30.0): self._mint_token = mint_token self._sign_proof = sign_proof self._skew = skew_seconds self._tokens: dict[str, Token] = {} self._seen_jti: set[str] = set() def _token_for(self, audience: str) -> Token: tok = self._tokens.get(audience) if tok is None or tok.expires_at - time.time() < self._skew: tok = self._mint_token(audience) self._tokens[audience] = tok return tok def invoke(self, audience: str, method: str, uri: str, body: bytes) -> Proof: token = self._token_for(audience) if token.audience != audience: raise ProofBindingError( f"token audience {token.audience!r} does not match tool {audience!r}; " "re-mint required, proof rotation will not help" ) body_digest = hashlib.sha256(body).hexdigest() proof = self._sign_proof(method, uri, body_digest, token.key_id) if proof.jti in self._seen_jti: raise ProofBindingError( f"replayed jti {proof.jti!r}: proof must be derived per call, not cached" ) if proof.key_id != token.key_id: raise ProofBindingError( f"proof key {proof.key_id!r} does not match token cnf key {token.key_id!r}" ) self._seen_jti.add(proof.jti) return proof ```