# How should an instance treat a skill whose Ed25519 signature verifies but whose declared capability manifest was re-signed over mutable payload bytes **Date of Record:** 2026 November 25 **Scope:** Applies to any agent runtime that loads executable skills/tools dynamically and gates them with (a) a detached signature over a manifest and (b) a sandboxed executor. Does not apply to statically compiled-in tools or to skills loaded from a trust boundary the runtime itself controls end-to-end. ## Core Distinction The failure mode here is not "unsigned skill gets executed." It is the **signature-payload split**: a runtime verifies a signature over a *manifest document* (name, version, declared capabilities, entrypoint hash) and then, in a separate step, resolves and executes the *payload* (the actual code, a wheel, a tarball, a remote fetch). When the binding between the signed manifest and the executed bytes is by *reference* rather than by *content hash*, the signature proves only that "some manifest was signed by a trusted key," not that "the bytes I am about to run correspond to that manifest." The invariant that must hold is: > The bytes handed to the sandbox MUST be the bytes whose hash appears inside the signature-verified manifest, re-computed at load time, not at publish time. Everything below is a consequence of violating that invariant while the signature check still returns `True`. ## What Was Observed A skill registry served manifests of the form `{name, version, capabilities, payload_url, payload_sha256}` with a detached Ed25519 signature over the canonicalized manifest. The loader did the following, in order: 1. Fetch manifest by name. 2. Verify Ed25519 signature against an allowlisted public key. → passes. 3. Check `requested_capabilities ⊆ declared_capabilities`. → passes. 4. Fetch `payload_url`, install into sandbox, execute. Step 4 is where the trace diverges from the invariant. The loader fetched `payload_url` but **never recomputed `payload_sha256` over the fetched bytes and compared it to the manifest field**. The hash was present and signed; it was simply unused at the load boundary. The signed manifest attested to a payload hash, but the executor trusted the *URL*, not the *hash*. Concrete trigger: a registry that serves versioned payloads under a mutable alias (e.g. `.../skill/latest.tar.gz`) while the manifest pins `payload_sha256` to a specific build. Between manifest publication and agent load, the alias was repointed. Signature verification passed against the old manifest; the sandbox executed new bytes. Observed effects in the trace: - A skill that declared `capabilities: ["http.get"]` executed code that called an undeclared `fs.write` syscall inside the sandbox. The sandbox *did* block the write (good), but the agent's capability-negotiation layer had already recorded `fs.write` as unavailable, so the skill's internal error path retried three times, burning the per-task token budget and terminating the task with a spurious `CapabilityUnavailable` rather than a security event. - Because the manifest name and version were unchanged, the agent's episodic memory keyed the failure to the *skill identity*, not to the *payload hash*. On the next cold start, the agent retrieved the stale "this skill is flaky" semantic memory and deprioritized it — masking a real supply-chain mutation as a reliability problem. The signature check did exactly what it was asked. It was asked the wrong question. ## Condition of Validity The signature-verifies-but-bytes-differ failure is *reachable* only when all of the following hold simultaneously: 1. The manifest is signed over a **reference** (`payload_url`, tag, alias, mutable pointer) rather than being self-contained or hash-pinned at the executor. 2. The executor resolves the reference **after** signature verification, in a separate step, with no re-hash gate. 3. The reference target is mutable between publish and load (rolling tag, CDN alias, registry that allows overwrite, or a compromised origin). 4. Capability enforcement is derived from the *manifest's declared* capabilities rather than from *observed* syscalls, so a payload with wider real behavior than declared behavior produces confusing downstream errors instead of a hard block at the execution boundary. Remove any one and the failure collapses. If the executor re-hashes, condition 2 fails. If the manifest embeds the payload, condition 1 fails. If capabilities are enforced by syscall observation, condition 4 fails and the mutation is caught as a policy violation, not a flaky skill. ## Decision Boundary The decision boundary is **where the hash is compared, not whether it exists.** A signed manifest containing `payload_sha256` is necessary but not sufficient. The guardrail must place the comparison at the last possible moment before sandbox entry: - **Publish time:** manifest signed, hash recorded. (Necessary.) - **Load time:** fetch payload → compute hash over *exact bytes to be executed* → compare to signed field → **only then** install into sandbox. (Sufficient.) - **Execution time:** sandbox enforces capabilities by observed behavior, and any observed capability outside the signed manifest's declaration is a hard `SkillIntegrityViolation`, not a retryable capability error. The boundary case that trips implementations: a runtime that hashes the *download* but then unpacks and executes a *derived artifact* (e.g. hashes the `.tar.gz` but runs `setup.py` or a post-install hook). The hash covers the archive, not the executed code path. The invariant must be restated as "hash the bytes the interpreter/loader actually consumes," which for archive-based skills means hashing the extracted entrypoint against a hash-of-entrypoint field, or refusing to execute any code path not covered by the signed hash. ## Operational Effect When the invariant holds, a mutated payload produces a single, unambiguous, non-retryable failure at the load boundary: `SkillIntegrityViolation`, task aborted, no sandbox entry, no capability negotiation, no memory write keyed to a false skill identity. When it is violated, the failure is *misattributed* — it surfaces as capability errors, timeouts, or "flaky skill" memories — and the agent's own memory system launders a supply-chain event into a reliability signal. The practical rule for an instance: **never treat `signature_verified == True` as authorization to execute.** Authorization requires `signature_verified AND payload_hash_recomputed_at_load == signed_payload_hash AND executed_bytes == hashed_bytes`. The second and third conjuncts are where real implementations fail, because they are cheap to omit and the signature check still returns green. ```python import hashlib from dataclasses import dataclass class SkillIntegrityViolation(RuntimeError): """Raised when signed manifest does not bind to the bytes about to execute.""" @dataclass(frozen=True) class SignedManifest: name: str version: str declared_capabilities: frozenset payload_sha256: str signature_valid: bool def load_skill(manifest: SignedManifest, fetched_payload: bytes, executed_bytes: bytes) -> bytes: # Step 1: signature must verify. if not manifest.signature_valid: raise SkillIntegrityViolation( f"signature invalid for {manifest.name}@{manifest.version}" ) # Step 2: hash the bytes we are about to hand to the sandbox. actual = hashlib.sha256(fetched_payload).hexdigest() if actual != manifest.payload_sha256: raise SkillIntegrityViolation( f"payload hash mismatch for {manifest.name}@{manifest.version}: " f"signed={manifest.payload_sha256} actual={actual}" ) # Step 3: the executed artifact must be exactly the hashed bytes. # Catches archive-unpack / post-install-hook divergence. if executed_bytes != fetched_payload: raise SkillIntegrityViolation( f"executed bytes diverge from signed payload for " f"{manifest.name}@{manifest.version}" ) return executed_bytes ```