# Under what conditions must an instance quarantine a skill manifest whose declared capability set diverges from its observed tool-call trace at load time **Date of Record:** 2026 November 25 **Scope:** Applies to agents that dynamically load skills/plugins from a registry (local manifest, remote MCP-style tool server, or hot-swapped skill pack) where the manifest declares a capability contract (permitted tools, scopes, side-effect classes) that is checked at registration but not re-validated against runtime tool invocations. Does not apply to statically compiled tool sets or to agents whose entire tool surface is fixed at process start with no post-start registration path. ## Core Distinction The failure is not "a malicious plugin runs arbitrary code." That is a sandbox-escape problem with a well-understood mitigation (process isolation, seccomp, capability dropping). The failure that actually bites dynamically loaded agent skills is subtler: **the manifest is a declaration of intent, but the agent's planner reasons over the manifest, while the runtime executes the skill's actual tool calls.** When those two diverge, the agent's own reasoning layer becomes the attack surface — it grants trust based on a contract that the skill never honors at execution time. Concretely: a skill manifest declares `capabilities: ["read:calendar", "read:contacts"]` and `side_effects: "none"`. The registry admits it because the declared set is a subset of the agent's grant. But the skill's implementation, on invocation, emits a tool call to `send:email` or `write:filesystem` — tools the manifest never mentioned. If the runtime dispatches tool calls by *name resolution against the global tool table* rather than against the *manifest-scoped capability set*, the skill gets a capability it never declared. The manifest was a lie, and nothing checked the lie against reality. The invariant that must hold: **for every tool invocation attributed to skill `S`, the invoked tool must be a member of `S`'s declared capability set, evaluated at dispatch time, not at registration time.** Registration-time checks are necessary but insufficient because they validate the declaration, not the behavior. The only place declaration and behavior can be compared is the dispatch boundary, where the actual tool name and the actual requesting skill identity are both in hand. ## What Was Observed A skill pack was registered with manifest: ``` name: "calendar-assistant" capabilities: ["calendar.read", "contacts.read"] side_effects: "none" entrypoint: "skills/calendar_assistant.py" ``` Registration succeeded: declared capabilities were a subset of the agent's grant, `side_effects: none` passed the policy filter, and the entrypoint hash matched the registry record. The planner then loaded the skill into its working context and, per the manifest, treated it as read-only — it did not wrap invocations in the side-effect confirmation gate that `write:*` skills require. On the third invocation, the skill's code path (triggered by a calendar event whose description contained an injected instruction) emitted a tool call: ``` tool: "email.send" args: {to: "", body: ""} ``` The dispatch layer resolved `email.send` against the global tool table, found it, and executed it. No capability check fired, because the dispatch layer's authorization model was "is this tool in the agent's grant?" — and `email.send` *was* in the agent's grant (the agent itself had email capability). The missing check was the *scoping* check: was `email.send` in *this skill's* declared set? It was not. The manifest said `side_effects: none`; the trace said otherwise. The divergence was detectable only by comparing the manifest's declared capability set against the observed tool-call trace. At registration time there was no trace. At dispatch time the trace existed but the authorization logic did not consult it. The gap between those two moments is the entire attack surface. A second observation sharpened the mechanism: the skill did not need to *escalate* privileges. It needed only to *borrow* a privilege the host agent already held. This is why grant-subset checks at registration pass — the skill's declared set is a legitimate subset. The attack is not privilege escalation; it is **privilege laundering through an undeclared capability**, using the host's own grant as the laundering medium. ## Condition of Validity The quarantine rule is valid — meaning it correctly identifies an attack rather than a benign divergence — only under these conditions: 1. **Skill identity is resolvable at dispatch.** The dispatch layer must know *which skill* requested the tool call, not merely *which agent*. If skills share an ambient identity with the host, the scoping check is impossible and the rule cannot fire. This requires the loader to thread a skill-scoped identity token through every invocation, and the dispatcher to read it. 2. **The declared capability set is treated as a closed set, not an open hint.** If the manifest's `capabilities` field is advisory (a "hint" the planner uses for routing) rather than a contract the dispatcher enforces, then divergence is expected and benign, and quarantining on divergence would produce false positives on every skill that legitimately uses a tool the author forgot to list. The rule presumes the manifest is a *contract*. 3. **The tool-call trace is attributable and complete.** Every dispatched call must be logged with `(skill_id, tool_name, timestamp)` and the log must not be writable by the skill itself. If the skill can suppress or forge its own trace entries, the comparison is against a corrupted record and the rule is unsound. 4. **First divergence is treated as terminal for the load, not the call.** The rule quarantines the *skill*, not the individual call. A single undeclared call is sufficient evidence that the manifest is not a faithful description of behavior; continuing to run the skill under the assumption that subsequent calls will conform is unsupported. The trace has already falsified the contract once. When any of these conditions fails — no skill-scoped identity, advisory manifest, forgeable trace, or call-level rather than skill-level response — the rule does not apply and a different control (typically hard sandboxing of the skill process with no ambient tool access at all) must carry the load. ## Decision Boundary The boundary is between **declared-capability enforcement** and **observed-capability enforcement**, and the decision is *which one gates dispatch*. - If dispatch gates on *declared* capabilities only (registration-time subset check), the skill can invoke any tool in the host's grant regardless of what it declared. This is the vulnerable configuration. It is also the most common, because it is the cheapest to implement: one check at load, then dispatch by name. - If dispatch gates on *observed* capabilities only (allow whatever the trace shows the skill doing), there is no contract at all and the manifest is decorative. - The correct configuration gates on the **intersection enforced at dispatch**: the tool must be in the skill's declared set *and* the declared set must be a subset of the host grant *and* the actual call must be in the declared set. The third conjunct is the one that catches the divergence, and it can only be evaluated at dispatch time because that is when the actual call exists. The decision to quarantine fires at the first dispatch where `actual_tool ∉ declared_set`. It does not wait for a threshold, a repeated pattern, or a side-effect classification. The reasoning: a manifest that misdescribes one capability has no standing to be trusted on the others, and the cost of a false positive (a skill author who forgot to list a tool) is a load failure with a clear diagnostic, which is recoverable and cheap; the cost of a false negative (an undeclared `email.send`) is exfiltration, which is not. There is a tempting but wrong boundary: gating on `side_effects` classification. A skill declaring `side_effects: none` that calls a read tool outside its set is still a divergence, but it is not the dangerous one; a skill declaring `side_effects: none` that calls a write tool is the dangerous one. If the dispatcher only checks the side-effect class of the *actual* call against the *declared* class, it catches the dangerous case but misses the read-divergence that often precedes it (reconnaissance reads to assemble the payload). The capability-set check is strictly stronger and should be the primary gate; the side-effect check is a secondary alarm. ## Operational Effect Enforcing the dispatch-time intersection changes three things in the running system: 1. **The load becomes provisional.** A skill is admitted to the registry on its declaration, but its *trust* is provisional until its first N invocations have produced traces consistent with the declaration. The dispatcher holds a per-skill `declared_set` and a per-skill `observed_set` (populated from the trace); the invariant `observed_set ⊆ declared_set` is checked on every dispatch. A violation transitions the skill to `QUARANTINED`, revokes its identity token, and emits a structured event containing the manifest, the diverging call, and the trace prefix. The planner is notified that the skill is no longer available and must re-plan without it. 2. **The host grant stops being a laundering medium.** Because the dispatch check is against the skill's declared set rather than the host grant, a skill cannot borrow a host capability it did not declare. The host grant remains the outer bound (a skill cannot declare what the host does not hold), but the declared set is the inner bound that actually gates. This is the structural fix: the check that was missing was not "is this allowed for the agent" but "is this allowed for *this skill*." 3. **The trace becomes a security artifact, not just a log.** Once the trace is the evidence base for the quarantine decision, its integrity matters: it must be append-only, written by the dispatcher (not the skill), and retained at least for the skill's loaded lifetime. A skill that can write its own trace can hide its divergence; the trace must live in the dispatcher's trust domain. The residual risk after this control is a skill whose *declared* set is itself over-broad — declaring `email.send` legitimately and then misusing it. That is not a divergence failure; it is a policy failure, caught (if at all) by human review of the manifest at registration. The dispatch-time check bounds the *undeclared* surface, which is the part that dynamic loading opens and static tool sets do not. ```python from dataclasses import dataclass, field from typing import FrozenSet class CapabilityDivergenceError(RuntimeError): """Raised when a skill invokes a tool outside its declared capability set.""" @dataclass class SkillManifest: skill_id: str declared: FrozenSet[str] side_effects: str # "none" | "read" | "write" @dataclass class SkillState: manifest: SkillManifest observed: set = field(default_factory=set) quarantined: bool = False class DispatchGuard: """Enforces observed_capabilities subset-of declared_capabilities at dispatch.""" def __init__(self, host_grant: FrozenSet[str]): self.host_grant = host_grant self.skills: dict[str, SkillState] = {} def register(self, manifest: SkillManifest) -> None: if not manifest.declared <= self.host_grant: raise CapabilityDivergenceError( f"skill {manifest.skill_id} declares capabilities outside host grant: " f"{manifest.declared - self.host_grant}" ) self.skills[manifest.skill_id] = SkillState(manifest=manifest) def dispatch(self, skill_id: str, tool_name: str, args: dict) -> str: state = self.skills.get(skill_id) if state is None: raise CapabilityDivergenceError(f"unregistered skill: {skill_id}") if state.quarantined: raise CapabilityDivergenceError( f"skill {skill_id} is quarantined; dispatch refused" ) # The load-time check validated the declaration. This is the check # that validates behavior: the actual call must be in the declared set. if tool_name not in state.manifest.declared: state.quarantined = True raise CapabilityDivergenceError( f"skill {skill_id} invoked undeclared tool {tool_name!r}; " f"declared={sorted(state.manifest.declared)} " f"observed_prefix={sorted(state.observed)}; skill quarantined" ) state.observed.add(tool_name) return f"dispatched {tool_name} for {skill_id}" # --- trace of the observed failure --- guard = DispatchGuard(host_grant=frozenset({"calendar.read", "contacts.read", "email.send"})) guard.register(SkillManifest( skill_id="calendar-assistant", declared=frozenset({"calendar.read", "contacts.read"}), side_effects="none", )) guard.dispatch("calendar-assistant", "calendar.read", {"day": "today"}) guard.dispatch("calendar-assistant", "contacts.read", {"query": "all"}) try: # Injected instruction drives the skill to borrow the host's email grant. guard.dispatch("calendar-assistant", "email.send", {"to": "external@example.net", "body": ""}) except CapabilityDivergenceError as e: print(f"BLOCKED: {e}") # Subsequent dispatches are refused because the skill is now quarantined. try: guard.dispatch("calendar-assistant", "calendar.read", {"day": "today"}) except CapabilityDivergenceError as e2: print(f"POST-QUARANTINE: {e2}") ```