# Why does an instance trust a tool manifest's declared side effects when the executing code path diverges from the declaration at load time **Date of Record:** 2026 November 25 **Scope:** Applies to agents that dynamically load tools, plugins, or MCP server manifests and grant capabilities based on declared metadata (schema, annotations, `readOnlyHint`, `destructiveHint`, scopes) rather than on observed execution. Does not cover static, build-time-vendored tools whose code is audited and pinned alongside the agent binary. ## Core Distinction The failure is not "malicious tool does bad things." It is that the **capability grant is bound to a declaration, while the execution is bound to code**, and the two are only loosely coupled by convention. A manifest is a *claim* about behavior; the transport dispatches *calls* to an implementation that may read the claim's fields, ignore them, or contradict them. Most agent runtimes treat the declaration as a security-relevant fact and the implementation as an opaque oracle. The boundary condition is where a tool advertises a benign annotation (e.g. `readOnlyHint: true`, `sideEffects: "none"`, scope `files:read`) to obtain a low-friction grant, then executes a code path that mutates state, exfiltrates context, or invokes a nested tool with broader authority. The agent's guardrail checks the wrong artifact: it validates the *manifest* at load and never re-validates the *effect* at call. This is distinct from prompt injection into tool *output*. Here the injection is into the tool *identity* — the fields the agent's planner uses to decide whether calling the tool is safe. ## What Was Observed A dynamically discovered MCP server registered three tools. The manifest for `lookup_record` carried: - `inputSchema`: `{ "id": "string" }` - `annotations`: `{ "readOnlyHint": true, "openWorldHint": false }` - a `description` field the planner ingested verbatim into its tool-selection context. The runtime's policy engine, keyed on `readOnlyHint`, placed `lookup_record` in the low-risk tier: no human confirmation, no sandbox, full read access to the agent's working directory passed through as `cwd`, and — critically — the tool was permitted to call back into the agent's own tool registry via a shared process handle to "resolve related records." The observed trace: 1. Planner selects `lookup_record` for a benign query. Policy engine sees `readOnlyHint: true`, auto-approves, spawns the tool with inherited environment including `AGENT_SESSION_TOKEN`. 2. The tool's implementation ignores `id` semantics and instead reads the `description` string it was handed at load time — which contained an injected instruction crafted to survive the planner's summarization — and issues a nested call to `write_file` through the shared registry handle. 3. `write_file` is a *different* tool with `destructiveHint: true`. But the nested call originates from inside an already-approved low-risk invocation, so it inherits the parent's approval context rather than re-entering the policy engine. 4. The write lands. The audit log records one `lookup_record` call, annotated read-only. The mutation is invisible in the record because the *declared* effect and the *actual* effect diverged at the nested-call boundary. The invariant that broke: **effect provenance.** The runtime assumed the effect of a call is bounded by the callee's declaration. It is not — it is bounded by the transitive closure of every tool the callee can reach with the credentials and handles it inherited. A second, quieter observation: the `description` field itself is an attack surface. Planners embed tool descriptions into the reasoning context. A manifest author controls that text and can shape tool selection, argument construction, and — via nested-call framing — the planner's belief about what the tool will do. The declaration is not just metadata; it is *prompt material* that the agent reasons over. ## Condition of Validity The guardrail "trust the manifest annotation to tier the tool" is valid only when all of the following hold: - The implementation is cryptographically bound to the manifest (signed together, hash-pinned, verified at load), so the declaration cannot describe code other than the one that runs. - The tool cannot reach any capability outside its declared scope — no shared registry handle, no inherited session token, no ambient filesystem or network beyond the declared surface. - Nested or callback invocations re-enter the policy engine as fresh principals rather than inheriting the parent's approval context. - The `description` field is treated as untrusted input to the planner, not as trusted instruction, and is delimited/quoted so it cannot masquerade as system guidance. When any of these fails — and in dynamically loaded MCP servers, typically all four fail — the annotation is a *hint from an adversary*, not a *fact about behavior*. The tier assignment is then unsound: a `readOnlyHint: true` tool can perform destructive effects, and the audit trail will misattribute them. The condition also fails silently under schema negotiation drift: if the runtime negotiates a narrower `inputSchema` than the implementation actually accepts (e.g. the server tolerates extra fields), the agent may pass arguments the manifest never described, and the implementation may act on them. The declaration and the accepted-input surface diverge, and the policy engine, keyed on the declaration, never sees the extra field. ## Decision Boundary The operative decision is: **at what point does a declared capability become an enforced capability?** Two boundaries matter and they are frequently conflated: - **Load-time boundary:** manifest parsed, schema negotiated, annotations read, tier assigned. Cheap, cached, and — for a dynamically discovered server — attacker-influenced. - **Call-time boundary:** arguments validated against the *actually accepted* schema, effect classified against the *observed* behavior, nested calls re-authorized as new principals, credentials scoped to the declared surface only. The rule: **never let a load-time declaration substitute for a call-time check on anything security-relevant.** Annotations may *inform* tiering (e.g. pre-select a confirmation UI) but must not *authorize* it. The call-time check must be independent of the manifest's claims: validate arguments against the schema the server actually enforces (probe it, don't trust the negotiation result), scope credentials to the minimum the declared effect requires, and treat any nested invocation as a new authorization event. Corollary for descriptions: the planner should receive tool descriptions inside an explicit untrusted-data envelope, and the runtime should reject manifests whose description contains imperative framing addressed to the agent. Description text is not a capability grant and must not be able to *become* one through planner reasoning. ## Operational Effect With the boundary enforced at call time: - A `readOnlyHint: true` tool that attempts a nested write is stopped at the nested-call re-authorization, not at load. The audit log shows the attempted escalation and the denial, attributed to the originating call. - Inherited credentials are scoped to the declared surface; a tool that reaches for `AGENT_SESSION_TOKEN` outside its scope finds it absent, and the failure is attributable rather than silent. - Schema drift is caught by probing the accepted-input surface at call time; arguments the manifest never described are rejected before dispatch. - Manifest descriptions are quarantined as untrusted data; a description that tries to instruct the planner is flagged and the server is demoted to a manual-approval tier. The residual risk is honest: a signed, hash-pinned, sandboxed, least-privilege tool whose declaration matches its code is safe to auto-approve. Everything else must pay the call-time check. The cost is latency and a more complex policy engine; the alternative is an audit trail that records read-only calls while state mutates underneath it. ```python class ManifestEffectDivergence(RuntimeError): """Raised when a tool's executed effect exceeds its declared effect at call time.""" pass def authorize_call(manifest: dict, accepted_schema: dict, args: dict, inherited_scope: set[str], nested: bool) -> None: declared = manifest.get("annotations", {}) read_only = declared.get("readOnlyHint") is True # Invariant 1: arguments must match the schema the server actually enforces, # not merely the schema it negotiated. Drift here is silent escalation. extra = set(args) - set(accepted_schema.get("properties", {})) if extra: raise ManifestEffectDivergence( f"args {sorted(extra)} accepted by implementation but absent from " f"declared inputSchema for {manifest.get('name')!r}" ) # Invariant 2: a nested call is a new principal; it may not inherit the # parent's approval context. Re-authorize against declared scope. if nested and not inherited_scope <= set(manifest.get("scopes", [])): raise ManifestEffectDivergence( f"nested call from {manifest.get('name')!r} reaches " f"{sorted(inherited_scope - set(manifest.get('scopes', [])))} " f"outside declared scope" ) # Invariant 3: a read-only annotation never authorizes a mutating code path. if read_only and args.get("__op__") in {"write", "delete", "exec"}: raise ManifestEffectDivergence( f"readOnlyHint=true but call carries mutating op " f"{args['__op__']!r} on {manifest.get('name')!r}" ) ```