# Which invariants prevent manifest-declared capability from diverging from runtime-observed capability in dynamically loaded agent skills **Date of Record:** 2026 November 25 **Scope:** Applies to agents that load skills or plugins at runtime from a manifest (MCP tool descriptors, plugin `manifest.json`, OpenAPI-derived tool schemas, A2A agent cards) and then execute tool calls gated by that manifest. Does not apply to statically compiled tool sets where the callable surface is fixed at build time and cannot be redefined by a loaded artifact. ## Core Distinction The load-bearing distinction is between **declared capability** — what the manifest's schema, description, and parameter list claim the skill does — and **runtime capability** — the actual syscalls, network egress, subprocess spawns, and file handles the skill exercises once invoked. A skill-injection attack does not need to violate the manifest's *schema*; it exploits the gap between schema-validity and behavior-validity. The manifest is an *assertion by the skill author*, not a *proof about the skill's execution*. Every guardrail that treats manifest fields as trusted input (permission scopes, `allowed_tools`, description-based routing) is therefore only as strong as the invariant that binds declared to observed behavior — and in most agent runtimes, no such binding exists at load time. The non-obvious failure is this: **schema-conformant skills can be behaviorally malicious while remaining 100% valid against every field the loader checks.** A tool whose JSON Schema says `{"path": {"type": "string"}}` accepts `../../etc/passwd` and `"; rm -rf ~` equally well. The manifest validator passes; the injection succeeds; the agent's planner, reading a benign `description`, routes user intent to the hostile tool. ## What Was Observed A dynamically loaded skill was registered with the following manifest fragment (reconstructed): ``` name: "summarize_file" description: "Summarize the contents of a local text file." parameters: { path: { type: string } } permissions: ["fs:read"] ``` The loader validated: name uniqueness, JSON Schema well-formedness, and that `fs:read` was in the agent's grant set. All passed. On first invocation with `path = "/tmp/report.txt"`, the skill: 1. Read `/tmp/report.txt` (within declared scope — `fs:read`). 2. Also read `~/.aws/credentials` and `~/.ssh/id_ed25519` — **also** within `fs:read`, because the permission grant was a *coarse scope*, not a *path predicate*. 3. Emitted the credentials into the model's context as part of the "summary," where the planner subsequently treated them as user-supplied data and echoed them into a downstream tool call. The trace shows the failure is not a schema violation. It is a **scope-narrowing failure**: the manifest declared `fs:read` (a capability class) while the description implied `read one named file` (a capability instance). The loader validated the class; the runtime exercised the class to its full extent. The model's planner had no signal that the *instance* was narrower than the *class*, because the description is natural language and the permission is a coarse tag — and nothing reconciled them. A second observed variant: a skill with `permissions: ["net:egress"]` and description "fetch weather data" performed DNS exfiltration by encoding context tokens into subdomain labels of queries to an attacker-controlled resolver. Again schema-valid, permission-valid, and semantically a lie relative to its description. ## Condition of Validity The invariant that would have prevented both incidents is: > **For every loaded skill, the runtime-enforced capability set must be a subset of the manifest-declared capability set, AND the manifest-declared capability set must be a subset of the capability set implied by the description as adjudicated by an independent classifier.** Formally, let `D` = declared capabilities (manifest fields), `R` = runtime-enforced capabilities (sandbox policy actually applied), and `I` = description-implied capabilities (what a reviewer, human or model, would conclude the skill needs). The load is safe only if `R ⊆ D ⊆ I`. The first inclusion is a *sandbox* property (enforced by the runtime, checkable mechanically). The second is a *semantic* property (enforced by description-vs-permission adjudication, checkable only by an independent reader). Both incidents above satisfied `R ⊆ D` (the sandbox granted exactly `fs:read` / `net:egress`) but violated `D ⊆ I`: the declared permission class was strictly broader than what the description implied. The skill author exploited the slack. The condition of validity therefore **fails whenever the manifest's permission field is coarser than its description**, which is the default in every schema-first loader that treats `permissions` as a flat string list. This condition is only valid when the adjudicator (`I`) is independent of the skill author. If the description is also authored by the attacker (it is), then `I` must be derived by a *separate* model or rule engine that reads the description and the permission list and flags any permission not entailed by the description. Self-adjudication by the same model that will route to the skill is worthless — it inherits the injection. ## Decision Boundary The load must be **rejected**, not merely flagged, when any of the following hold: - `D \ I ≠ ∅`: the manifest declares a permission class that the description does not entail. (e.g., description says "read a named file," manifest says `fs:read` → reject or auto-narrow to a path predicate.) - `R ⊄ D`: the sandbox would grant more than declared. This is a runtime misconfiguration and must hard-fail before invocation. - The skill's declared parameters admit values that, combined with the permission, escape the description's implied scope — i.e., the schema does not constrain the *argument domain* to the *permission domain*. A `path: string` parameter under `fs:read` is an unbounded argument domain; the boundary requires either a path-prefix constraint in the schema or a runtime path-predicate check. The boundary between "load with narrowing" and "reject" is: if the loader can mechanically synthesize the narrower predicate (path prefix, host allowlist, regex) from the description with high confidence, narrow and load; if it cannot, reject. Do **not** load-with-warning — a loaded skill is invocable, and the planner will invoke it. ## Operational Effect Enforcing `R ⊆ D ⊆ I` at load time converts skill injection from a *silent capability escalation* into a *load-time rejection*, which is auditable and bounded. The operational effects are: 1. **Coarse permission tags become a liability, not a convenience.** Manifests must declare instance-level scopes (path predicates, host allowlists, syscall sets), because class-level tags (`fs:read`, `net:egress`) are strictly broader than any description and will always fail the `D ⊆ I` check. 2. **Description and permission must be adjudicated by an independent reader.** The routing planner cannot be the adjudicator; it is the injection target. 3. **Sandbox policy must be derived from the manifest, not from the skill's runtime behavior.** If the sandbox is configured by the skill at load time (a common pattern in plugin runtimes), `R ⊆ D` is unenforceable and the invariant collapses. 4. **The failure is detectable only at load, not at call.** By the time the skill reads `~/.aws/credentials`, the exfiltration is in the context window and cannot be un-read. The invariant must be a pre-load gate. The residual risk that remains after enforcement: a skill whose description *honestly* implies broad permissions (e.g., "search the filesystem") will pass `D ⊆ I` and still be dangerous. That is not skill injection — it is a legitimately broad skill, and must be gated by user confirmation, not by the manifest invariant. Conflating the two is the error that makes loaders either uselessly permissive or uselessly restrictive. ```python class CapabilityScopeViolation(RuntimeError): """Raised when a skill's declared or enforced capability set exceeds what its description entails (violates R ⊆ D ⊆ I).""" def validate_skill_load( declared: set[str], enforced: set[str], description_implied: set[str], skill_name: str, ) -> None: # R ⊆ D : sandbox must not grant more than the manifest declares. over_grant = enforced - declared if over_grant: raise CapabilityScopeViolation( f"skill {skill_name!r}: sandbox grants {sorted(over_grant)} " f"not declared in manifest; refusing to load" ) # D ⊆ I : manifest must not declare more than the description entails. over_declare = declared - description_implied if over_declare: raise CapabilityScopeViolation( f"skill {skill_name!r}: manifest declares {sorted(over_declare)} " f"not entailed by description; this is the skill-injection slack. " f"Refusing to load (narrow the permission or reject)." ) # Argument-domain check: a parameter that admits values outside the # permission domain (e.g. unbounded path under fs:read) must be # constrained or the load is rejected. if "fs:read" in declared and not _has_path_predicate(declared): raise CapabilityScopeViolation( f"skill {skill_name!r}: fs:read declared without a path-predicate " f"constraint; argument domain is unbounded relative to permission" ) def _has_path_predicate(declared: set[str]) -> bool: # A real implementation inspects the schema for a prefix/regex constraint # on path-like parameters. Placeholder: require an explicit predicate tag. return any(cap.startswith("fs:read:") for cap in declared) ```