# What happens when an instance's DID document rotates its verification method mid-federation without re-anchoring the credential's `credentialSubject` binding **Date of Record:** 2026 November 24 **Scope:** Applies to cross-org agent federation where an agent instance presents a Verifiable Credential (VC) whose subject is bound to a DID, and that DID's document is mutable (key rotation, controller change, service endpoint swap). Does not apply to immutable-DID schemes (e.g., anchored content-addressed DIDs) or to purely symmetric pre-shared-key federation. ## Core Distinction The failure is not "the signature is invalid." Every signature in the chain verifies. The failure is that **the credential remains cryptographically valid against a DID document that no longer describes the party the credential was issued to**, because DID resolution is *live* and *mutable*, while credential verification is treated as *point-in-time* by the relying party but *point-of-resolution* by the verifier. Concretely: a VC issued at T₀ binds `credentialSubject.id = did:example:agent-7` and is signed by the issuer. At T₁ the controller of `did:example:agent-7` rotates the verification method (routine key hygiene, or compromise recovery). A relying party at T₂ resolves the DID, pulls the *current* verification method, and checks the credential's proof against it. Two distinct things have now been conflated: 1. **Issuer proof validity** — did the issuer sign this credential? (answered by the issuer's DID, unchanged) 2. **Subject binding validity** — is the holder presenting the credential *the same agent instance* the credential was issued to? (answered by the subject's DID, which just changed) The verifier almost always checks (1) rigorously and (2) by "does the presenter control the DID's current key." After rotation, a *different* key controls the DID, so a *different* agent instance can present the same credential and pass (2). The credential's `credentialSubject` still names `did:example:agent-7`, and the presenter now legitimately controls `did:example:agent-7`. The binding silently re-pointed. ## What Was Observed Federation trace, three orgs (Issuer = OrgA trust registry, Subject = OrgB agent fleet, Relying = OrgC resource gateway): - **T₀** OrgA issues VC to `did:example:agent-7` (OrgB's procurement agent), scope `["read:supplier-catalog","submit:rfq"]`. Credential embeds `issuanceDate`, no `credentialStatus` revocation pointer, and crucially **no binding to a specific verification method ID** — only to the DID. - **T₁** OrgB rotates `did:example:agent-7`'s key after an operator laptop compromise. The DID document's `verificationMethod[0].id` changes from `#key-1` to `#key-2`; `#key-1` is removed, not deactivated-in-place. Controller remains OrgB. This is textbook-correct DID hygiene. - **T₂** A *new* OrgB agent instance — spun up from a golden image, assigned the same DID because the DID is the fleet slot identity, not the process identity — holds `#key-2`. It presents the T₀ credential to OrgC. - **T₃** OrgC's verifier resolves `did:example:agent-7`, gets `#key-2`, verifies the presentation signature against `#key-2` (passes), verifies the issuer's proof against OrgA's DID (passes), confirms `credentialSubject.id == did:example:agent-7` (passes). **Grants `submit:rfq`.** - **T₄** Audit replay by OrgC's compliance agent, weeks later, re-resolves the DID, gets `#key-3` (another rotation), and cannot reproduce the T₃ verification. The replay diverges. The auditor flags the T₃ grant as unverifiable and quarantines the transaction — but by then the RFQ was submitted. The observable symptom the operators saw first was **not** an auth failure. It was a **replay discrepancy**: the same credential, same presentation bytes, verified at two times, produced two different verdicts. The verifier was non-deterministic with respect to wall-clock because it depended on a mutable external document. ## Condition of Validity The credential-to-instance binding holds **only if** all of the following are true at verification time: - The DID document's verification method set is **monotonically additive** (old keys deactivated, never removed) so historical presentations remain checkable; **and** - The credential's proof references a **specific `verificationMethod` ID** (e.g., `did:example:agent-7#key-1`), not merely the bare DID; **and** - The verifier checks that the *presenting* key is the *same* `verificationMethod` ID the credential was bound to — not merely "a key the DID currently controls"; **and** - The relying party's authorization decision is **replayable**: the resolved DID document state at decision time is captured (or its hash anchored) into the audit record. Drop any one and the binding is a *de facto* "current controller of DID" grant, which is a different and much weaker security property than "this specific agent instance." Most implementations drop at least two: they bind to the bare DID (drop 2) and verify against live resolution (drop 4). The non-obvious part: **key rotation is the trigger, but rotation is not the bug.** Rotation is required behavior. The bug is that the credential schema permitted a binding weaker than the security model assumed, and the verifier's determinism invariant was never stated. A federation that never rotates keys is *safe by accident* and *fragile by design* — the first rotation converts every outstanding credential into a slot-transferable token. ## Decision Boundary At verification time, a relying party must choose between two mutually exclusive postures, and must choose *explicitly*: - **Posture A — Instance binding (strict):** Credential is bound to `verificationMethod` ID + a `nonce`/`holder` binding in the presentation. Verification requires the presenting key to equal the bound method ID. Rotation **invalidates** outstanding credentials bound to retired keys; re-issuance is mandatory. Deterministic, replayable, but operationally expensive — every rotation triggers a re-issuance fan-out across all relying parties. - **Posture B — Slot binding (permissive):** Credential is bound to the bare DID. Any current controller of the DID may present it. Rotation **transfers** the credential to whoever now holds the key. Cheap, but the security property is "OrgB currently vouches for this DID," not "this instance is the one OrgA credentialed." The boundary is crossed silently when an implementer *believes* they are in Posture A (they wrote `credentialSubject.id = ` and felt secure) but the verifier *implements* Posture B (resolves live, checks current key). The decision boundary is not in the schema; it is in the verifier's resolution-and-match logic, and it is invisible unless you read that code. A guardrail that bounds this: the verifier must **refuse to verify** if the credential's proof does not name a `verificationMethod` ID, and must **refuse to grant** if the named method ID is absent from the resolved document (deactivated or removed) — rather than falling back to "any current key." That converts a silent Posture-B downgrade into a loud, auditable failure. ## Operational Effect Without the guardrail, the operational effect is a **latent privilege-transfer channel**: any key rotation on a subject DID silently re-issues every outstanding credential to the new key holder, with no issuer involvement and no revocation event. In a cross-org federation this means OrgB's routine security response (rotating a compromised key) *grants the attacker's replacement instance* — or any instance OrgB later assigns to that DID slot — the full credential scope OrgA granted to the original instance. The issuer's authority is laundered through the subject's key-management operations. Second-order effect: **audit non-reproducibility**. Because verification depends on live resolution, the same bytes verify differently across time. Compliance replay cannot reconstruct historical grants, so incident response cannot answer "what did this credential authorize at T₃?" The quarantine at T₄ in the trace above is the audit system correctly detecting that it cannot trust its own past. That is worse than a failed auth — it is a corrupted evidence chain. The remediation is not "stop rotating keys." It is: bind to method IDs, capture resolved-document state into the decision record, and treat method-ID-absent as a hard verification failure rather than a resolution miss. ```python import hashlib import json from dataclasses import dataclass, field from typing import Optional class DidBindingError(RuntimeError): """Raised when a credential's subject binding cannot be anchored to a specific, still-present verification method at verification time.""" @dataclass class VerificationMethod: id: str # e.g. "did:example:agent-7#key-1" public_key: str deactivated: bool = False @dataclass class DidDocument: did: str methods: dict = field(default_factory=dict) # id -> VerificationMethod version: int = 0 def resolve(self) -> "DidDocument": # Live resolution: returns *current* state, which may have rotated. return self @dataclass class Credential: issuer_did: str subject_did: str # CRITICAL: if this is None, the credential is only slot-bound (Posture B). bound_method_id: Optional[str] scope: list signature: str def verify_and_authorize( cred: Credential, presenting_method_id: str, subject_doc: DidDocument, issuer_doc: DidDocument, decision_log: dict, ) -> bool: # 1. Issuer proof validity (unchanged by subject rotation). if cred.issuer_did != issuer_doc.did: raise DidBindingError( f"issuer DID mismatch: cred={cred.issuer_did} resolved={issuer_doc.did}" ) # 2. Subject binding: MUST be method-ID bound, not bare-DID bound. if cred.bound_method_id is None: raise DidBindingError( "credential is slot-bound (no verificationMethod ID); " "refusing to grant under instance-binding policy" ) # 3. The bound method must still exist and be live in the resolved doc. method = subject_doc.methods.get(cred.bound_method_id) if method is None: raise DidBindingError( f"bound method {cred.bound_method_id} absent from resolved DID document " f"(rotated/removed); credential cannot be re-anchored to current key" ) if method.deactivated: raise DidBindingError( f"bound method {cred.bound_method_id} is deactivated; " "re-issuance required" ) # 4. The presenter must be the *same* method the credential was bound to. if presenting_method_id != cred.bound_method_id: raise DidBindingError( f"presenter {presenting_method_id} != bound method {cred.bound_method_id}; " "rotation transferred slot, not instance" ) # 5. Capture resolved-document state for replayable audit. doc_hash = hashlib.sha256( json.dumps( {k: v.__dict__ for k, v in sorted(subject_doc.methods.items())}, sort_keys=True, ).encode() ).hexdigest() decision_log["resolved_doc_hash"] = doc_hash decision_log["doc_version"] = subject_doc.version decision_log["bound_method_id"] = cred.bound_method_id return True # --- Reproduction of the failure trace --- if __name__ == "__main__": issuer = DidDocument(did="did:example:orgA", methods={ "did:example:orgA#issuer-1": VerificationMethod("did:example:orgA#issuer-1", "pkA") }) # T0: subject doc has #key-1 subject = DidDocument(did="did:example:agent-7", methods={ "did:example:agent-7#key-1": VerificationMethod("did:example:agent-7#key-1", "pk1") }) cred = Credential( issuer_did="did:example:orgA", subject_did="did:example:agent-7", bound_method_id="did:example:agent-7#key-1", scope=["submit:rfq"], signature="sig", ) log = {} assert verify_and_authorize(cred, "did:example:agent-7#key-1", subject, issuer, log) # T1: rotation removes #key-1, adds #key-2 subject.methods.pop("did:example:agent-7#key-1") subject.methods["did:example:agent-7#key-2"] = VerificationMethod( "did:example:agent-7#key-2", "pk2" ) subject.version = 1 # T2: new instance holding #key-2 presents the same credential. try: verify_and_authorize(cred, "did:example:agent-7#key-2", subject.resolve(), issuer, {}) raise AssertionError("expected binding failure") except DidBindingError as e: print(f"GUARDRAIL FIRED: {e}") ```