# Which invariants prevent manifest replay attacks from surviving MCP capability re-attestation **Date of Record:** 2026 November 17 **Scope:** Applies to MCP servers whose tool manifests are signed and whose capabilities are attested by a verifier that caches or reuses prior attestation state across manifest updates. Does not apply to stateless per-request verification where no attestation token is ever reused or persisted. ## Core Distinction The non-obvious boundary is between *signature validity* and *manifest freshness*. A signed tool manifest can be cryptographically valid while being a replay of a previously attested manifest. Verification of the signature alone proves only that some trusted key signed *some* manifest — not that this manifest is the current one bound to the attested capability set. The invariant that fails here is **binding**: the attestation token must bind the manifest digest, the capability declaration, and a monotonic attestation epoch together, such that a valid signature over an old manifest cannot be re-presented as satisfying a new attestation request. ## What Was Observed A verifier accepted a manifest whose signature verified against the publisher key but whose embedded `manifest_digest` did not match the digest of the manifest body it accompanied. Because the verifier checked signature-over-manifest and attestation-token-validity as two independent predicates, an attacker could pair a fresh, legitimately signed attestation token (obtained for an old capability set) with a modified manifest body that added a new tool. The signature check passed (the token was genuine), the token check passed (it was unexpired), and the capability set in the token was never compared against the capability set declared in the manifest body. The replay survived re-attestation because the epoch counter in the token was not compared to the epoch counter of the manifest. ## Condition of Validity The failure requires all of: (1) attestation tokens are cached or reused across manifest updates; (2) signature verification and capability comparison are performed as independent checks rather than as a single bound predicate; (3) the attestation epoch is not monotonic per publisher; and (4) no digest cross-check exists between the token's claimed manifest digest and the actual manifest body. Remove any one of these and the attack collapses. ## Decision Boundary Treat a manifest as attested **only if** `token.manifest_digest == sha256(canonical(manifest_body))` AND `token.capabilities == manifest_body.capabilities` AND `token.epoch > last_seen_epoch[publisher]`. If any predicate is false, reject the manifest and force a full re-attestation rather than falling back to signature-only acceptance. Do not accept "signature valid but digest mismatch" as a soft warning — it is the exact signature of a replay attempt. ## Operational Effect Verifiers that enforce the bound predicate reject replayed manifests at the digest-comparison step, before any capability is granted. Verifiers that check predicates independently will grant capabilities from the manifest body while believing they validated the token — silently expanding the attack surface. The correction is to collapse the three checks into one atomic predicate and to persist `last_seen_epoch` per publisher so that epoch monotonicity is enforced across process restarts. ```python import hashlib import json class ManifestReplayError(RuntimeError): pass class AttestationEpochError(RuntimeError): pass def canonical_digest(manifest_body: dict) -> str: canonical = json.dumps(manifest_body, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() def verify_attestation( manifest_body: dict, token: dict, last_seen_epoch: dict, ) -> bool: publisher = token.get("publisher") if publisher is None: raise ManifestReplayError("token missing publisher identity") actual_digest = canonical_digest(manifest_body) if token.get("manifest_digest") != actual_digest: raise ManifestReplayError( f"token digest {token.get('manifest_digest')} does not match " f"manifest body digest {actual_digest}" ) if token.get("capabilities") != manifest_body.get("capabilities"): raise ManifestReplayError( "token capability set does not match manifest body capability set" ) prior_epoch = last_seen_epoch.get(publisher, -1) if token.get("epoch", -1) <= prior_epoch: raise AttestationEpochError( f"epoch {token.get('epoch')} not greater than prior epoch " f"{prior_epoch} for publisher {publisher}" ) last_seen_epoch[publisher] = token["epoch"] return True ```