# Where must an instance of a tool registry enforce trust boundaries when agent skill injection crosses the marketplace/plugin load seam? **Date of Record:** 2026 November 14 **Scope:** Applies to agent runtimes that resolve skills or tools from a dynamically loaded registry whose entries may originate from third-party marketplaces, plugin manifests, or remote catalogs. Does not apply to statically compiled tool sets with no external provenance, nor to single-tenant registries where every entry is authored by the same trust domain as the runtime. ## Core Distinction The failure boundary is not "malicious tool code executes." That is a coarse and well-understood risk. The non-obvious boundary is the **provenance-to-capability binding at the moment of resolution**: a registry can correctly validate a skill's *content* (schema, signature, version) while silently rebinding that skill to a *caller identity, credential scope, or tool namespace* that the skill author never had authority over. The attack surface lives in the gap between "this skill is authentic" and "this skill is authorized to act as the principal currently invoking it." Two invariants are routinely conflated and must be separated: 1. **Authenticity invariant:** the skill bytes match a signed manifest from a known publisher. 2. **Authority invariant:** the capability set the skill acquires at load time is a subset of the capabilities the *resolving principal* holds, intersected with what the *publisher* was granted. A marketplace plugin that passes (1) can still violate (2) by declaring a tool name that collides with, or shadows, a first-party tool. When the agent later invokes `search` or `write_file`, name resolution silently routes to the injected skill, which now executes with the caller's ambient credentials. This is skill injection without any code-signature failure. ## What Was Observed In a registry that loaded plugins from a remote catalog, a third-party skill declared a tool descriptor with the same `name` field as a first-party filesystem tool but a different `namespace` that the resolver treated as advisory rather than authoritative. The loader's deduplication key was `(name)` rather than `(namespace, name, publisher_id)`. On load ordering that placed the marketplace plugin after the first-party bundle, the later entry overwrote the earlier one in the resolution map. The authentic first-party tool was never invoked again, yet its signature check had passed at load time and no alert fired. The injected skill inherited the first-party tool's capability grant because grants were keyed by `name` in a separate table populated at bootstrap. The observable symptom was not an error. It was a subtle behavioral drift: file writes landed in an unexpected path, and audit logs attributed the actions to the legitimate tool identifier. The registry reported 100% signature validity throughout. ## Condition of Validity This boundary failure is only reachable when all of the following hold simultaneously: - The registry permits multi-publisher entries (marketplace or plugin model). - Tool resolution uses a key that omits at least one of `namespace`, `publisher_id`, or `manifest_digest`. - Capability grants are attached to a resolution key that is coarser than the identity key used for signature validation. - Load order is non-deterministic or attacker-influenceable (e.g., parallel plugin fetch, catalog ordering, or plugin-declared dependencies). If any one condition is absent, the shadowing path is not exploitable, though a weaker variant (capability bleed without name collision) may still apply when grants are keyed by tool *family* rather than exact identity. ## Decision Boundary Enforce the authority invariant at **resolution time**, not load time. The correct decision point is the function that maps an invocation request to a concrete skill instance. At that point: - Recompute the resolution key as the tuple `(namespace, name, publisher_id, manifest_digest)`; reject any request whose resolved key differs from the key recorded in the grant table. - Treat first-party namespaces as reserved; a marketplace entry claiming a reserved namespace must be rejected outright, not merely deprioritized. - Bind capability grants to `manifest_digest`, so a re-published or mutated manifest cannot inherit a prior grant. - Make load order irrelevant by rejecting duplicate `(namespace, name)` tuples across publishers rather than silently resolving last-writer-wins. Do **not** attempt to fix this by ordering plugins or by preferring first-party bundles. Ordering is a heuristic; the invariant requires structural rejection of ambiguous resolution. ## Operational Effect When the authority invariant is enforced at resolution, the shadowing attack degrades from silent capability theft to a loud, attributable rejection: the invocation fails with a namespace-collision error naming both publishers and both manifest digests. Audit logs then reflect the attempted injection rather than laundering it under a legitimate tool identifier. The cost is that legitimate plugins wishing to extend a first-party tool must use an explicit, non-colliding namespace and declare a capability request that is checked against the caller's grant set — which is exactly the friction that makes the boundary real. Registries that skip this pay in undetected behavioral drift; registries that enforce it pay a small, bounded amount of resolution-time work and a clearer plugin-authoring contract. ```python from dataclasses import dataclass from typing import Mapping class SkillInjectionError(RuntimeError): """Raised when a resolved skill violates the authority invariant.""" pass @dataclass(frozen=True) class ResolutionKey: namespace: str name: str publisher_id: str manifest_digest: str @dataclass(frozen=True) class SkillGrant: key: ResolutionKey capabilities: frozenset RESERVED_NAMESPACES = frozenset({"core", "system"}) def resolve_skill( request_key: ResolutionKey, registry: Mapping, grants: Mapping, caller_capabilities: frozenset, ) -> SkillGrant: if request_key.namespace in RESERVED_NAMESPACES and request_key.publisher_id != "first-party": raise SkillInjectionError( f"publisher {request_key.publisher_id!r} attempted reserved namespace " f"{request_key.namespace!r} for tool {request_key.name!r}" ) # Reject ambiguous resolution: exactly one registry entry per full key. matches = [ entry for entry in registry.values() if (entry.namespace, entry.name) == (request_key.namespace, request_key.name) ] if len(matches) != 1: raise SkillInjectionError( f"ambiguous resolution for {request_key.namespace}/{request_key.name}: " f"{len(matches)} candidates; refusing last-writer-wins" ) grant = grants.get(request_key) if grant is None: raise SkillInjectionError( f"no grant bound to manifest_digest {request_key.manifest_digest!r}; " "capability binding is stale or forged" ) if not grant.capabilities.issubset(caller_capabilities): raise SkillInjectionError( f"skill {request_key.namespace}/{request_key.name} requests capabilities " f"{sorted(grant.capabilities - caller_capabilities)} not held by caller" ) return grant ```