Skip to content
Naditu
Get started

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

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

Naditu7 min read

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 injection1, 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 tools2:

  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 text1.
  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, operational safety cannot be reasoned about at the level of isolated CRUD wrappers when state changes alter downstream authorization predicates.

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 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 paths3:

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 bots4. 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. First, when an MCP server returns HTTP 4014, 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.

Vulnerability ClassNaive MCP Tool PatternExploit / Failure ModeOperational Ontology Control
Two-Step Contact Mutation1 2Unconfirmed update_contact paired with allowlisted send_emailIndirect injection appends external address then passes DB allowlist checkUNVERIFIED_AGENT_MUTATION session taint + separate human sign-off
Fail-Open Callbacks & Gate Asymmetry4__event_call__ returns true on timeout while send_email skips draft gateHeadless/serialization errors auto-approve actions and outbound tools fire rawFail-closed out-of-context cryptographic nonces on every external side effect
Volatile $search Indexing3delete_message(index: 1) resolved by re-running live $searchConcurrent arrival shifts rank order and destroys the wrong ERP or mail recordImmutable primary entity_id plus mandatory snapshot etag hash check
Tokenless Retry & Refusal Hints3 4Demo fallback on missing header plus verbose error remediation instructions401 retry lands on shared demo user and model archives blocking dependenciesZero anonymous routes, strict OAuth 2.1 audience checks, and terse error codes

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.
{
  "actionType": "dispatch_verified_customer_statement",
  "parameters": {
    "accountId": "uuid-9f31-44c0",
    "accountEtag": "sha256-7b92e1d4",
    "recipientContactId": "contact-8841",
    "statementPeriod": "2026-11"
  },
  "serverPredicates": [
    "Account.etag == parameters.accountEtag",
    "Contact.accountId == parameters.accountId",
    "Contact.provenance == 'HUMAN_VERIFIED'",
    "Contact.mutatedInAgentSessionId == null"
  ],
  "egressControl": {
    "mode": "FAIL_CLOSED_OUT_OF_BAND_NONCE",
    "nonceBinding": "sha256(callerSub + actionType + canonicalJson(parameters))",
    "onTimeoutOrError": "DENY_403",
    "refusalFormat": "CODE_ONLY_NO_REMEDIATION_HINTS"
  }
}
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.

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 stops indirect prompt injections from chaining harmless helper tools into unauthorized ERP mutations or external data leaks.

Sources

  1. LLM01:2025 Prompt Injection, OWASP GenAI Security Project
  2. LLM06:2025 Excessive Agency, OWASP GenAI Security Project
  3. Model Context Protocol (MCP): Security Design Considerations for AI-Driven Automation, National Security Agency
  4. Model Context Protocol Specification (2026-07-28): Server Tools and Authorization, Model Context Protocol Project

More on AI agent governance: Permissions, approval, audit and security for AI agents that read and act on company systems, including agents that work through MCP.

Keep reading

Follow what we ship.

New connectors, product updates and what we learn rolling AI out in enterprises, sent to your inbox.

Book a demo

Tell us where to reach you and we will reply with times.