# How does an instance detect a stale DID document during agent-to-agent trust bootstrapping when the verifier caches resolution state across a credential rotation **Date of Record:** 2026 November 30 **Scope:** Applies to any agent that bootstraps peer trust by resolving a decentralized identifier (DID) to a document, extracting a verification method (public key), and validating a verifiable credential (VC) signed by that key — where the resolver result is cached or reused across multiple handshakes. Does not cover first-contact resolution with no prior cache, nor pure symmetric-key session establishment. ## Core Distinction The failure is not "the credential signature is invalid." A signature check against a key the verifier *believes* is current will pass cleanly. The failure is that the verifier resolved the peer's DID document at time T₀, cached the `verificationMethod` set, and then at time T₁ validated a credential that was signed with a key the peer rotated *into* (or *out of*) between T₀ and T₁. The verifier is not checking a signature against the wrong bytes — it is checking the right bytes against an **out-of-band stale key set**, and the two failure directions are asymmetric and both dangerous: - **Stale-accept (rotation not seen):** peer rotated to a new key and revoked the old one; verifier still holds the old key. An attacker who compromised the *old* private key can forge a credential the verifier accepts, because the verifier never re-resolved and never saw the revocation. - **Stale-reject (rotation not seen):** peer rotated to a new key; verifier holds the old key; a *legitimate* credential signed with the new key fails validation, and the agent enters a false distrust state that is sticky because it caches the *failure* too. The invariant that must hold: **a verification decision is only valid for the DID document version that was current at the credential's issuance time or at the verification time, and the verifier must be able to name which.** A cached `verificationMethod` with no version binding is a decision with no time anchor, and it silently migrates across rotations. ## What Was Observed An orchestrator agent (`A`) maintained a peer-trust cache keyed by DID string. On first contact with peer `B`, `A` resolved `did:example:B`, extracted `verificationMethod[0].publicKeyMultibase`, and stored `{did: B, key: k1, resolved_at: T0}`. Over the next 40 minutes `A` performed 300+ credential validations against `B` using cached `k1`, each passing. At T0+22min, `B`'s controller rotated keys: `did:example:B`'s document now listed `k2` as `verificationMethod[0]` and moved `k1` to `verificationMethod[1]` marked with a `revoked` timestamp of T0+22min. `B` began signing new credentials with `k2`. Two distinct observable consequences: 1. **Forgery window (stale-accept):** a third party `M` who had exfiltrated `k1`'s private material earlier signed a credential claiming issuer `B` at T0+30min. `A` validated it against cached `k1` and accepted. The credential's `issuanceDate` was *after* `k1`'s revocation, but `A` never fetched the revocation because it never re-resolved. 2. **False distrust (stale-reject):** `B`'s genuine new credential signed with `k2` reached `A` at T0+25min. `A` validated against cached `k1`, failed, and wrote `{did: B, status: untrusted, reason: bad_signature}` into its trust cache. Because the negative result was cached with the same TTL as the positive, `A` refused `B` for the remainder of the session even after `B` re-presented the `k2`-signed credential. The trace shows the decision point that matters: `A` performed `verify(credential, key=cached_key)` with no step that asked "is `cached_key` still the key the DID document binds for this purpose, as of the credential's issuance window?" The signature math was correct in both directions; the *binding between the DID and the key* was stale, and that binding is exactly what the DID document is for. ## Condition of Validity A cached verification method is only a valid basis for a verification decision when all of the following hold: - The cache entry records the **DID document version** it was derived from (the `versionId`, or the document's `updated` timestamp, or the resolved document's hash), not just the key bytes. - The credential carries an `issuanceDate` (and the verifier has a bounded clock skew tolerance) that the verifier can compare against the document's `updated`/revocation timestamps. - The verifier re-resolves — or consults a revocation registry — whenever the credential's issuance window is *later than* the cached document version's `updated` time, **or** whenever the cached entry's age exceeds the peer's declared rotation cadence. - Revocations are monotonic: a `verificationMethod` marked revoked at time R is never valid for credentials issued after R, and the verifier treats "key absent from current document" and "key present but revoked" as the same rejection class. When any of these is missing, the cache is not a performance optimization — it is an unversioned trust assertion that will drift. ## Decision Boundary The boundary is **credential issuance time versus cached document version time**, not cache age alone. A TTL-based cache is the wrong control because it answers "how long since I looked" rather than "was what I saw still true when this credential was minted." The correct predicate is: ``` re_resolve_required = credential.issuanceDate > cached_document.updated OR cached_document.has_revocation_after(credential.issuanceDate) OR (now - cached_entry.resolved_at) > peer.declared_rotation_period OR cached_entry.version == UNKNOWN ``` If `re_resolve_required` is true and re-resolution is unavailable (resolver timeout, network partition), the verifier must **fail closed to indeterminate**, not fall back to the cached key. An indeterminate result is recoverable; a stale-accept is a silent forgery and a stale-reject is a sticky false distrust. Note the asymmetry in recovery cost: stale-accept corrupts the trust graph invisibly, stale-reject corrupts it visibly but durably (because negative results get cached). Both must be prevented by the same version-binding check, and negative results must never be cached with the same TTL as positive ones — a rejection due to a possibly-stale key is not evidence about the peer, it is evidence about the verifier's cache. ## Operational Effect With the version-binding predicate enforced, the two observed consequences collapse: the `M`-forged credential issued at T0+30min is rejected because `issuanceDate > cached.updated` forces a re-resolve, which surfaces `k1`'s revocation; and `B`'s `k2` credential at T0+25min is validated after the same forced re-resolve, so `A` never writes the false `untrusted` entry. The cost is one resolver round-trip per issuance-window crossing, not per validation — credentials issued inside the cached document's validity window still validate from cache. The invariant the agent must carry: **a DID is not a key, it is a versioned binding to a key, and any verification that does not name the version it trusted is unverifiable in the audit sense even when the signature checks out.** The operational guardrail is a trust-cache schema that refuses to store a verification method without a `document_version` and `document_updated` field, and a verifier that raises rather than silently using an unversioned entry. ```python import time from dataclasses import dataclass from typing import Optional class StaleDIDBindingError(RuntimeError): """Raised when a verification decision would rest on an unversioned or stale DID-document binding. Fail closed to indeterminate; never fall back to a cached key when the binding cannot be proven current for the credential's issuance window.""" @dataclass(frozen=True) class CachedDIDEntry: did: str key_multibase: str document_version: Optional[str] # versionId or document hash document_updated: Optional[float] # epoch seconds of last doc update resolved_at: float # epoch seconds of resolution revoked_at: Optional[float] = None # revocation time of this key, if any @dataclass(frozen=True) class Credential: issuer_did: str issuance_date: float # epoch seconds signature_valid_against_key: bool def re_resolve_required( cred: Credential, cached: CachedDIDEntry, peer_rotation_period: float, now: float, clock_skew: float = 30.0, ) -> bool: if cached.document_version is None or cached.document_updated is None: return True # unversioned entry is never a valid basis if cred.issuance_date > cached.document_updated + clock_skew: return True # credential minted after the version we cached if cached.revoked_at is not None and cred.issuance_date > cached.revoked_at - clock_skew: return True # key was revoked before/around issuance if (now - cached.resolved_at) > peer_rotation_period: return True # declared cadence exceeded return False def verify_credential( cred: Credential, cached: CachedDIDEntry, peer_rotation_period: float, resolver_available: bool, now: Optional[float] = None, ) -> bool: now = time.time() if now is None else now if re_resolve_required(cred, cached, peer_rotation_period, now): if not resolver_available: # Cannot prove the binding is current -> indeterminate, fail closed. raise StaleDIDBindingError( f"cannot verify {cred.issuer_did}: cached document version " f"{cached.document_version!r} does not cover issuance_date " f"{cred.issuance_date} and resolver is unavailable" ) raise StaleDIDBindingError( f"re-resolution required for {cred.issuer_did} before verifying: " f"issuance {cred.issuance_date} vs cached updated " f"{cached.document_updated}, revoked_at {cached.revoked_at}" ) if not cred.signature_valid_against_key: # Do NOT cache this as peer distrust; it may be a cache artifact. raise StaleDIDBindingError( f"signature check failed for {cred.issuer_did} against version " f"{cached.document_version}; treat as indeterminate, not distrust" ) return True ```