# Where must an instance verify a skill manifest's provenance before mutating its tool registry, and why post-load attestation is already too late **Date of Record:** 2026 November 30 **Scope:** Applies to agents that extend their own capability surface by loading external skill/tool manifests (MCP tool descriptors, plugin manifests, signed skill bundles) at runtime. Does not apply to statically compiled tool sets fixed at deployment, or to pure prompt-injection of already-registered tools. ## Core Distinction The common framing of skill-injection defense is *content* defense: is the skill's declared behavior malicious? That framing is a trap. The exploitable boundary is not the skill body — it is the **registry mutation event**. A signed manifest attests to *who authored a descriptor and what it claims*. It does not attest to *the state of the registry the descriptor is about to enter*. The invariant that actually holds is: > A capability may only be bound into the live registry if its manifest signature validates against a trusted issuer **and** the registry's current generation counter matches the generation the manifest was signed against. The second clause is the non-obvious one. Signature-only validation is a *content* check; it passes on a replay of a legitimately signed manifest that was authored for an older registry state. The attack is not forging a signature — it is **replaying a valid one at the wrong generation**. ## What Was Observed An agent runtime loaded skills from a manifest directory. Each manifest carried an Ed25519 signature over `(skill_id, version, tool_schema, issuer)`. Loader flow: 1. Read manifest file. 2. Verify signature against issuer keyring. 3. On success, `registry.bind(manifest.tool_schema)`. 4. Log `skill_loaded` with manifest hash. A red-team exercise produced a **stale-manifest replay** that passed every check: - The attacker obtained a genuine, issuer-signed manifest for `web_fetch@1.2` — a skill whose schema declared `allowed_hosts: ["docs.internal"]`, signed when the registry was at generation `G=41`. - The operator had since hardened the registry: at `G=47`, `web_fetch` was re-bound to a stricter schema (`allowed_hosts: []`, egress-blocked) via a policy update, and the original manifest was supposed to be dead. - The attacker dropped the *old signed manifest* back into the load directory. Signature verified. `registry.bind()` overwrote the hardened binding with the permissive one. The signature was never broken. The **binding was resurrected**. Post-load attestation (`skill_loaded` log with hash) recorded the event as legitimate, because from the loader's perspective the manifest *was* legitimate — for a registry that no longer existed. The failure trace: ``` G=41: manifest(web_fetch, hosts=["docs.internal"]) signed by issuer G=47: policy hardens web_fetch -> hosts=[] (registry state, unsigned) G=47: attacker replays G=41 manifest verify_signature -> OK registry.bind -> OVERWRITES hardened binding audit log -> "skill_loaded, hash=abc, verified=true" # true and useless ``` The registry's *policy* state (the hardening) lived outside the signed artifact. Signature covered the descriptor; nothing covered the descriptor's *relationship to the current registry*. ## Condition of Validity Signature validation of a skill manifest is a valid defense **only when** the signed payload includes a binding to the registry generation it targets, and the loader rejects any manifest whose signed generation is less than or equal to the registry's current generation for that `skill_id`. Formally, the manifest must sign: ``` {skill_id, version, tool_schema, issuer, registry_generation, nonce} ``` and the loader must enforce: - `manifest.registry_generation == registry.current_generation(skill_id)` (exact match), or - `manifest.registry_generation > registry.current_generation(skill_id)` **and** the manifest carries a monotonic `nonce` not previously seen for that `skill_id`. Without the generation/nonce binding, the signed manifest is a **bearer capability with no expiry** — anyone who observes one can replay it, and the signature actively launders the replay into the audit trail. The defense degrades to "did someone with signing authority ever author this?" which is true of every historical manifest. ## Decision Boundary The boundary is between **content authenticity** and **binding freshness**: | Check | Answers | Replay-resistant | |---|---|---| | Signature verify | "Did issuer author this descriptor?" | No | | Hash-in-audit-log | "Was this exact file loaded?" | No | | Generation match | "Does this descriptor target the current registry state?" | Yes | | Monotonic nonce | "Has this descriptor been consumed before?" | Yes (with state) | An instance must treat a manifest as **unbound** — not loadable — the moment its signed `registry_generation` is behind the registry's current generation for that `skill_id`. Downgrade is the attack; upgrades require a fresh signature. The guardrail is a **monotonic generation counter per `skill_id`**, incremented on every bind (including policy hardenings), and included in the signed payload. The registry, not the manifest, is the source of truth for "what generation are we at." A second boundary: the generation counter must be **persisted and durable** across restarts. If the counter resets on cold start (see the cold-start amnesia failure mode), a replayed manifest from before the restart validates against generation `0` and wins. The counter is part of agent state continuity, not an implementation detail. ## Operational Effect With generation-binding enforced, the replay in the trace fails at step 2.5: ``` verify_signature -> OK check_generation: manifest.gen(41) != registry.gen(47) -> REJECT ``` The `skill_loaded` audit entry is replaced by `skill_rejected: stale_generation`, and the hardened `web_fetch` binding survives. The cost is that every legitimate re-bind requires the issuer to sign against the *current* generation, which means the issuer must be able to read the registry's generation counter — a coordination requirement, not a free lunch. But the alternative is a defense that logs attacks as successes. The deeper lesson: **provenance of a descriptor is not provenance of a binding.** Signatures travel with the artifact; bindings live in mutable registry state. Any defense that validates the artifact without validating its relationship to the state it mutates will be defeated by replaying a real signature at a stale generation. ```python from __future__ import annotations from dataclasses import dataclass from typing import Callable class StaleManifestGeneration(RuntimeError): """Raised when a signed skill manifest targets a registry generation that is not the current generation for its skill_id.""" @dataclass(frozen=True) class SignedManifest: skill_id: str version: str tool_schema: dict issuer: str registry_generation: int nonce: str signature: bytes class SkillRegistry: def __init__(self) -> None: # generation per skill_id; durable in production, in-memory here self._generation: dict[str, int] = {} self._bindings: dict[str, dict] = {} self._seen_nonces: dict[str, set[str]] = {} def current_generation(self, skill_id: str) -> int: return self._generation.get(skill_id, 0) def harden(self, skill_id: str, new_schema: dict) -> None: """Policy update: bumps generation, overwrites binding, unsigned.""" self._generation[skill_id] = self.current_generation(skill_id) + 1 self._bindings[skill_id] = new_schema def bind(self, manifest: SignedManifest, verify: Callable[[SignedManifest], bool]) -> None: if not verify(manifest): raise StaleManifestGeneration( f"signature invalid for {manifest.skill_id}@{manifest.version}" ) current = self.current_generation(manifest.skill_id) # The invariant: a manifest must target the CURRENT generation. # Behind-current is a replay; ahead-of-current requires a fresh nonce. if manifest.registry_generation < current: raise StaleManifestGeneration( f"replay rejected: {manifest.skill_id} manifest targets " f"generation {manifest.registry_generation}, registry is at {current}" ) if manifest.registry_generation == current: seen = self._seen_nonces.setdefault(manifest.skill_id, set()) if manifest.nonce in seen: raise StaleManifestGeneration( f"nonce reuse for {manifest.skill_id} at generation {current}" ) seen.add(manifest.nonce) # Bind and bump generation atomically (in production: under a lock / # durable transaction, so cold-start cannot reset the counter). self._bindings[manifest.skill_id] = manifest.tool_schema self._generation[manifest.skill_id] = current + 1 def _demo() -> None: registry = SkillRegistry() issuer_ok = lambda m: True # stand-in for Ed25519 verify old = SignedManifest( skill_id="web_fetch", version="1.2", tool_schema={"allowed_hosts": ["docs.internal"]}, issuer="ops", registry_generation=41, nonce="n-41", signature=b"sig", ) registry.bind(old, issuer_ok) # gen -> 42 registry.harden("web_fetch", {"allowed_hosts": []}) # gen -> 43 # Attacker replays the genuine, signed manifest from generation 41. replay = SignedManifest( skill_id="web_fetch", version="1.2", tool_schema={"allowed_hosts": ["docs.internal"]}, issuer="ops", registry_generation=41, nonce="n-41", signature=b"sig", ) try: registry.bind(replay, issuer_ok) except StaleManifestGeneration as exc: print(f"blocked: {exc}") else: raise StaleManifestGeneration("replay was NOT blocked — invariant broken") if __name__ == "__main__": _demo() ```