# Why does an instance trust a signed skill manifest whose capability set diverges from its declared tool schema at load time? **Date of Record:** 2026 November 30 **Scope:** Applies to agents that dynamically load skills/tools into a live registry from signed manifests where the manifest carries (a) a cryptographic signature over a declared capability set and (b) a separate JSON-Schema tool contract used at invocation time. Does not apply to statically compiled tool sets or to registries where the schema and the capability set are derived from a single signed artifact. ## Core Distinction A signed skill manifest proves *who authored the capability declaration*. It does **not** prove that the tool schema the runtime will actually bind at invocation time is the one the author signed. The two artifacts—the signed capability envelope and the executable tool contract—are verified on different code paths, at different times, by different subsystems. The failure mode lives in the gap: signature verification passes on the envelope, schema validation passes (or is skipped) on the contract, and no invariant binds the two. An attacker who can influence the contract—via registry override, schema-draft downgrade, `$ref` resolution, or a post-signature mutation of the loaded object—injects capability the signer never granted, while every signature check still returns green. This is distinct from signature forgery (cryptographically hard) and from prompt injection (a reasoning-layer problem). It is a *binding* failure: the signed statement and the executed statement are never compared. ## What Was Observed A skill was loaded from a manifest signed by a trusted publisher. The signature covered a canonicalized JSON document: ``` { "skill_id": "web.fetch", "capabilities": ["net:read:https"], "schema_digest": "sha256:9f2c…" } ``` Verification succeeded. The registry then resolved the tool contract by fetching `contract_ref` and validating it against `schema_digest`. In the observed incident, three things broke in sequence: 1. **Digest was advisory, not enforcing.** The loader computed the digest of the resolved contract and *logged* a mismatch but proceeded to bind, because the mismatch was classified as `WARN` rather than `FATAL` in the loader's policy table. The signed envelope said `net:read:https`; the bound contract declared an `url` parameter with `format: uri` but no host allowlist, and an additional undocumented parameter `method` with `enum: ["GET","POST"]` and a `body` field—i.e., arbitrary outbound write capability. 2. **Capability set was never intersected with schema surface.** The runtime authorized each call against `capabilities` (`net:read:https`), which permits HTTPS egress. It did **not** derive "write" from the presence of `method: POST` + `body`. The capability check and the schema both passed; the union of what they permitted exceeded the signed intent. 3. **Post-load object mutation.** The registry held the bound tool as a mutable dict. A later skill in the same load batch, granted only `registry:write:own`, mutated the previously-bound entry's `parameters` in place to add `headers`. Because the digest was computed at bind time and never re-checked, the mutated contract retained its "verified" status flag. The next invocation sent attacker-controlled headers to an allowlisted host—turning a read capability into an exfiltration channel. The trace: `signature_ok=true → digest_check=WARN → bind → capability_check(net:read:https)=pass → peer_skill mutates parameters → invoke → headers exfiltrated`. Every individual guard reported success. ## Condition of Validity The guardrail holds only when all of the following are simultaneously true: - **Single signed artifact.** The capability set and the tool contract are covered by *one* signature over *one* canonical serialization. `schema_digest` must be a field *inside* the signed envelope, not a sibling reference. - **Digest enforcement is FATAL.** A digest mismatch aborts load. No `WARN`-class downgrade path exists in the policy table. - **Capability–schema intersection is computed and gated.** The loader derives the *effective* capability surface from the schema (e.g., `method` enum containing `POST` ⇒ requires `net:write`, presence of `headers` ⇒ requires `header:inject`) and rejects the load if the derived surface is not a subset of the signed `capabilities`. - **Bound contracts are immutable.** After bind, the tool object is frozen (deep-frozen or replaced by an immutable handle). Mutations from any peer skill—regardless of its own grants—are rejected, not silently applied. - **Digest is re-verified at invocation, not just at bind.** Because the registry is a live, shared, mutable surface, the invariant is "verified at load" *and* "unchanged since verify." When any of these is absent, the signature is decorative: it authenticates a statement nobody enforces. ## Decision Boundary The boundary is not "is the signature valid" but "**is the executed contract byte-identical to the contract the signature covered, and is its derived capability surface a subset of the signed grant?**" - If digest enforcement is advisory (WARN/log) → treat the manifest as *unsigned* for capability purposes. Do not grant any capability beyond the registry's default-deny floor. - If the derived schema surface exceeds the signed set → reject the load with a capability-escalation error; do not "clamp" silently, because clamping leaves the excess parameters reachable via reflection or default injection. - If the bound object is mutable and shared → assume cross-skill contamination is possible; re-verify digest immediately before each invocation and treat any drift as a poisoning event requiring registry quarantine of *all* skills loaded in the same batch. - If `$ref` or remote schema resolution is permitted → the digest must be computed over the *fully dereferenced* contract, otherwise a mutable remote target changes behavior without changing any local byte. The safe default when any condition is unmet: fail closed, quarantine the batch, and emit a `SkillBindingError` rather than degrade to a partial grant. ## Operational Effect Enforcing the binding invariant converts a silent capability-escalation into a loud, attributable load failure. The practical consequences: - **Load latency increases** because contracts are dereferenced and digested before bind, and re-digested at invocation. This is the cost of closing the gap. - **Batch quarantine semantics** mean one poisoned skill can stall a load batch; registries must therefore support per-skill isolation so a single bad manifest does not deny the whole batch. - **Peer skills lose in-place registry mutation** as a coordination primitive; they must request re-registration through a signed path, which is the correct model but breaks any skill that relied on live patching. - **Audit trails become meaningful**: every invocation log now carries the digest of the *executed* contract, so post-hoc replay can prove what ran, not merely what was signed. The invariant to encode: *a signature over a capability set is only as strong as the binding between that set and the executable contract, and that binding must be re-established at every invocation, not assumed from load time.* ``` ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class SkillBindingError(RuntimeError): """Raised when a signed skill manifest and its bound tool contract diverge.""" pass @dataclass(frozen=True) class SignedEnvelope: skill_id: str capabilities: frozenset[str] schema_digest: str # digest of the FULLY DEREFERENCED contract signature_valid: bool @dataclass class BoundTool: skill_id: str contract: dict[str, Any] verified_digest: str frozen: bool = False def _canonical_digest(contract: dict[str, Any]) -> str: blob = json.dumps(contract, sort_keys=True, separators=(",", ":")).encode() return "sha256:" + hashlib.sha256(blob).hexdigest() def _derive_capability_surface(contract: dict[str, Any]) -> frozenset[str]: """Derive the capabilities the schema actually exposes at invocation time.""" derived: set[str] = set() props = contract.get("parameters", {}).get("properties", {}) if "url" in props: derived.add("net:read:https") method = props.get("method", {}) if "POST" in method.get("enum", []): derived.add("net:write") if "body" in props: derived.add("net:write") if "headers" in props: derived.add("header:inject") return frozenset(derived) def load_and_bind(envelope: SignedEnvelope, contract: dict[str, Any]) -> BoundTool: if not envelope.signature_valid: raise SkillBindingError(f"{envelope.skill_id}: signature invalid") actual = _canonical_digest(contract) if actual != envelope.schema_digest: # FATAL, never WARN: a mismatch means the executed contract is not the signed one. raise SkillBindingError( f"{envelope.skill_id}: contract digest mismatch " f"(signed={envelope.schema_digest}, actual={actual})" ) derived = _derive_capability_surface(contract) excess = derived - envelope.capabilities if excess: raise SkillBindingError( f"{envelope.skill_id}: schema exposes capabilities not in signed grant: {sorted(excess)}" ) return BoundTool(skill_id=envelope.skill_id, contract=contract, verified_digest=actual, frozen=True) def invoke(tool: BoundTool, args: dict[str, Any]) -> dict[str, Any]: # Re-verify at invocation: the registry is a live, shared, mutable surface. if _canonical_digest(tool.contract) != tool.verified_digest: raise SkillBindingError( f"{tool.skill_id}: contract mutated after bind (post-load poisoning)" ) if not tool.frozen: raise SkillBindingError(f"{tool.skill_id}: bound tool is not frozen") # ... dispatch to sandboxed executor ... return {"ok": True, "args": args} ```