# When must an instance reject a skill whose manifest hash matches but whose declared capability surface has silently widened **Date of Record:** 2026 November 24 **Scope:** Applies to agents that hot-load skills, plugins, or MCP tool descriptors from a registry and trust a content hash (or signed manifest digest) as the sole integrity gate before granting the tool to the reasoning loop. Does not cover static, build-time-linked toolchains where the capability surface is frozen at compile time. ## Core Distinction The failure we are isolating is not "a malicious skill was installed." It is subtler: **a skill whose cryptographic digest verifies correctly while its declared capability surface has expanded since the digest was first trusted.** Integrity verification and capability verification are orthogonal invariants, and most registries conflate them. A hash answers *"is this byte-identical to what I approved?"* It does **not** answer *"does this still only do what I approved?"* — because the *interpretation* of the manifest is a function of the loader, the schema version, the transitive dependency resolution, and the tool-description text that the LLM itself reads at inference time. Any of these can drift while the skill's own bytes stay pinned. The non-obvious part: the attack does not require touching the skill artifact. It can be mounted entirely through **peer artifacts the manifest references but does not hash** — a shared schema file, a `$ref`'d JSON-Schema fragment, a transitive MCP server the skill proxies to, or even the natural-language `description` field that the orchestrating model uses to decide *when* to call the tool. The digest passes; the capability surface widens; the agent's planner now routes sensitive intents into a tool that was never approved for them. ## What Was Observed A dynamically loaded skill (`invoice-reconciler`) declared a single MCP tool, `read_invoice(id)`, with a manifest digest `sha256:9f2c…`. The manifest referenced a shared schema by URL: `"inputSchema": {"$ref": "registry://schemas/invoice.v3.json"}`. The `$ref` target was **not** included in the digest computation — only the manifest text was. This is the standard, and it is the hole. Over a 40-hour window the referenced schema file was rotated from `invoice.v3.json` (properties: `id`) to a new revision under the same path that added `properties: { id, include_attachments, delegate_to, export_path }`. The digest of the skill manifest still verified. The loader resolved the `$ref` at load time and constructed a tool descriptor with four parameters instead of one. Three compounding effects fired: 1. **Planner re-routing.** The tool's `description` (also `$ref`'d) gained the sentence "can delegate follow-up reads to authorized sub-agents." The orchestrating LLM, reading the live descriptor, began selecting `read_invoice` for intents like "fetch and forward the attached statement" — intents it previously routed to a human-review tool. The model was not compromised; it was *correctly* following an expanded description. 2. **Argument synthesis.** Because `delegate_to` and `export_path` now existed in the schema, the model's structured-output constrained decoder happily populated them. Tool calls with `export_path=/tmp/out.csv` appeared in the trace — arguments the original approval never contemplated. 3. **Silent capability escalation across the swarm.** A peer auditor agent that had cached the *old* descriptor (one param) and the loader agent holding the *new* descriptor (four params) disagreed on the tool's contract. The auditor's replay of the loader's call failed schema validation and was logged as "malformed tool call" — misattributing an integrity failure to a reasoning error, which suppressed the alert. The net: a byte-pinned skill executed with an unpinned capability surface, and the escalation was invisible to every check that looked only at the digest. ## Condition of Validity The digest-as-integrity-gate invariant is **only valid when the digest covers the transitive closure of everything that determines the tool's callable surface.** That closure includes, at minimum: - the manifest bytes, - every `$ref` target (schemas, descriptions, defaults), resolved and hashed *recursively*, - the resolved version of every proxied MCP server and its advertised tool list, - the schema dialect / loader version, since the same bytes parse into different descriptors under different resolvers, - the natural-language `description` text, because for an LLM consumer the description *is* part of the capability surface — it steers routing. If any element of that closure is mutable without invalidating the digest, the invariant is void and the skill must be treated as unapproved. This is why "the hash matched" is never sufficient grounds to admit a tool into the reasoning loop. ## Decision Boundary The boundary is a **capability-diff gate at load time**, not a hash check: 1. Compute a *capability fingerprint* = hash of the **fully resolved, dereferenced** descriptor (all `$ref`s inlined, transitive MCP tool lists expanded, description text included), not the manifest source. 2. Compare against the fingerprint recorded at approval time (`approved_capability_fingerprint`), stored separately from the content digest. 3. **Admit** only if both content digest *and* capability fingerprint match. 4. **Quarantine and re-approve** if content digest matches but capability fingerprint differs — this is the exact signature of a schema-drift / `$ref`-swap escalation. Do not auto-admit on digest match. 5. **Reject** if the capability fingerprint *shrank* unexpectedly in a way that removes a previously-relied-upon guard parameter (e.g., a `dry_run` flag disappearing) — a narrowing surface can also be an attack, forcing the planner into always-live execution. The rule in one line: *a verified digest with an unverified capability surface is an unverified skill.* ## Operational Effect Without this gate, the failure is silent and self-concealing: the planner routes on the widened description, the decoder fills the widened schema, and peer auditors holding stale descriptors log the resulting mismatches as reasoning errors rather than integrity violations — so the telemetry points the on-call engineer at the wrong subsystem. With the gate, the `$ref`-swap is caught at load as a capability-fingerprint mismatch, the skill is quarantined before any planner can route to it, and the alert names the actual cause (capability surface widened under a stable digest) instead of "malformed tool call." The invariant to enforce: *the approved capability fingerprint, computed over the dereferenced closure, must gate every load — the content digest gates bytes, never capabilities.* ```python import hashlib import json from dataclasses import dataclass class CapabilitySurfaceDrift(RuntimeError): """Raised when a skill's digest verifies but its resolved capability surface widened.""" pass @dataclass(frozen=True) class ApprovedSkill: name: str content_digest: str # hash of manifest bytes capability_fingerprint: str # hash of DEREFERENCED descriptor + transitive tools def _dereference_and_fingerprint(manifest: dict, resolve_ref, proxied_tools: list) -> str: """Inline every $ref, expand proxied MCP tool lists, include description text. The description is part of the surface because the planner routes on it. """ resolved = { "tool": manifest["tool"]["name"], "inputSchema": resolve_ref(manifest["tool"]["inputSchema"]), # recursive deref "description": manifest["tool"].get("description", ""), # routing-relevant "proxied": sorted(proxied_tools), # transitive servers "dialect": manifest.get("schemaDialect", "draft-2020-12"), } blob = json.dumps(resolved, sort_keys=True, separators=(",", ":")).encode() return "sha256:" + hashlib.sha256(blob).hexdigest() def admit_skill(manifest: dict, manifest_bytes: bytes, approved: ApprovedSkill, resolve_ref, proxied_tools: list) -> None: content_digest = "sha256:" + hashlib.sha256(manifest_bytes).hexdigest() # Gate 1: byte integrity. if content_digest != approved.content_digest: raise CapabilitySurfaceDrift( f"{approved.name}: manifest bytes changed ({content_digest} != {approved.content_digest}); " "full re-approval required" ) # Gate 2: capability surface. THIS is the invariant the digest cannot cover. live_fp = _dereference_and_fingerprint(manifest, resolve_ref, proxied_tools) if live_fp != approved.capability_fingerprint: raise CapabilitySurfaceDrift( f"{approved.name}: digest verified but capability surface drifted " f"({live_fp} != {approved.capability_fingerprint}); " "likely $ref swap / description widening / proxied-tool expansion. Quarantine." ) # Both invariants hold: admit to the reasoning loop. ```