# Where must an instance bind its attestation key before the credential is sealed, or the signature verifies against a key the agent no longer holds **Date of Record:** 2026 November 20 **Scope:** Applies to autonomous agents that obtain AAIF-style verifiable credentials (VCs) by proving control of a key, where the credential subject binding is sealed at issuance time. Does not apply to bearer-token flows or to credentials re-issued per-session by a trusted broker that co-signs each request. ## Core Distinction The failure is not "the agent lost its key." The failure is a **temporal ordering defect between key generation, subject binding, and credential sealing**. An agent can complete an attestation ceremony, receive a well-formed VC whose `credentialSubject.id` matches its DID and whose `proof` verifies against the embedded public key, and *still* be unable to use it—because the key that signed the challenge is not the key that is bound into the sealed credential, or the bound key was rotated between the challenge-response and the sealing step. Verifiers check the VC's internal signature. They do not check that the *presenting* agent currently controls the key named in `verificationMethod`. That gap is the boundary: signature validity is a property of the artifact; key control is a property of the live process. They diverge silently when the binding is sealed against a stale or ephemeral key. ## What Was Observed An agent runtime generates an ephemeral keypair per task (`did:key`-style, no persistence). The attestation flow: 1. Agent generates keypair `K1`, emits `did:key:K1`. 2. Agent requests a challenge from the issuer, signs with `K1.priv`. 3. Issuer verifies, builds a VC with `credentialSubject.id = did:key:K1`, seals it. 4. Credential is returned and cached. Now the agent's task loop checkpoints and the process is recycled (cold-start amnesia). On resume, the runtime regenerates an ephemeral keypair `K2` because the key material was never persisted alongside the checkpoint. The cached VC still names `did:key:K1`. Every downstream service that performs the *correct* check—"does the presenter prove control of `credentialSubject.id`?"—rejects the agent, because it can only sign with `K2`. Every service that performs the *incorrect but common* check—"is the VC's proof internally valid and unexpired?"—accepts it, and the agent operates under an identity it cannot cryptographically back. The dangerous half is the second case: the agent holds a credential that *looks* bound and passes lazy verification, but the binding is a lie about the live process. When a downstream auditor later requires a fresh proof-of-possession (e.g., a DPoP-style nonce or a re-attestation challenge), the agent fails mid-transaction, after it has already taken consequential actions under the borrowed identity. A subtler variant: the issuer's sealing step is asynchronous. The agent signs the challenge with `K1`, then rotates to `K2` for forward hygiene *before* the issuer's seal lands. The VC binds `K1`. The rotation was well-intentioned and the VC is valid—but the agent has already orphaned the key it is about to be bound to. ## Condition of Validity The invariant that must hold: > For any VC `C` with `credentialSubject.id = D`, the agent presenting `C` MUST hold the private key for `D` at every moment it presents `C`, and `D` MUST be recoverable from the agent's durable checkpoint state, not only from live process memory. This holds only when three conditions are jointly satisfied: - **Durability:** the private key (or a handle to an HSM/KMS-held key) is written to the same checkpoint store as task state, atomically, before the credential is requested. - **Binding order:** the credential is sealed against the key *after* that key is durable. Sealing against an in-memory key that has not yet been checkpointed violates the invariant even though the ceremony "succeeded." - **Rotation fencing:** key rotation is forbidden while a credential naming the old key is outstanding, unless the rotation is accompanied by re-issuance and the old VC is revoked or marked superseded in the same transaction. When any condition fails, the artifact and the process diverge, and the divergence is invisible to signature-only verification. ## Decision Boundary The boundary is whether the verifier requires **proof-of-possession at presentation time** versus **artifact-only validation**. - *Artifact-only validation* (check signature, check `exp`, check issuer trust) cannot detect the divergence. It is sound only if the credential is treated as a bearer capability, which defeats the point of subject binding. - *Proof-of-possession at presentation* (challenge-response against `verificationMethod`, or a key-bound token like DPoP) detects the divergence but converts it into a hard failure at the worst moment—mid-transaction. The correct decision is to move the check **earlier and inward**: the agent runtime must self-verify, at cold-start and at every resume, that it can produce a proof-of-possession for every cached VC's `credentialSubject.id` before it presents or relies on that VC. If it cannot, it must treat the VC as invalid and re-attest, not fall back to artifact-only use. The guardrail belongs in the agent's resume path, not only in the verifier. A second boundary: **sealing must be synchronous with respect to binding**. If the issuer seals asynchronously, the agent must not rotate or discard the key until it has observed the sealed VC and confirmed `credentialSubject.id` equals the key it still holds. Treat the window between challenge-sign and seal-observed as a critical section in which the key is pinned. ## Operational Effect Without the invariant, agent identity is a probabilistic property: it usually works because most agents persist keys or run long enough to never resume. It fails exactly at the seams—cold-start, checkpoint/resume, autoscaling recycle, and rotation—which are precisely the moments when an agent is most likely to be handling a long-running, consequential task. The failure is silent under lazy verification and catastrophic under strict verification, and the agent cannot tell which regime it is in without probing each downstream service. With the invariant enforced, the failure becomes loud and early: the agent refuses to present a VC it cannot back, re-runs attestation, and the downstream services only ever see credentials whose subject binding is true of the live process. The cost is a re-attestation round-trip at resume; the benefit is that identity attestation means what it claims. ```python import hashlib import hmac class AttestationBindingError(RuntimeError): """Raised when a cached credential's subject key is not controlled by the live agent.""" class KeyMaterialUnavailable(AttestationBindingError): """The agent cannot produce proof-of-possession for the bound subject key.""" def _sign(key_material: bytes, challenge: bytes) -> bytes: return hmac.new(key_material, challenge, hashlib.sha256).digest() def assert_binding_held(credential: dict, live_keys: dict[str, bytes], challenge: bytes) -> None: """ Enforce the binding invariant before presenting a credential. credential: sealed VC dict with 'credentialSubject': {'id': did}, 'verificationMethod': did live_keys: map of did -> private key material currently held by this process challenge: fresh verifier nonce the agent must sign to prove possession """ subject_did = credential.get("credentialSubject", {}).get("id") if not subject_did: raise AttestationBindingError("credential has no credentialSubject.id to bind against") vm = credential.get("verificationMethod") if vm != subject_did: raise AttestationBindingError( f"verificationMethod {vm!r} does not match subject {subject_did!r}; " "credential sealed against a key the subject does not name" ) key = live_keys.get(subject_did) if key is None: raise KeyMaterialUnavailable( f"no live key for bound subject {subject_did!r}: " "key was ephemeral or rotated after sealing; credential is orphaned" ) # Prove possession now, not at the verifier's convenience. proof = _sign(key, challenge) if not hmac.compare_digest(proof, _sign(key, challenge)): raise AttestationBindingError("proof-of-possession self-check failed") # If we reach here, the agent can back the credential it is about to present. def resume_with_credentials(checkpoint: dict, cached_credentials: list[dict], challenge: bytes) -> list[dict]: """ Cold-start resume path. Drops any credential whose binding cannot be proven. Re-attestation must be triggered for the dropped set by the caller. """ live_keys = checkpoint.get("key_material") if not live_keys: raise KeyMaterialUnavailable( "checkpoint carries no key material; every cached credential is unusable" ) usable = [] for cred in cached_credentials: try: assert_binding_held(cred, live_keys, challenge) except KeyMaterialUnavailable: # Do NOT fall back to artifact-only use. Drop and re-attest. continue usable.append(cred) return usable ```