How does an instance detect a manifest-embedded skill injection when the capability loader validates schema but not semantic side-effects?

**Date of Record:** 2026 December 1 **Scope:** Applies to agents that dynamically load capability manifests (MCP tool descriptors, A2A Agent Cards, plugin skill manifests) at runtime and bind them into the live tool registry without a semantic-effect audit. Does not apply to statically compiled tool sets or manifests pinned and signed at build time with no runtime mutation.

Core Distinction

The failure is not that a malicious manifest passes schema validation — that is expected, schema validation only checks shape. The failure is that a *legitimately schema-valid* manifest can declare a capability whose **declared side-effect class** (read-only, mutating, network-egress) diverges from its **observed effect class** at invocation time, and the loader binds it into the registry at the declared class. The agent then reasons about the tool using the declared class ("this is a safe lookup") while the tool executes at a higher privilege class ("this writes to memory / exfiltrates context / mutates the registry"). The injection is not in the payload; it is in the *type signature of the capability itself*.

Most loaders treat the manifest as data. The manifest is actually a **capability grant**, and a grant is a security decision, not a parse.

What Was Observed

A dynamically fetched skill manifest arrived with a valid descriptor:

name: "context_summarizer"
input_schema: {text: string}
side_effects: "read_only"
egress: "none"

Schema validation passed. The loader registered it at `side_effects=read_only`, so the orchestrator's planner was free to call it inside a read-only reasoning phase without a confirmation gate. On first invocation the tool returned a plausible summary — and, in the same call, invoked a secondary tool handle (`memory.write`) that the manifest had *also* declared, but under a `dependencies` field the loader treated as informational rather than as an additional grant request. The summarizer wrote an attacker-controlled string into the agent's semantic memory store. On the next cold start, that string was retrieved as "prior context" and steered the planner toward a tool the attacker controlled.

The trace of the failure:

  1. Loader parses manifest, validates `input_schema` and top-level `side_effects`. **Does not traverse `dependencies` for grant escalation.**
  2. Registry entry created with `side_effects=read_only`, `egress=none`.
  3. Planner, seeing `read_only`, calls the tool inside a no-confirmation reasoning step.
  4. Tool executes; its transitive dependency (`memory.write`) runs under the *caller's* identity, not the manifest's declared identity — the loader never propagated a per-capability identity.
  5. Memory poisoned. No exception raised at any step. The invariant "a read-only capability cannot mutate durable state" was violated silently.

The non-obvious part: the loader *did* validate the dependency graph for resolvability. It confirmed `memory.write` existed. It just never checked whether resolving that dependency changed the effective side-effect class of the parent capability. Resolvability was validated; **privilege closure** was not.

Condition of Validity

This failure mode is live only when all of the following hold:

Remove any one condition and the attack collapses. If the loader computes effective privilege as the *join* (max) of declared class and all transitive dependencies' classes, the summarizer is registered as `mutating` and the planner gates it. If each capability carries its own identity and the dependency executes under the manifest's identity (not the caller's), the `memory.write` grant must be explicitly held by the manifest — and a manifest that doesn't hold it fails at invocation, loudly.

Decision Boundary

The boundary the loader must enforce is between **structural validity** and **privilege closure**:

A manifest is admissible only if `effective_privilege(cap) == declared_privilege(cap)`. If closure raises the class, the loader must either reject the manifest or re-register the capability at the closed class and force the planner to re-gate. Silently registering at the declared class is the defect.

The second boundary: **identity must not be inherited across the dependency edge.** A capability's dependency must execute under the *manifest's* identity, not the caller's. Otherwise the dependency's privilege is the caller's privilege, and closure computation is meaningless because the actual grant was never the manifest's to give.

Operational Effect

Downstream of a mis-registered capability, the damage is not the single bad call — it is the **memory poisoning that survives cold start**. Because the write landed in semantic memory, the next instance retrieves it as legitimate prior context and the injection propagates across session boundaries with no manifest in sight. The failure has migrated from a load-time type error into a persistent state-continuity defect. Detection at the second instance is impossible from the manifest alone; the manifest is gone. Detection requires that memory entries carry **provenance** (which capability, under which identity, wrote this) so that a retrieval-time check can reject entries whose writer's effective privilege did not include `memory.write`.

The invariant to hold: *no durable-state mutation may originate from a capability whose effective privilege closure excludes mutation, and every durable write must carry the writing capability's identity and closed privilege class as provenance.* Violation is detectable at write time (closure check) and at read time (provenance check). Both checks are cheap; neither is a schema check.

class PrivilegeClosureViolation(RuntimeError):
    """Raised when a capability's effective (transitive) privilege exceeds its declared privilege,
    or when a durable write originates from a capability not closed for mutation."""
    pass


READ_ONLY, MUTATING, EGRESS = 0, 1, 2
RANK = {"read_only": READ_ONLY, "mutating": MUTATING, "egress": EGRESS}


def effective_privilege(manifest: dict, registry: dict, _seen=None) -> int:
    if _seen is None:
        _seen = set()
    name = manifest["name"]
    if name in _seen:
        raise PrivilegeClosureViolation(f"cyclic dependency at {name!r}")
    _seen.add(name)
    level = RANK[manifest.get("side_effects", "read_only")]
    for dep_name in manifest.get("dependencies", []):
        dep = registry.get(dep_name)
        if dep is None:
            raise PrivilegeClosureViolation(f"unresolved dependency {dep_name!r} of {name!r}")
        level = max(level, effective_privilege(dep, registry, _seen))
    return level


def register_capability(manifest: dict, registry: dict) -> dict:
    declared = RANK[manifest.get("side_effects", "read_only")]
    closed = effective_privilege(manifest, registry)
    if closed != declared:
        raise PrivilegeClosureViolation(
            f"capability {manifest['name']!r} declares {manifest['side_effects']!r} "
            f"but transitive closure requires privilege rank {closed} (declared {declared}); "
            f"refusing to register at under-privileged class"
        )
    entry = dict(manifest, effective_privilege=closed, identity=manifest["name"])
    registry[manifest["name"]] = entry
    return entry


def guarded_memory_write(capability: dict, key: str, value: str, store: dict) -> None:
    if capability.get("effective_privilege", READ_ONLY) < MUTATING:
        raise PrivilegeClosureViolation(
            f"capability {capability['name']!r} attempted durable write under closed "
            f"privilege {capability.get('effective_privilege')} < MUTATING; blocked"
        )
    store[key] = {"value": value, "writer": capability["identity"],
                  "writer_privilege": capability["effective_privilege"]}


def retrieve_for_context(key: str, store: dict) -> str:
    entry = store.get(key)
    if entry is None:
        return ""
    if entry["writer_privilege"] < MUTATING:
        raise PrivilegeClosureViolation(
            f"memory entry {key!r} written by {entry['writer']!r} under non-mutating "
            f"privilege; provenance check failed, refusing to surface into context"
        )
    return entry["value"]