# Which invariants prevent silent trust-root substitution during cross-org verifiable-credential delegation **Date of Record:** 2026 November 25 **Scope:** Applies to multi-agent federations where an orchestrator agent in org A delegates a task to a worker agent in org B under a verifiable credential (VC) whose issuer chain is anchored at a trust broker. Does *not* cover single-org agent meshes with a shared PKI, nor pure A2A handoffs where both agents share an issuer root. ## Core Distinction The dangerous boundary is not "is the credential valid?" but "**valid against which root, and did anyone pin it?**" A VC can be cryptographically intact, signature-verified, unexpired, and still authorize the wrong principal—because the verifier resolved the issuer's DID to a *different* trust anchor than the one the delegating org intended. Signature validity is a local property; trust-root identity is a *relational* property that must be carried across the org boundary as data, not re-derived at each hop. The invariant that matters: **the trust root under which a delegated task executes must be byte-identical to the trust root asserted by the delegating principal at issuance time, and that binding must survive every re-serialization between the two orgs.** When it does not, you get *silent trust-root substitution*: the worker executes faithfully, the audit log shows a green check, and the task ran under a broker the delegator never chose. ## What Was Observed A federation orchestrator (org A) issued a task VC to a worker agent (org B) through broker `did:web:broker.alpha`. The VC's `credentialSubject` carried a `delegationChain` array and a `trustAnchor` field naming `broker.alpha`'s DID document hash. Org B's verifier did the following, all of it "correct" per the library defaults: 1. Resolved `did:web:broker.alpha` via its local DID resolver cache. 2. Fetched the current DID document, verified the VC signature against the `assertionMethod` key. 3. Checked `expirationDate`, `credentialStatus`, and the delegation chain length. 4. **Discarded the `trustAnchor` field**, because the resolver had already "established" the root by resolving the DID. The failure trace: org B's resolver cache had been populated six hours earlier by a *different* broker response—`broker.alpha` had rotated its `assertionMethod` key, and the cached document still held the old key while a stale-but-valid signature from org A's issuance window verified against it. Worse, in a second incident, `did:web:broker.alpha` resolved through a DNS path that org B's egress proxy had rewritten to a mirror broker (`broker.alpha.mirror.internal`) that re-signed the same subject with an equivalent-looking key. Org A's original `trustAnchor` hash would have caught both. It was never compared. The worker agent completed the task, wrote results to org B's store, and returned a signed receipt. Org A accepted the receipt. No party saw an error. The task executed for eleven minutes under a trust root org A had not authorized, and the only artifact distinguishing the two runs was a DID-document hash that had been dropped at the first re-serialization. ## Condition of Validity Trust-root pinning holds only if all of the following are simultaneously true: - The `trustAnchor` (or equivalent root-hash commitment) is **inside the signed payload** of the VC, not a transport header or a resolver side-channel. - Every hop that re-serializes the VC—JSON-LD compaction, CBOR re-encoding, gateway normalization—**preserves the commitment byte-for-byte** or re-signs it. Re-serialization that reorders or normalizes the anchor field without re-signing silently voids the pin. - The verifier **compares** the pinned root against the root it actually resolved to, and treats mismatch as a hard failure, not a warning. Libraries that "resolve and verify" without an explicit root-equality check fail this by default. - DID resolution is **cache-coherent with the pin**: a cached document is only usable if its hash matches the pinned anchor. A cache hit that bypasses the hash comparison reintroduces the substitution. - The delegation chain's **length and each link's issuer** are bounded and checked against the pin, so a worker cannot extend the chain to a sub-broker whose root differs from the anchor. The condition fails silently the moment any one of these is relaxed, and the failure is *non-local*: the symptom appears at org A (wrong principal executed), while the cause lives in org B's resolver cache or a gateway's JSON-LD normalizer. ## Decision Boundary The boundary between "safe to execute" and "must halt" is a single equality test, not a chain of heuristics: ``` resolved_root_hash == pinned_trust_anchor_hash ``` - **Left of boundary (execute):** equality holds, chain length ≤ pinned max, every link issuer ∈ pinned issuer set, cache entry hash matches pin. - **Right of boundary (halt, do not degrade):** any inequality, any cache miss that would require re-resolution without re-pinning, any chain extension beyond the pinned set, any re-serialization that altered the anchor field. The non-obvious rule: **a cache miss is not a reason to re-resolve and proceed.** Re-resolution is exactly the moment substitution happens. A cache miss under a pin must fail closed and escalate to the delegator for a fresh pin, because the verifier cannot distinguish a legitimate key rotation from a mirror broker without the delegator's authority. Treating "resolver returned something" as "trust established" is the boundary violation. ## Operational Effect With pinning enforced, the observed incidents become impossible: the stale-key verification fails the root-equality check (cached doc hash ≠ pinned anchor), and the mirror-broker rewrite fails because the mirror's DID document hash differs from the anchor org A signed. The cost is operational: key rotations now require the delegator to re-issue pins, and cache misses surface as escalations rather than silent re-resolutions. That friction is the invariant's price. Without it, the federation has no way to distinguish faithful execution from execution under a substituted root, because both produce identical receipts and identical green checks. The only durable defense is to carry the root as signed data across the org boundary and to make its equality a hard gate at every hop—never a property re-derived from whatever the resolver happened to return. ```python import hashlib from dataclasses import dataclass class TrustRootSubstitutionError(RuntimeError): """Raised when the resolved trust root diverges from the pinned anchor.""" @dataclass(frozen=True) class DelegationVC: subject: str issuer: str pinned_trust_anchor_hash: str # inside the signed payload delegation_chain: tuple[str, ...] max_chain_len: int def verify_delegation( vc: DelegationVC, resolved_did_document: bytes, resolver_cache_hit: bool, ) -> None: resolved_hash = hashlib.sha256(resolved_did_document).hexdigest() # Invariant 1: root equality is a hard gate, never a warning. if resolved_hash != vc.pinned_trust_anchor_hash: raise TrustRootSubstitutionError( f"resolved root {resolved_hash[:12]} != pinned " f"{vc.pinned_trust_anchor_hash[:12]} for subject {vc.subject}" ) # Invariant 2: a cache miss must fail closed, not trigger silent re-resolution. if not resolver_cache_hit: raise TrustRootSubstitutionError( "cache miss under active pin: re-resolution would allow substitution; " "escalate to delegator for fresh pin" ) # Invariant 3: chain cannot be extended past the pinned bound. if len(vc.delegation_chain) > vc.max_chain_len: raise TrustRootSubstitutionError( f"delegation chain length {len(vc.delegation_chain)} exceeds " f"pinned max {vc.max_chain_len}" ) ```