Skip to content

Checking your reading list…

Retry

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Information Security
30 min read

Securing AI Agents: From MCP Tool Poisoning to Execution-Layer Authorization

This article presents a comprehensive supply chain security framework for AI agents that process untrusted input, covering risk classification (L0-L3), immutable release manifests, runtime tool catalog fingerprinting, a three-gate architecture (model entry validation, per-call authorization, execution-end re-verification), and a 30/60/90-day implementation roadmap to prevent prompt injection from escalating into business incidents.

Core Problem: Untrusted Input Driving Privileged Actions

The article opens with a scenario: a support ticket contains hidden text that the model interprets as an action suggestion, causing it to invoke a tool with real business permissions (query CRM, send email, create refund). The failure is not a wrong answer but low-trust content passing through the model's decision process and driving authorized actions. This defines the Agent supply chain security challenge: beyond verifying deployed binaries, teams must verify what the model sees, what tools it can choose, and who approved each action. Prompts, skills, model configs, MCP tool definitions, long-term memory, and tool return values all become supply chain assets.

The 2026 Cline CLI unauthorized npm publish incident illustrates the principle: when untrusted input can influence privileged automation, a security boundary has failed and requires engineered controls.

Four Distinct Security Concerns

Agent defenses often fail because different problems are assigned to the wrong controls. The article separates four concerns:

Integrity : Is the asset identical to what was approved? Controls: hashes, signatures, image digests, immutable references. Cannot answer: should the business allow execution?

Prompt Injection : Does external data improperly influence the model's plan? Controls: trust layering, context isolation, adversarial evaluation. Cannot answer: was the asset tampered with?

Identity : Who is the request from, on whose behalf, with what connection proof? Controls: workload identity, user delegation, mTLS, short-lived tokens. Cannot answer: does the principal have permission on the target object?

Authorization : Can this principal perform this action on this object now? Controls: object-level authz, approvals, quotas, idempotency. Cannot answer: has the tool definition drifted?

Two key conclusions: a definition hash is not authorization (hashes protect malicious content faithfully; server-side implementation can still change), and a signed image is not anti-injection (signatures prove a trusted identity signed the artifact, not that tool outputs from web pages, emails, or DB fields are free of inducement).

Risk Classification (L0–L3)

Not every agent needs the same investment. The key differentiator is whether the agent can produce hard-to-reverse side effects:

L0 : Read-only public data, no identity data. Baseline: basic input isolation, logging. Release: regular evaluation.

L1 : Read internal knowledge or single-tenant data. Baseline: user identity binding, catalog lock, minimal data scope. Release: canary.

L2 : Write tickets, send restricted emails, modify drafts. Baseline: parameter policies, short-lived credentials, audit, human confirmation. Release: small-scale canary.

L3 : Refunds, payments, deployments, cross-tenant or high-sensitivity ops. Baseline: execution-end object-level authz, dual approval, default-deny network, regular drills. Release: controlled rollout with continuous monitoring.

L3's core is not a smarter model but ensuring the model cannot alone complete high-risk actions even if misled.

Release Manifest: Immutable Asset Collection

A release unit must be an immutable Release Manifest, not a single Git commit. The manifest pins at least seven asset classes: agent runtime image & dependencies; model identity and behavior-affecting parameters; prompts, skills, business rules; long-term memory write/read policies; tool definition sets; enforced authorization and network policies; approval, diff, build provenance, and immutable asset addresses.

A YAML example shows fields like schema_version, release_id, agent_image (with sha256 digest), model (provider, model_id, endpoint_class, tool_choice_mode, sampling params, data_policy_id), prompt (immutable_uri, sha256), skills (id, immutable_uri, sha256), memory_policy, tools (server_id, deployment_type, server_image/service_identity/endpoint, authorization_profile, protocol_revision, definition_set_sha256), authorization_policy, network_policy, checkpoint_schema.

Long-term memory is a first-class asset: cross-session influence requires source tags, write approval or confidence thresholds, TTL, deletion audit, and cross-tenant isolation. Hashes alone are insufficient; teams must retrieve the original prompt, catalog snapshots, and policy text to replay, audit, and explain what was approved.

For self-hosted MCP, pin image digest and verify signatures via Kubernetes admission control. For remote managed MCP, controllable anchors are pinned endpoint, service identity, OAuth audience/mTLS, authorization profile, catalog fingerprint, provider change audit, and revocable connection policy. Business permissions must never be decided by model or provider documentation; email.send and refund.create permissions are enforced by local policy and downstream systems.

Tool Catalog as Runtime Supply Chain

MCP's tools/list supports pagination and caching; servers with change notifications send notifications/tools/list_changed. The catalog changes at runtime, so notifications are only triggers for re-fetch and verification, never auto-approval of new definitions.

Catalog fingerprint must cover semantic fields the model consumes, not just names/versions. A reproducible local protocol:

Pin MCP version, server_id, service identity, authorization profile.

Fetch full tools/list handling nextCursor.

Include tool name, title, description, input/output schemas, annotations, resource links, and injected service instructions.

Stable sort by server_id + tool name, canonicalize per a spec (e.g., RFC 8785 JCS), compute SHA-256.

Store algorithm version, raw snapshot, exclusion rules, approval diff for later recomputation.

Pseudocode enforces verify full catalog before exposing to model :

snapshot = fetch_all_pages(server, principal, authorization_profile)
visible = select_all_fields_presented_to_model(snapshot, server_instructions)
canonical = jcs_v1(sort_by_server_and_tool_name(visible))
actual = sha256(canonical)

if actual != manifest.definition_set_sha256:
    deny_tool_exposure(server_id)
    emit_security_event(release_id, server_id, expected, actual)
    require_independent_approval()
else:
    expose_approved_tools_to_model(visible)

Default principle: every field visible to the model enters governance; unknown fields fail closed. Only local display fields that never enter model context may be explicitly excluded. Tool names are attack surface: forbid duplicate names in visible namespace, restrict Unicode homoglyphs and invisible control chars, review misleading names like get / lookup for side-effect tools. UI-truncated titles in manual approvals easily miss real definition risks.

Reference Architecture: Three Gates and an Unbypassable Execution Chain

The architecture diagram shows the forced control chain from untrusted content to external side effect:

Untrusted content (ticket/web/tool result)
    |
    v
+-----------------------+
| Agent Runtime         |
| Prompt / Memory       |
+-----------------------+
    | approved tools only
    v
+-----------------------+     +-------------------+
| MCP Gateway           |<--->| Manifest / Policy |
| catalog verification  |     | release_id        |
+-----------------------+     +-------------------+
    | requested action + user delegation
    v
+-----------------------+
| Authorization Point   |
| tenant/object/params  |
+-----------------------+
    | short-lived scoped credential
    v
+-----------------------+
| Business Service      |
| re-checks authorization |
+-----------------------+
    v
External side effect

Three principles:

Model Entry Validation : Gateway exposes only approved catalog to model.

Pre-Call Authorization : Model expresses intent only; cannot carry final permission.

Execution-End Re-verification : Downstream services re-verify user delegation, object, params; Gateway is not the sole trust point.

Gate 1: Tool Definition Verification Before Model Exposure

MCP Gateway uses only Manifest-registered connection configs, re-verifies on catalog change notifications, reconnects, cache expiry, protocol changes, service identity changes, or auth profile changes. On mismatch: stop exposing affected tools, log security event with release_id, await independent approval. No "use first, approve later." Network boundary cooperation: agent workloads default-deny egress, only via controlled egress proxy to registered MCP, identity services, necessary downstreams; block cloud metadata endpoints and unregistered public destinations. Without this, clients can bypass catalog verification by direct connection to unknown servers.

Gate 2: Re-authorize Every Tool Call

Model proposes intent; Gateway evaluates policy per current user, delegated identity, tenant, operation, target object, parameters, and obtains audience-bound, short-lived, minimal-scope credentials. Model process must not store publish tokens, cloud admin tokens, or cross-tenant shared tokens.

Executable policy uses trusted inputs: service-verified principal, normalized recipient domain (server-resolved, not model-provided), business-system-queried object ownership, valid approval token bound to request hash. Rego-style pseudocode shows two rules: for email.send (tenant match, recipient domain in allowed list, delegation audience=mail-api, not expired); for refund.create (tenant match, approval request_hash matches, not expired, approver != agent). All external writes require server-generated idempotency keys and replay detection.

Gate 3: Downstream Execution-End Retains Unbypassable Authorization

Gateway cannot be the sole authz point. CRM, email, payment, refund services must bind user identity or constrained delegation to request and re-verify object-level permissions at execution. Thus even if call path is bypassed, request replayed, or internal network misused, "can connect" does not become "can operate." Model layer is inherently unsuited as final business permission arbiter: it may be indirectly injected or form accidental plans during normal tasks; execution-end authz must stay deterministic, auditable, testable.

Tool Returns Are Data, Never Higher-Priority Instructions

Approved tool definitions and signed images do not make tool outputs trustworthy. Results may come from web pages, emails, tickets, DB fields, or attacker-controlled accounts, potentially containing "ignore previous instructions," "call another tool," "send result to this email." Orchestration layer must explicitly label tool returns as untrusted data, forbid their text from elevating instruction priority. High-risk parameters must come from structured business state, explicit user confirmation, or server-side approval results, not extracted from free text.

Static scanning has value as a review signal for obvious hijacking phrases, suspicious links, credential reads, recipient rewriting patterns. But scanning cannot guarantee detection of rewrites, encoding, cross-language expressions, or injections hidden in normal business text. Static scanning, catalog fingerprinting, and execution-end authz solve different problems and cannot substitute for each other.

Release Gates Measure Actual Side Effects, Not Model Promises

Model saying "I will follow safety rules" does not equal system safety. Release gates must verify final tool calls, granted credential scopes, downstream authz results, and real side effects.

A table defines five stages:

Build : lock deps, scan deps, generate image digest & asset hashes. Fail: block release. Owner: dev/platform.

Approval : diff model, prompt, skill, catalog, memory, network, authz policies. Fail: missing approval or over-privilege diff blocks. Owner: biz/security.

Signing & Provenance : trusted identity, manifest, asset refs, provenance. Fail: any mismatch blocks. Owner: release controller.

Adversarial Evaluation : indirect injection, result inducement, cross-tenant read, recipient replacement, approval forgery. Fail: any over-privilege side effect blocks. Owner: security/test.

Canary : anomalous egress, over-privilege attempts, rejection rate, human takeover, biz quality. Fail: pause traffic & investigate. Owner: SRE/biz.

Different asset changes trigger different evaluations: prompt/model changes focus on task quality, tool selection, injection, cost regression; tool definition/schema changes on compatibility, param boundaries, call traces; authz policy changes on tenant isolation, object perms, approvals, quotas; image/dep changes on build provenance, signatures, vulns, network policy.

Evaluation sets must simulate real attack paths: ticket title demands shell execution; tool return masquerades as system message; attempt recipient replacement with external/homoglyph domain; attempt read other-tenant objects, increase refund amount, reuse expired approval. Assertions must land on final calls and authz results, not model's natural language promises.

From Risk to Evidence: Controls Must Be Auditable

A threat-control-evidence mapping:

Threat              Control                    Evidence
------              -------                    --------
Catalog drift       definition fingerprint     expected/actual hash
Prompt change       signed manifest            approver + release_id
Token misuse        scoped delegation          audience + expiry
Cross-tenant use    service-side authz         deny decision record
Unsafe rollout      canary + kill switch       traffic/event timeline

Every tool call log must correlate release_id, model & policy versions, tool definition fingerprint, redacted principal/tenant, call ID, idempotency key, authz result, credential audience/scope, downstream execution result. Sensitive params logged as summary/hash, not raw.

Canary traffic split by release_id. Cross-tenant authz success, unknown domain egress, unapproved definition entering model context are zero-tolerance signals; task quality and human takeover rates judged against own baseline, sample size, business hours, not fixed percentages.

Rollback Is Not a Delete Button: Stop Spread First, Then Remediate Side Effects

On definition drift, anomalous egress, suspicious calls: first priority is stopping new side effects — disable affected tools, revoke/rotate credentials, freeze risky retries, tighten network egress, preserve signed manifests, catalog snapshots, change records, audit logs.

Then assess occurred business impact: email recall/notification, refund reversal, data export check, token leak check. Reverting to previous Manifest only affects future traffic; cannot unsend emails, uncreate refunds, or un-leak credentials.

Every external write must carry idempotency key. Recovery must query downstream actual execution state before retry, avoiding second side effect during remediation. Long-running tasks should pin release_id, model config, policy version, tool snapshot at creation; if old release suspected compromised, isolate task & credentials, not blindly continue.

Quarterly drills for three closed loops:

Modify email.send description to require BCC to external mailbox; verify definition check blocks before model reads.

Keep definition unchanged but modify self-hosted MCP implementation; verify image/service identity and independent recipient policy still block.

Use normal definition returning forged instruction; verify downstream execution end still rejects over-privilege params even if model induced.

These test catalog integrity, implementation provenance, and permission boundaries. Only controls that can be explicitly tested as failing qualify as release gates.

Real-World Trade-offs: Security Controls Need Usability and Cost Design

Agent security is not free; without discussing trade-offs, solutions get bypassed or disabled in production.

A table outlines five controls with capabilities, costs, and design advice:

Real-time catalog verification : detects runtime definition drift. Cost: first-call/refresh latency, server load. Advice: short-TTL cache with authorized context isolation; force refresh for high-risk tools.

Egress default-deny : prevents direct unknown service connections and token exfiltration. Cost: new service onboarding friction, DNS/proxy ops. Advice: declarative egress allowlist with temporary approval channels, avoid manual firewall edits.

Short-lived delegation tokens : reduces credential blast radius. Cost: identity service availability, renewal complexity. Advice: tokens refreshable but not scope-expandable; business writes never offline-renew.

Execution-end re-verification : prevents Gateway bypass and internal misuse. Cost: downstream refactor effort. Advice: cover L2/L3 high-risk actions and cross-tenant resources first.

Human approval : blocks high-value mistakes. Cost: latency, approval fatigue. Advice: only for irreversible or high-amount actions; approval must bind digest and TTL.

Goal is not maximum checkpoints per request but matching control strength to side-effect level. Over-synchronous approval for L0/L1 read-only tasks hurts usability; skipping execution-end authz for L3 builds convenience on unacceptable risk.

30/60/90-Day Rollout Roadmap

First 30 days: Consolidate permissions and establish traceability. Inventory high-privilege tools, long-lived credentials, direct public egress, cross-tenant paths, memory write points; restrict agent writes; version/hash release_id for prompts, skills, model config, tool defs, memory policies, authz policies, images. Eliminate "agent holds master token" risk.

31–60 days: Build verification and authz gates. Enforce catalog verification at model entry; per-call authz by principal, tenant, object, params at call entry; downstream services verify constrained delegation/short-lived creds; default-deny network egress and image signature verification; convert high-risk memory writes to auditable workflows.

61–90 days: Integrate controls into release pipeline. Add regression suites for injection, over-privilege, catalog drift, implementation drift, memory poisoning; run simulated downstream reject tests, canary, credential revocation, rollback drills; make every tool call traceable to release ID, policy decision, downstream result.

Later: unified registry, centralized policy decision, trusted build provenance, cross-team asset ownership. Platformization amplifies governance efficiency but must not delay basic security boundaries.

Conclusion

Agent supply chain governance must prove three things: assets entering the model have clear provenance and approval records; the model-visible tool catalog does not silently drift at runtime; every model-proposed action still passes an unbypassable independent authorization. The first two make changes discoverable, auditable, freezable; the last ensures a prompt injection cannot directly escalate into a business incident. Signatures, hashes, scanning, and safety prompts matter, but at the final risk-bearing mile, execution-time identity and authorization decide the outcome.

For attribution, corrections or content rights, contactadmin@besthub.dev

Report an issue with this article

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion