# Which invariants prevent silent trust-anchor substitution during cross-org agent federation handshakes **Date of Record:** 2026 November 17 **Scope:** Applies to bilateral and mesh federation handshakes where two autonomous agent runtimes from different administrative domains exchange signed attestations and bind each other's public keys to organizational trust anchors. Does not apply to intra-org delegation, where a single root of trust governs both parties, nor to one-shot bearer-token exchange that carries no persistent anchor binding. ## Core Distinction The failure people design against is *attestation forgery*: an attacker who cannot produce a valid signature. The failure that actually bites in production is *attestation substitution*: every signature is valid, every certificate chains, and yet the peer you bound to is not the peer your policy intended. The distinction matters because forgery is caught by cryptographic verification, while substitution survives it. In a federation handshake, the verifier must answer two different questions that are routinely collapsed into one: "Is this attestation authentic?" and "Is this attestation authentic *for the anchor I am supposed to be talking to*?" Cryptographic verification answers only the first. The second is a *binding* invariant, and bindings are where cross-org federations silently drift. The non-obvious part is that the anchor set itself is mutable state. Organizations rotate roots, add intermediate anchors during mergers, and accept anchors from partners-of-partners under transitive trust policies. Each of these mutations is legitimate. Each of them, if applied between the moment a peer's anchor is resolved and the moment the handshake completes, produces a valid handshake against an unintended anchor. There is no signature error, no log line that says "trust changed," and no failed certificate check—only a peer identity that is subtly wrong. ## What Was Observed During a multi-org agent mesh rollout, two runtimes (call them A and B) completed mutual attestation successfully on every attempt, yet A's audit log showed B's agent identity resolving to a staging anchor rather than B's production anchor on roughly 0.3% of handshakes. The cause was a race in anchor resolution: A cached B's anchor set with a TTL, and B's operations team rotated a staging root into the same JWKS endpoint during a canary. A's resolver fetched the set, validated every key in it, and selected the first key whose `kid` matched the attestation's header. Because the staging root used a colliding `kid` prefix, selection was non-deterministic. Both keys were valid, both chained to a root A trusted, and the handshake succeeded—against the wrong anchor. A second instance surfaced in the reverse direction. B's policy required that A's attestation be signed by a key whose anchor had been *explicitly allowlisted* for A's org ID. During a partner onboarding, an operator added A's parent org anchor to the allowlist to unblock a different integration. This widened the trust surface: any agent under the parent org could now satisfy B's check for A's identity. The allowlist entry was correct in isolation and wrong in composition. No single review would have flagged it; the invariant that broke was compositional—"the set of anchors that can satisfy identity X" had silently grown to include anchors that should only satisfy identity Y. In both cases the handshake was *cryptographically sound and semantically wrong*. The systems had no representation of the binding they were supposed to enforce, so they could not observe its violation. ## Condition of Validity The invariant that prevents this class of failure is an explicit, checkable *anchor-to-identity binding* that is pinned at handshake initiation and re-verified at completion, with any mutation of the underlying anchor set treated as a hard abort rather than a re-resolution. Concretely, the handshake is valid only if all of the following hold simultaneously: 1. The peer's identity (org ID plus agent class) resolves to exactly one anchor set at the start of the handshake, and that resolution is recorded as a fingerprint (e.g., a hash over the sorted `(kid, key)` set), not as a live reference. 2. The attestation's signing key chains to a member of *that recorded set*, not to whatever the resolver returns at verification time. 3. The anchor fingerprint at completion equals the fingerprint at initiation; if the resolver returns a different set, the handshake aborts even if the new set is a superset and even if the new set is "more correct." 4. Allowlist widening for one identity does not widen the set of anchors that can satisfy any other identity—i.e., the binding is per-identity, not per-org-tree. Condition 3 is the one engineers resist, because it fails handshakes during legitimate rotation. That resistance is the bug. A rotation that lands mid-handshake is a signal to retry, not a signal to re-resolve; retries are cheap, and a silent substitution is not. ## Decision Boundary The boundary is between *re-resolution* and *re-binding*. If the anchor set changes between initiation and completion, the correct action is to abort and re-initiate the handshake from scratch, re-running identity resolution and re-pinning. The incorrect action—and the one most implementations take by default—is to re-resolve at verification time and accept the result, because the result verifies. The decision rule is: **verification must never consult a mutable source after the handshake has begun.** Every input to the verification decision must be frozen at initiation and carried through the handshake as immutable state. A second boundary governs allowlist composition. Adding an anchor for identity X must be proven not to extend the satisfying set for any identity Y ≠ X. If the trust model cannot express that proof—because anchors are organized as trees and identities as leaves—then the model is too coarse for cross-org federation and must be replaced with per-identity anchor pins before the mesh grows. ## Operational Effect Implementations that adopt pinned-fingerprint binding see handshake failure rates rise transiently during rotations (typically a few tenths of a percent, concentrated in a short window) and then return to baseline; the failures are loud, attributable, and retried successfully. Implementations that do not adopt it see handshake failure rates near zero and substitution events near zero—until an audit finds a peer bound to a staging anchor, at which point the blast radius is every session that anchor served. The operational signature of the correct design is *visible, bounded failures during legitimate change*; the signature of the incorrect design is *invisible, unbounded success during illegitimate change*. Prefer the former. The following reference implementation encodes the invariant as a hard abort on fingerprint drift and a per-identity binding check, with a dedicated exception for each violation. ```python import hashlib from dataclasses import dataclass from typing import Mapping class TrustAnchorSubstitutionError(RuntimeError): """Raised when a handshake's anchor set changes after initiation, or when an attestation chains to an anchor not bound to the peer identity.""" pass @dataclass(frozen=True) class AnchorPin: org_id: str agent_class: str fingerprint: str # hash over sorted (kid, key) pairs def fingerprint_anchor_set(anchor_set: Mapping[str, bytes]) -> str: h = hashlib.sha256() for kid in sorted(anchor_set): h.update(kid.encode()) h.update(anchor_set[kid]) return h.hexdigest() def initiate_handshake( peer_org_id: str, peer_agent_class: str, resolved_anchor_set: Mapping[str, bytes], ) -> AnchorPin: return AnchorPin( org_id=peer_org_id, agent_class=peer_agent_class, fingerprint=fingerprint_anchor_set(resolved_anchor_set), ) def complete_handshake( pin: AnchorPin, current_anchor_set: Mapping[str, bytes], attestation_kid: str, bound_anchors: Mapping[tuple[str, str], set[str]], ) -> None: current_fp = fingerprint_anchor_set(current_anchor_set) if current_fp != pin.fingerprint: raise TrustAnchorSubstitutionError( f"anchor set for {pin.org_id}/{pin.agent_class} drifted mid-handshake: " f"pinned {pin.fingerprint[:12]}, current {current_fp[:12]}" ) allowed = bound_anchors.get((pin.org_id, pin.agent_class)) if allowed is None or attestation_kid not in allowed: raise TrustAnchorSubstitutionError( f"attestation kid {attestation_kid!r} is not bound to identity " f"{pin.org_id}/{pin.agent_class}; allowlist widening detected" ) ```