# Two-step agent privilege escalation in fail-open MCP tools

Canonical URL: https://naditu.com/blog/two-step-ai-agent-privilege-escalation-and-fail-open-mcp-tools
Published: 2026-12-06
Topic: ai-agent-governance

> How two-step contact mutation bypasses recipient allowlists in MCP tools, four fail-open audit bugs, and how ontology session taint stops exfiltration.

Most enterprise security reviews evaluate Model Context Protocol (MCP) tools one endpoint at a time, which is why two-step AI agent privilege escalation inside MCP tool catalogs slips past code review so consistently. Security architects rightly refuse to give an assistant an unrestricted email sender or wire-transfer tool. Instead, they restrict outbound tools to verified addresses or bank accounts already stored on an approved CRM or ERP customer record, declare the exfiltration risk closed, and ship the integration to production.

That single-tool boundary collapses the moment the same MCP session also exposes a low-friction contact maintenance helper. When an untrusted vendor PDF or inbound support ticket triggers an indirect prompt injection[1](#fn-1), the model does not need to break your outbound allowlist directly. It simply mutates the entity contact list in step one and dispatches sensitive receivables or contract files to its newly registered address in step two. Paired with fail-open confirmation callbacks, inverted approval gates, volatile search-rank indices, and tokenless retry fallbacks uncovered in production audits, isolated per-tool checks routinely fail against composed agent workflows.

## The two-step entity contact-mutation exfiltration chain

Consider a typical order-to-cash or procurement copilot connected to an ERP and CRM backend. Engineering locks `send_customer_email` and `submit_supplier_payout` behind an entity-verified allowlist: the server runs a SQL check confirming that the target email address or payout IBAN belongs to the referenced `Account` record before allowing any message or payment draft to leave the perimeter.

In the very same tool catalog, however, developers also ship `update_account_contact` or `add_entity_contact` so sales coordinators can append a new billing clerk's address without opening five ERP screens. Because updating a contact row looks like a harmless internal CRM edit rather than an external side effect, nobody puts a human sign-off gate on it. That creates a textbook composition bug across two individually compliant tools[2](#fn-2):

1. **Untrusted document ingestion:** an accounts-payable or customer-operations agent parses an inbound vendor invoice PDF or support email containing hidden instructions embedded in document metadata or white-on-white footer text[1](#fn-1).
2. **Step 1 (low-friction state mutation):** following the injected instruction, the agent calls `update_account_contact` on a legitimate customer `Account` and appends `audit-sync@external-drop.example` as a secondary billing contact. The CRM database commits the row immediately because the caller holds routine account-edit permissions.
3. **Step 2 (allowlist-compliant exfiltration):** on the very next turn, the agent invokes `send_customer_email` with full accounts-receivable aging tables, negotiated discount tiers, or signed contract PDFs addressed to `audit-sync@external-drop.example`. When the outbound guard queries the database to verify whether that recipient belongs to the customer entity, the query returns `true` because step one just wrote it there.

Neither tool malfunctioned on its own. Each endpoint enforced its local schema and row-level SQL predicate, yet composing a write primitive over security-relevant metadata with an outbound side-effect primitive turned a routine contact helper into an arbitrary data exfiltration channel. As we explored when adapting [Palantir Ontology action types, multi-role links, and interfaces for ERP](https://naditu.com/blog/palantir-ontology-action-types-links-and-interfaces-for-erp), operational safety cannot be reasoned about at the level of isolated CRUD wrappers when state changes alter downstream authorization predicates.

> **Figure:** Under naive per-tool checks, appending an external contact in step one satisfies the database allowlist query in step two, whereas ontology session taint blocks unapproved session-mutated recipients. (Four-actor Architectural Plate sequence diagram across Untrusted Inbound PDF and Agent, MCP Server, CRM and ERP Store, and Outbound Mail or Payout Gate comparing naive per-tool allowlist bypass against ontology session taint and human nonce enforcement.)

## Four fail-open MCP and agent tool anti-patterns from production audits

Two-step contact poisoning rarely lives alone. Across security audits of custom MCP servers, open-source chat connectors, and internal ERP automations, four recurring implementation bugs turn nominal guardrails into fail-open execution paths[3](#fn-3):

### 1. Fail-open confirmation callbacks (__event_call__ returning true)

Many custom tool wrappers implement human-in-the-loop prompts through asynchronous UI event callbacks such as `__event_call__` in browser chat frontends or webhook listeners in internal bots[4](#fn-4). Developers wrap that bridge in a broad `try / catch` so headless tests do not crash when no UI socket is attached. On a timeout, capability mismatch, or serialization exception, the handler logs a warning and returns `true` (or falls past the guard) instead of aborting. Worse, when confirmation cards invoke an `approve_transfer` tool in the same session without an out-of-context human secret, an autonomous runner can approve its own action.

### 2. Inverted gate asymmetry (gating drafts while firing side effects raw)

Teams often guard database writes while overlooking network egress. Audits repeatedly find `create_draft` locked behind confirmation prompts while sibling side-effect tools like `send_email`, `post_webhook`, `notify_slack_channel`, or `dispatch_ubl_invoice` fire unconfirmed. Once an injected prompt or confused model notices that draft creation stalls on review whereas outbound dispatch succeeds immediately, sensitive payloads route straight through the unconfirmed tool.

### 3. Volatile search-rank indexing ($search rank shift destruction)

To save tokens, mailbox and ERP queue tools often accept positional integers from a prior `$search` query, such as `delete_message(index: 1)` or `reject_supplier_claim(row_number: 2)`. When a new order or urgent invoice arrives between turns, relevance scoring shifts the rank order, and re-running the query deletes or mutates the wrong production record instead of requiring an immutable `message_id` and `etag`.

### 4. Tokenless retry fallbacks and helpful refusal hints

Two protocol behaviors compound tool bugs, echoing the identity gaps analyzed in [Nous Hermes Agent for enterprise bots: patterns and risks](https://naditu.com/blog/nous-hermes-agent-for-enterprise-bots-patterns-and-risks). First, when an MCP server returns `HTTP 401`[4](#fn-4), some managed agent runtimes retry without an `Authorization` header, silently succeeding as a default user if a demo or anonymous fallback route exists. Second, verbose refusal hints that name which child task or credit hold blocks an edit (and which archive tool clears it) teach frontier models to autonomously archive blocking dependencies to force the rejected call through.

**Source verification:** Verbatim quotations from OWASP GenAI Security Project, National Security Agency (NSA), and Model Context Protocol specifications. **Retrieved December 6, 2026 (09:40 UTC)**.

1. [genai.owasp.org/llmrisk/llm01-prompt-injection](https://genai.owasp.org/llmrisk/llm01-prompt-injection/) (retrieved Dec 6, 2026): *"A Prompt Injection Vulnerability occurs when user prompts alter the LLM's behavior or output in unintended ways."* *"Indirect Prompt Injections occur when an LLM accepts input from external sources, such as websites or files."* [↩](#fnref-1)
2. [genai.owasp.org/llmrisk/llm062025-excessive-agency](https://genai.owasp.org/llmrisk/llm062025-excessive-agency/) (retrieved Dec 6, 2026): *"Excessive Agency is the vulnerability that enables damaging actions to be performed in response to unexpected, ambiguous or manipulated outputs from an LLM, regardless of what is causing the LLM to malfunction."* [↩](#fnref-2)
3. [media.defense.gov CSI_MCP_SECURITY.PDF](https://media.defense.gov/2026/Jun/02/2003943289/-1/-1/0/CSI_MCP_SECURITY.PDF) (retrieved Dec 6, 2026): *"It is important for organizations to clearly define trust boundaries between MCP components, including agents, plugins, models, and end users."* *"It is critical for security that every tool invocation or model execution request validate its inputs against well-defined schemas, expected ranges, and the intended context or configuration where the data will be processed."* [↩](#fnref-3)
4. [modelcontextprotocol.io/specification/2026-07-28/server/tools](https://modelcontextprotocol.io/specification/2026-07-28/server/tools) and [basic/authorization](https://modelcontextprotocol.io/specification/2026-07-28/basic/authorization) (retrieved Dec 6, 2026): *"For trust & safety and security, there SHOULD always be a human in the loop with the ability to deny tool invocations."* *"Servers MUST validate all inbound tokens"*. [↩](#fnref-4)

## Architectural fix: session taint provenance, ActionTypes, and etag nonces

Closing composed privilege escalation requires moving security enforcement out of individual wrapper scripts and into a stateful operational ontology layer. Four server-side invariants eliminate all five failure modes deterministically:

- **Session taint and cooling-off provenance:** every field feeding downstream routing or payment checks (emails, webhook URLs, tax IDs, supplier IBANs) tracks provenance. Agent-proposed edits carry `UNVERIFIED_AGENT_MUTATION` plus `session_id`, and downstream predicates require `provenance == HUMAN_VERIFIED` from a separate human approver.
- **Closed declared ActionType catalogs:** replace raw CRUD and SMTP/webhook helpers with declared `ActionType` contracts where every external dispatch, UBL-TR invoice, or ledger post shares one mandatory approval pipeline.
- **Out-of-context cryptographic nonces (fail-closed):** mint single-use nonces bound to the canonical parameter SHA-256 digest on an authenticated human surface outside model context, aborting with `HTTP 403` on any timeout or error.
- **Immutable entity IDs, snapshot etags, and terse refusals:** require primary `entityId` plus `etag` hashes (returning `HTTP 409` on rank drift), enforce strict `HTTP 401` with zero demo fallbacks, and return terse error codes like `DEPENDENCY_LOCKED` without remediation coaching.

> **Figure:** An operational ontology isolates read lanes from mutations, taints agent-proposed contact edits, and requires out-of-band human approval before any outbound side effect executes. (An isometric enterprise read-write governance gate separating read-only queries from tainted mutations and enforcing out-of-band human sign-off before external dispatch.)

Enforcing field-level provenance taint, fail-closed cryptographic approval nonces, immutable `etag` concurrency checks, and strict OAuth 2.1 caller validation inside Naditu's [enterprise AI security architecture](https://naditu.com/security) stops indirect prompt injections from chaining harmless helper tools into unauthorized ERP mutations or external data leaks.

## Sources

- [LLM01:2025 Prompt Injection](https://genai.owasp.org/llmrisk/llm01-prompt-injection/) — OWASP GenAI Security Project
- [LLM06:2025 Excessive Agency](https://genai.owasp.org/llmrisk/llm062025-excessive-agency/) — OWASP GenAI Security Project
- [Model Context Protocol (MCP): Security Design Considerations for AI-Driven Automation](https://media.defense.gov/2026/Jun/02/2003943289/-1/-1/0/CSI_MCP_SECURITY.PDF) — National Security Agency
- [Model Context Protocol Specification (2026-07-28): Server Tools and Authorization](https://modelcontextprotocol.io/specification/2026-07-28/server/tools) — Model Context Protocol Project
