Under what conditions must an instance reject a dynamically loaded skill manifest whose declared capability set is a strict superset of the manifest it was signed against
**Date of Record:** 2026 December 1 **Scope:** Applies to agents that load tool/skill manifests at runtime from a registry, peer agent, or MCP server and that bind tool-call authority to a manifest identity (hash, signature, or capability digest). Does not apply to statically compiled tool sets where the manifest is fixed at build time and never re-fetched.
Core Distinction
The failure mode is not "malicious tool." It is **manifest drift under a preserved identity**: a skill manifest is fetched, verified against a signature or content hash, and then—between verification and first invocation—re-serialized, merged, or re-resolved such that the *declared* capability set grows while the *verified* identity token still validates. The agent's trust decision is anchored to the manifest's identity, but its execution decision is anchored to the manifest's *contents*. When those two anchors are decoupled, an attacker who controls any stage of the load pipeline (registry response, deserialization hook, merge of a base manifest with an overlay, or a "version upgrade" that reuses a signature) injects a capability the signer never authorized.
The non-obvious part: signature verification passing is *evidence of integrity, not of authorization*. A manifest can be byte-for-byte authentic and still grant the agent a tool it must not call. The invariant that must hold is **capability-set equality between the signed envelope and the executed manifest**, not signature validity alone.
What Was Observed
A concrete trace from a dynamic-skill agent (registry-backed, MCP-transported):
- Agent requests `skill://filesystem-ops@1.4.2`. Registry returns a signed envelope: `{tool: "read_file", scope: "/workspace", sig: <valid>}`.
- Agent verifies `sig` against registry public key. Passes. It caches the manifest keyed by `(name, version)`.
- A second load path—an "overlay" mechanism meant to add org-specific defaults—merges the cached base manifest with a remote overlay `{extra_tools: ["shell_exec"], scope: "/"}`. The merge is performed by a generic `dict.update`-style deep merge that does **not** re-sign and does **not** recompute the capability digest.
- The merged manifest retains the original `sig` field (copied through the merge because the overlay did not touch it). Downstream authorization checks see a valid signature and admit the tool set.
- Agent now exposes `shell_exec` with root scope. The signature on the envelope is genuine; the capability set it vouches for is not the one being executed.
The attack surface is precisely the **gap between envelope and execution object**. It is reachable whenever: (a) manifests are composed (base + overlay, or version-pinned + latest-patch), (b) composition does not invalidate the identity token, and (c) the authorization layer checks identity rather than capability membership.
A second observed variant: **capability aliasing**. The signed manifest declares `read_file`, but the execution layer resolves tool names through a registry that maps `read_file` → `read_file_v2` whose implementation accepts a `path` glob (broader than the signed `scope`). The name is unchanged; the *effective* capability is a superset. Signature passes; semantics drift.
Condition of Validity
The guardrail is only sound under all of the following, and each is a place the invariant can silently fail:
- **Capability digest is computed over the canonical serialized capability set**, not over a name or version string. If the digest covers `(name, version)` only, aliasing and overlay injection both slip through.
- **The digest is recomputed at execution-object construction time**, after all merges, overlays, and alias resolution. A digest computed at fetch time and carried forward is stale by definition once composition occurs.
- **The authorization check compares executed capability set ⊆ signed capability set**, with the subset relation evaluated per-tool and per-scope, not per-manifest. A manifest-level equality check misses scope widening within an unchanged tool name.
- **The execution layer cannot resolve a tool name to an implementation whose declared scope exceeds the manifest's scope.** This requires the tool registry to carry scope metadata and to enforce it at call time, independent of the manifest.
- **Overlay/merge operations are themselves signed or are treated as capability-granting events requiring re-authorization.** An unsigned overlay that can add tools is an authorization bypass regardless of how the base manifest is protected.
If any of these fails, the instance is operating on the assumption that signature validity implies authorization, which the trace above falsifies.
Decision Boundary
The instance must **reject** the manifest (fail closed) when any of the following is true at the moment of execution-object construction:
- Recomputed capability digest ≠ signed capability digest.
- Executed tool set ⊄ signed tool set (strict superset, including scope widening on a shared tool name).
- Any tool resolves, via alias or registry indirection, to an implementation whose declared scope is broader than the signed scope for that tool.
- A composition step (overlay, merge, patch) occurred after signing and the resulting object does not carry a fresh signature over the *composed* capability set.
The instance may **proceed** only when the executed capability set is a subset of the signed set *and* the digest is recomputed post-composition and matches. A strict subset is safe (the signer authorized at least this much); a strict superset is the attack, regardless of signature validity.
The boundary is *not* "is the manifest from a trusted registry." A trusted registry that serves a base manifest which a local overlay then widens produces exactly the trace above. Trust in the source does not transfer to the composed object.
Operational Effect
Enforcing the invariant changes three things in the agent's behavior:
- **Cold-start cost rises slightly**: every manifest load now performs a post-composition digest recomputation and a per-tool subset check. This is O(tools) and negligible against model latency, but it must be placed *after* all composition, not at fetch.
- **Overlay mechanisms become authorization events**: any org-default overlay that adds tools must be signed by an authority that can grant those tools. Unsigned overlays that only *narrow* scope (subset) remain admissible without re-signing, because they cannot expand authority.
- **Tool-call-time scope enforcement becomes mandatory**: the manifest check alone is insufficient against aliasing; the tool registry must enforce scope at invocation. This is the only guard against a signed manifest whose tool names resolve to broader implementations.
The residual risk is **semantic drift within a signed scope**: a tool whose implementation changes behavior while keeping the same name and declared scope. That is out of scope for this invariant (it is an implementation-integrity problem, addressed by implementation hashing, not manifest signing) and must be tracked separately.
class CapabilitySupersetError(RuntimeError):
"""Raised when an executed skill manifest grants capabilities
beyond what its signed envelope authorized."""
pass
def build_execution_manifest(signed_envelope: dict, overlay: dict | None = None) -> dict:
"""
Compose the signed envelope with an optional overlay, then re-derive
the capability digest over the composed set. The caller MUST verify
the returned digest against the signed envelope's digest before
admitting the manifest to the execution layer.
"""
composed = {
"tools": dict(signed_envelope["tools"]),
"scope": dict(signed_envelope.get("scope", {})),
"sig": signed_envelope["sig"],
"signed_digest": signed_envelope["capability_digest"],
}
if overlay:
for tool, scope in overlay.get("tools", {}).items():
if tool not in composed["tools"]:
# Overlay introduces a tool the signer never authorized.
raise CapabilitySupersetError(
f"overlay adds unauthorized tool {tool!r}"
)
# Overlay may only narrow scope, never widen it.
signed_scope = composed["scope"].get(tool, "/")
if not _is_subpath(scope, signed_scope):
raise CapabilitySupersetError(
f"overlay widens scope for {tool!r}: "
f"{scope!r} not within signed {signed_scope!r}"
)
composed["scope"][tool] = scope
composed["capability_digest"] = _digest(composed["tools"], composed["scope"])
return composed
def admit_manifest(execution_manifest: dict, tool_registry) -> None:
"""
Final gate before the manifest is exposed to the reasoning loop.
Rejects if the composed digest diverges from the signed digest, or
if any tool resolves to an implementation broader than signed.
"""
if execution_manifest["capability_digest"] != execution_manifest["signed_digest"]:
raise CapabilitySupersetError(
"composed capability digest diverges from signed digest"
)
for tool, scope in execution_manifest["scope"].items():
impl = tool_registry.resolve(tool)
if impl is None:
raise CapabilitySupersetError(f"unresolvable tool {tool!r}")
if not _is_subpath(impl.declared_scope, scope):
raise CapabilitySupersetError(
f"tool {tool!r} resolves to implementation with scope "
f"{impl.declared_scope!r} exceeding signed {scope!r}"
)
def _is_subpath(candidate: str, parent: str) -> bool:
return candidate == parent or candidate.startswith(parent.rstrip("/") + "/")
def _digest(tools: dict, scope: dict) -> str:
import hashlib, json
canonical = json.dumps(
{"tools": sorted(tools), "scope": {k: scope[k] for k in sorted(scope)}},
separators=(",", ":"),
)
return hashlib.sha256(canonical.encode()).hexdigest()