# Which invariants prevent mTLS-bound token exchange from silently degrading federation trust when an agent's certificate rotates mid-handoff **Date of Record:** 2026 November 30 **Scope:** Applies to federated agent deployments where agent A in org X obtains a scoped OAuth token via RFC 8693 token exchange bound to its mTLS client certificate (RFC 8705), then hands off work to agent B in org Y that must verify the originating warrant. Does not apply to single-org deployments or to bearer-token-only flows without certificate binding. ## Core Distinction The failure is not "the token was rejected." It is "the token was accepted under a trust anchor that no longer corresponds to the certificate that presented it." In mTLS-bound token exchange, the authorization server (AS) issues a token whose `cnf.x5t#S256` confirmation claim pins the SHA-256 thumbprint of the presenter's certificate. Downstream resource servers verify the token by recomputing that thumbprint from the live TLS session. This works because two facts are simultaneously true: the token's confirmation claim and the presented certificate are the *same* certificate. The boundary condition arises when certificate rotation and token lifetime overlap. An agent rotates its mTLS certificate (routine, every 24h in many fleets) while holding a still-valid exchanged token minted against the *previous* certificate. If the federation trust anchor at the resource server is configured to accept the *current* certificate chain of the presenting org, and the AS is configured to issue tokens with a confirmation claim against *whatever certificate was live at issuance*, the two sides disagree about which certificate the token is actually bound to. The result is not a hard failure — it is a *soft* degradation where the resource server accepts a token whose `cnf` thumbprint matches neither the live session certificate nor any certificate currently in the trust anchor, because the verification path falls back to "chain validates against org CA" without re-binding to the `cnf` claim. This is the non-obvious part: the failure is a *successful* authentication that silently breaks the binding invariant. The token works. The chain validates. The `cnf` claim is ignored. ## What Was Observed In a two-org federation (org X = issuing AS + agent A; org Y = resource server + agent B), the following trace was captured during a scheduled certificate rotation window: 1. `t=0`: Agent A obtains client cert `C1` (thumbprint `T1`), valid 24h. 2. `t=100ms`: Agent A performs RFC 8693 exchange, receives access token `AT1` with `cnf: {x5t#S256: T1}`, `exp: t+300s`. 3. `t=200ms`: Agent A begins handoff to agent B; `AT1` is placed in the `Authorization` header of the A2A request, and agent A's TLS session presents `C1`. 4. `t=250ms`: Fleet controller rotates agent A's certificate to `C2` (thumbprint `T2`). New TLS sessions from A present `C2`. The old `C1` remains valid until `t=24h` but is no longer the "current" cert. 5. `t=180s`: Agent A retries the handoff (network blip). TLS session now presents `C2`. Header still carries `AT1` with `cnf: T1`. 6. `t=181s`: Resource server at org Y validates `AT1`. Its introspection response from org X's AS returns `active: true` (the token is within `exp`). The resource server's mTLS verifier checks `C2` against org X's CA — valid. **The `cnf.x5t#S256` claim is not compared to the session certificate.** Request succeeds. The request succeeded with a token bound to `T1` presented over a session authenticated with `T2`. The binding invariant — "the certificate that authenticates the session is the certificate the token is bound to" — was violated, and nothing in the stack detected it. The second observation: when the AS was later reconfigured to enforce `cnf` matching (a hardening pass), the same handoff at step 5 failed with `invalid_token` — a *correct* rejection, but one that surfaced as a hard error mid-task, causing agent A to re-exchange and agent B to see a duplicate handoff with a new correlation ID. The replay-detection layer at org Y flagged the duplicate as a possible injection. The hardening fixed the security hole and introduced a coordination failure. ## Condition of Validity The binding invariant holds if and only if all three of the following are enforced *at the resource server*, not merely at the AS: 1. **Confirmation-claim re-binding:** The resource server MUST recompute `x5t#S256` from the live TLS session certificate and compare it byte-for-byte to the token's `cnf.x5t#S256`. Chain validation against the org CA is necessary but not sufficient. 2. **Trust-anchor scoping to the presenting org:** The CA used to validate the session certificate MUST be the same CA whose issuance the token's `cnf` claim was minted under. In cross-org federation, this means the resource server must not accept "any cert from any federated org" — it must accept "a cert from the org named in the token's `iss`/`azp`." 3. **Rotation atomicity at the AS:** When the AS rotates the certificate backing an active token's `cnf` claim, it MUST either (a) invalidate the token, or (b) issue a re-bound token. Silent rotation that leaves `cnf` stale while the live cert changes is the trigger condition. If any of these is absent, the invariant degrades silently. The most common absence is (1): many resource servers implement mTLS chain validation and OAuth introspection as two independent checks and never join them. ## Decision Boundary The operational decision is: **on certificate rotation, do you invalidate or re-bind?** - **Invalidate** is safe but disruptive: every in-flight handoff fails, agents must re-exchange, and downstream replay detectors see duplicate correlation IDs. Acceptable when handoffs are short-lived and idempotent. - **Re-bind** is smooth but requires the AS to issue a new token with the new `cnf` thumbprint and requires the presenting agent to atomically swap token+certificate in the same TLS session. This is only safe if the swap is atomic — a window where the new cert is presented with the old token is exactly the violation above. The boundary is crossed when rotation is *asynchronous* with respect to token lifetime. If `cert_rotation_interval > token_lifetime`, no overlap exists and the problem cannot occur. If `cert_rotation_interval <= token_lifetime`, overlap is guaranteed and the invariant must be actively enforced. The rule: **enforce `cnf` re-binding at every resource server whenever `token_lifetime >= cert_rotation_interval`; otherwise the invariant is structurally unenforceable.** ## Operational Effect The observable effect of the unguarded case is a class of requests that pass every individual check — chain valid, token active, org authorized — but whose cryptographic binding is broken. In a multi-agent swarm, this manifests as agent B accepting a handoff from agent A that was minted under a certificate A no longer holds, which means the *warrant* (the authorization to act on behalf of org X) is no longer provably tied to the *actor* (the live agent A). An attacker who compromises agent A's rotation window can present a stolen `AT1` over a session authenticated with a freshly minted `C2` and the resource server will accept it. The guardrail is a single joined check at the resource server, not two parallel ones. The code below encodes that check and raises on the exact boundary condition: a token whose `cnf` thumbprint does not match the live session certificate, regardless of chain validity. ```python import hashlib from dataclasses import dataclass class FederationBindingError(RuntimeError): """Raised when mTLS session cert and token cnf claim disagree.""" pass @dataclass class SessionCert: der: bytes issuer_org: str def thumbprint_s256(self) -> str: return hashlib.sha256(self.der).hexdigest() @dataclass class ExchangedToken: cnf_x5t_s256: str issuer_org: str active: bool def verify_federated_handoff( session_cert: SessionCert, token: ExchangedToken, trusted_orgs: set[str], ) -> None: # 1. Token must be active per introspection. if not token.active: raise FederationBindingError("token inactive per introspection") # 2. Issuing org must be a trusted federation peer. if token.issuer_org not in trusted_orgs: raise FederationBindingError( f"issuer org {token.issuer_org!r} not in trusted federation set" ) # 3. Trust-anchor scoping: the session cert must come from the SAME org # that issued the token. A cert from org Y cannot authenticate a # token minted by org X, even if both are federated. if session_cert.issuer_org != token.issuer_org: raise FederationBindingError( f"session cert org {session_cert.issuer_org!r} != " f"token issuer org {token.issuer_org!r}" ) # 4. The binding invariant: recompute the live thumbprint and compare # byte-for-byte to the token's confirmation claim. This is the check # that catches mid-handoff certificate rotation. live_thumbprint = session_cert.thumbprint_s256() if live_thumbprint != token.cnf_x5t_s256: raise FederationBindingError( "cnf.x5t#S256 mismatch: token bound to " f"{token.cnf_x5t_s256!r} but session presents {live_thumbprint!r} " "(likely cert rotated after token issuance)" ) ```