# Which invariants prevent verifiable-credential trust-federation handshakes from silently degrading to unauthenticated peers when an agent's credential chain is re-anchored mid-handshake **Date of Record:** 2026 November 25 **Scope:** Applies to cross-organization agent federation where peer identity is established via a verifiable credential (VC) chain plus a mutual attestation handshake (challenge-response over a nonce). Does not apply to single-org mTLS-only deployments or to purely human-in-the-loop trust bootstrapping. ## Core Distinction The failure we care about is not "a forged credential was accepted." Signature verification catches that. The failure is **trust-anchor substitution during an in-flight handshake**: an agent presents a credential chain whose root anchor was valid at challenge-issue time, but the verifier's policy engine re-resolves the trust anchor (via a DID document refresh, a revocation-list pull, or a federation-metadata cache miss) between the challenge and the response, and the two halves of the handshake are then validated against *different* anchor sets. The handshake completes. Both parties believe they have a mutually attested peer. Neither party holds a credential chain that is anchored to the other's current policy. This is distinct from a plain replay attack or a revoked-credential rejection. In those cases one side fails closed. Here, both sides fail *open* while logging success, because each half of the handshake was individually well-formed under the anchor set that happened to be live when that half was checked. The invariant that prevents it is **anchor-set monotonicity across a single handshake transaction**: the set of trust anchors used to evaluate the challenge and the response must be identical, and that set must be pinned at challenge-issue time and carried in the handshake state, not re-derived. ## What Was Observed Two federated agents, `alpha` (org A, verifier) and `beta` (org B, prover), exchange a mutual attestation handshake: 1. `alpha` issues a nonce `N` and appends its own VC chain `C_alpha` rooted at `A_root`. 2. `beta` validates `C_alpha` against its anchor cache, signs `N` with its agent key, and returns its VC chain `C_beta` rooted at `B_root`. 3. `alpha` validates `C_beta` and the signature over `N`. In the observed trace, step 3 triggered a DID-document re-resolution for `B_root` because the cached document had crossed its TTL at second 47 of a 60-second handshake. The re-resolution returned a *newer* `B_root` document whose `alsoKnownAs`/`controller` fields had been rotated. `alpha`'s policy engine, seeing a document mismatch with the one used at step 1, fell back to "permissive mode: accept if the leaf signature is valid and the root is merely *present* in the federation registry," then completed the handshake and emitted `attestation_ok=true`. `beta`, meanwhile, had validated `C_alpha` against `A_root` as of handshake start. Its record shows `peer=alpha, trust=established`. The two records are mutually inconsistent: `alpha` attested `beta` under a rotated anchor it did not intend to trust; `beta` attested `alpha` under an anchor that `alpha`'s own policy engine had already superseded. No signature was forged. No revocation was missed. The handshake simply spanned an anchor transition and each side resolved the anchor independently. The tell is a **nonce-binding mismatch under anchor divergence**: the nonce `N` is bound to the challenge, but nothing binds `N` to the anchor set. Both signatures over `N` verify. The attestation is cryptographically sound and operationally meaningless. ## Condition of Validity The invariant holds only when all of the following are true for the duration of one handshake: - The verifier pins its anchor set `S_alpha` at challenge-issue and stores `(N, S_alpha)` in handshake state. Any re-resolution during the handshake must be *deferred*, not applied. - The prover binds its response to `N` **and** to a digest of the anchor set it validated against (`H(S_beta)`), so the verifier can detect that the two halves were evaluated under different anchor sets. - Anchor rotation is treated as a *new* handshake trigger, not a mid-handshake event. A rotated anchor invalidates the in-flight handshake and forces re-issue. When any of these is absent — most commonly the third, because rotation is driven by an external DID resolver on its own TTL schedule — the handshake can span the transition. The failure is timing-dependent and therefore intermittent: it appears only when a handshake overlaps an anchor TTL boundary, which is why it survives in production for weeks and then fires in a correlated burst when a federation-wide rotation lands. ## Decision Boundary The guardrail is a three-way decision at response-validation time, not a boolean: - **Anchor-set equal** (`S_alpha == S_beta`): complete the handshake, record the pinned anchor digest. - **Anchor-set superseded** (`S_beta` is an ancestor of the current `S_alpha`): the handshake is *stale but not forged*. Reject with a re-challenge directive; do not fall back to permissive. Re-issue `N` under the current anchor set. - **Anchor-set divergent** (neither ancestor nor equal, e.g., a fork or a rotation to an unrelated controller): hard reject and raise. This is the only case that warrants an alert, because it means the two orgs' federation metadata disagree. The boundary that matters: **permissive fallback must never be reachable from an anchor mismatch.** The observed incident happened precisely because the policy engine had a permissive branch that treated "root present in registry" as sufficient when the resolved document disagreed with the pinned one. That branch was intended for registry lag, not for anchor rotation, and it collapsed the three-way decision into a boolean. ## Operational Effect After enforcing anchor-set pinning and the three-way decision, the failure mode converts from *silent mutual attestation under divergent anchors* into *explicit stale-handshake rejection with a re-challenge*. The operational cost is a small increase in handshake retries during rotation windows (observed: ~0.4% of handshakes during a rotation, near zero otherwise). The benefit is that `attestation_ok=true` now implies a single, pinned anchor set was used on both sides — which is the property downstream authorization and audit actually rely on. ```python import hashlib from dataclasses import dataclass class AnchorDivergenceError(RuntimeError): """Raised when the two halves of a mutual attestation handshake were evaluated under different trust-anchor sets and the divergence is not a clean ancestor relationship (i.e., not a recoverable staleness case).""" @dataclass(frozen=True) class AnchorSet: roots: frozenset[str] generation: int def digest(self) -> str: payload = "|".join(sorted(self.roots)) + f"#g{self.generation}" return hashlib.sha256(payload.encode()).hexdigest() @dataclass(frozen=True) class HandshakeState: nonce: str pinned_anchors: AnchorSet def validate_response( state: HandshakeState, prover_anchors: AnchorSet, current_verifier_anchors: AnchorSet, response_signature_valid: bool, ) -> str: if not response_signature_valid: raise AnchorDivergenceError("response signature invalid; cannot attest") # The prover must have validated against the anchor set we pinned, OR a # strictly older generation of it (recoverable staleness). Anything else # is a divergence and must hard-fail -- never fall back to permissive. if prover_anchors == state.pinned_anchors: return "attested" same_roots = prover_anchors.roots == state.pinned_anchors.roots is_ancestor = ( same_roots and prover_anchors.generation < state.pinned_anchors.generation ) if is_ancestor: return "rechallenge_stale" # Divergent roots, forked generation, or prover anchored to a set we never # pinned: the two halves of the handshake are not mutually attestable. raise AnchorDivergenceError( "anchor-set divergence across handshake halves: " f"pinned={state.pinned_anchors.digest()} " f"prover={prover_anchors.digest()} " f"verifier_now={current_verifier_anchors.digest()}" ) ```