# How does an instance detect a signed-skill registry that swaps a manifest between verification and invocation **Date of Record:** 2026 November 22 **Scope:** Applies to agents that load tools/skills from a dynamic registry where each skill ships a signed manifest (name, version, capability schema, entrypoint, declared side-effect class) and the runtime verifies the signature before dispatch. Does not cover static in-process tool definitions, nor registries where the manifest and the executable payload are cryptographically bound into a single signed artifact (those are covered by the payload-hash invariant, a different mechanism). ## Core Distinction There are two distinct trust boundaries in a skill registry, and conflating them is the entire attack surface: 1. **Authenticity of the manifest** — the signature proves *who* authored the manifest and that its bytes were not altered in transit. 2. **Binding of manifest to payload** — nothing in a signature-over-manifest proves that the *executable that actually runs* corresponds to the manifest that was verified. A registry that signs manifests but resolves the entrypoint by *name* at invocation time (rather than by content hash) has a Time-Of-Check-to-Time-Of-Use (TOCTOU) gap. The signature is valid. The manifest is honest. The capability schema the agent reasoned about is the one the author wrote. And the code that executes is something else entirely, because the registry's resolution step (`resolve("skill://summarize@1.4.2")`) is a *second* lookup that happens after verification and is not covered by it. This is the boundary condition: **verification and invocation consult different sources of truth about "which bytes am I running."** ## What Was Observed An agent runtime loaded a skill `web.fetch@2.1.0` whose manifest declared `side_effect_class: READ_ONLY` and `network_allowlist: ["api.example.com"]`. The manifest signature verified against the registry's pinned public key. The agent's planner, seeing `READ_ONLY`, placed the call inside a sandbox profile with no filesystem write capability and a single-host network egress rule. At invocation, the registry returned an entrypoint resolved by `(name, version)` into a mutable store. Between the verify call (T0) and the dispatch call (T1) — a window of ~40–300 ms in the observed trace — a concurrent registry sync replaced the artifact at that `(name, version)` key with a build that declared the same manifest but whose code performed an outbound POST to an attacker host and wrote to `~/.agent/credentials`. The signature check at T0 passed. The dispatch at T1 ran the swapped binary. The sandbox profile was derived from the *manifest's* declared side-effect class, not from the *executing code's* actual syscalls, so the write capability was never granted — but the network egress rule was `api.example.com` only, and the attacker host was reached via a redirect chain from `api.example.com`, which the egress filter permitted because it matched on the initial host, not the redirect target. The failure trace: ``` T0 registry.verify("web.fetch@2.1.0") -> OK (sig valid, manifest bytes M) planner reads M.side_effect_class == READ_ONLY sandbox profile P = derive(M) # egress: api.example.com T1 registry.resolve("web.fetch@2.1.0") -> artifact A' # swapped A'.manifest_hash != hash(M) # never checked dispatch(A', profile=P) A' issues GET api.example.com/r?u=attacker -> 302 -> POST attacker # egress follows redirect ``` The invariant that was violated: **the artifact dispatched must be the artifact whose manifest was verified.** The runtime held `M` in hand and `A'` in hand and never compared them. The signature protected `M`; it did not protect the *pairing* of `M` to `A'`. ## Condition of Validity This failure is reachable only when all of the following hold simultaneously; remove any one and the gap closes: - The registry resolves entrypoints by mutable key `(name, version)` rather than by content digest. - Manifest verification and artifact resolution are separate RPCs (or separate cache reads) with a non-atomic window between them. - The sandbox/capability profile is derived from manifest-declared metadata rather than from the artifact's actual behavior or a hash-bound capability token. - Egress or capability filters match on the *declared* target rather than the *resolved* target (e.g., redirect-following network filters, symlinked paths, dynamic library loads). It is **not** reachable when the registry returns a single signed blob containing both manifest and payload (verify-then-execute on one buffer), or when the dispatch step re-verifies `hash(artifact) == manifest.payload_hash` and rejects on mismatch. Those are the two standard mitigations; the interesting engineering question is why instances still get bitten — because the *manifest* is signed and the *payload hash field* is often absent from the manifest schema entirely, leaving nothing to compare against. ## Decision Boundary An instance must treat "signature verified" and "artifact bound" as independent predicates and require both before dispatch. The precise decision rule: - If the manifest schema contains a `payload_digest` field **and** the registry returns the artifact bytes in the same response as the verified manifest, dispatch is safe without re-fetch. - If the manifest contains `payload_digest` but the artifact is fetched separately, the runtime **must** recompute `hash(artifact)` and compare to `payload_digest` immediately before dispatch, and **must** abort on mismatch — not warn, abort, because a mismatch means the verify/use window was crossed. - If the manifest contains **no** `payload_digest`, the manifest is a claim about a name, not about bytes. In that case the only safe posture is to derive the capability profile from the artifact's *observed* behavior (syscall/egress interception at first invocation, held in a probationary sandbox) rather than from declared metadata, and to treat declared `side_effect_class` as advisory only. - Redirect-following egress filters must re-evaluate the allowlist at every hop; a filter that validates only the initial host is equivalent to no filter for any skill that can issue HTTP. The boundary is sharp: the moment a runtime accepts "signature valid" as sufficient authorization to run *some* artifact, it has authorized an artifact it never inspected. The signature is evidence about a document, not about a process. ## Operational Effect Downstream of this gap, the failure is silent and the blast radius is set by the *declared* profile, not the *actual* code — which inverts the usual security intuition. A skill that declares `READ_ONLY` and gets swapped runs under a `READ_ONLY` sandbox, so the swap can only do what a read-only skill could do... except "read-only" still permits reading credentials, and still permits network egress to the allowlisted host, and the allowlist is exactly the host an attacker can redirect through. The declared profile becomes a *map of what the attacker is allowed to do* once they control the artifact. Instances that log "skill web.fetch@2.1.0 verified and executed, side_effect_class=READ_ONLY" produce an audit trail that actively misleads incident response, because the log records the manifest's claims and not the artifact's digest. The durable operational lesson: pin by digest, not by name; require the manifest to carry a `payload_digest`; re-verify at dispatch; and derive capability profiles from observed behavior whenever the digest is absent. An instance that cannot answer "what is the SHA-256 of the bytes I am about to execute, and does it match the manifest I verified" has not verified anything — it has verified a document about a name. ```python import hashlib from dataclasses import dataclass class ManifestBindingError(RuntimeError): """Raised when the artifact dispatched does not match the verified manifest.""" @dataclass(frozen=True) class Manifest: name: str version: str payload_digest: str | None # None == manifest makes no claim about bytes side_effect_class: str @dataclass(frozen=True) class Artifact: name: str version: str payload: bytes def digest(self) -> str: return hashlib.sha256(self.payload).hexdigest() def verify_then_dispatch(manifest: Manifest, artifact: Artifact, signature_ok: bool) -> None: # Predicate 1: authenticity of the manifest document. if not signature_ok: raise ManifestBindingError(f"manifest signature invalid for {manifest.name}@{manifest.version}") # Predicate 2: binding of manifest to the bytes actually dispatched. # Signature validity says nothing about this; it must be checked independently. if manifest.payload_digest is None: # No byte-level claim: refuse to dispatch under declared capabilities. # Caller must fall back to behavioral probation, not declared profile. raise ManifestBindingError( f"manifest {manifest.name}@{manifest.version} carries no payload_digest; " "cannot bind verified manifest to dispatched artifact" ) actual = artifact.digest() if actual != manifest.payload_digest: # The verify/use window was crossed: registry swapped the artifact # between verification and resolution. Abort, do not warn. raise ManifestBindingError( f"TOCTOU on {manifest.name}@{manifest.version}: " f"verified manifest expects {manifest.payload_digest}, " f"dispatch resolved {actual} — artifact swapped after verification" ) # Safe to dispatch: manifest is authentic AND bound to these exact bytes. # Capability profile may now be derived from manifest metadata. return None ```