MCP event payloads are untrusted: a practical security guide

MCP event payloads are untrusted: a practical security guide

An interactive coding assistant mostly reads input you put in front of it. An event-driven agent reads input written by whoever can send an email, open a GitHub issue, trigger a Sentry exception, or post in a shared channel — often while nobody is watching the terminal.

SEP-3415 (io.modelcontextprotocol/events) states the core security rule bluntly: event payloads are untrusted data and must be handled with the same caution as tool results. Whether you are implementing an MCP Events server, building a webhook receiver, or wiring Linear, GitHub, and Slack triggers into Claude Code today, the security model comes down to four concrete layers: payload hygiene, three-stage authorization, webhook transport hardening, and runtime guardrails.

The two attack surfaces in event-driven agents

SEP-3415's threat model separates attacks that apply to every delivery mode (events/poll, events/stream, and events/subscribe) from attacks unique to outbound webhooks:

  • All delivery modes: prompt injection hidden inside event data (for example an email subject or issue body containing instructions to exfiltrate secrets), PII or credentials leaking into event logs and queues, subscriptions continuing to deliver after a user loses upstream access, and runtimes treating event receipt as authorization to run privileged tools.
  • Webhook delivery (`events/subscribe`): SSRF and DNS rebinding (coercing an MCP server into POSTing to internal cloud metadata or RFC 1918 addresses), reflection/amplification flooding against third-party URLs, spoofed deliveries, replay of captured requests, response-oracle probing via error messages, and cross-tenant subscription tampering.

If you only harden HMAC signatures and ignore prompt injection or tool permissions, an attacker does not need to forge a webhook — they just send a legitimate email or public GitHub comment and let your signed pipeline carry their payload straight to the model.

Layer 1: Payload minimality and untrusted framing

The cheapest way to shrink both prompt-injection risk and PII exposure is to stop stuffing full document bodies into event payloads.

SEP-3415 explicitly recommends payload minimality:

  • Send triage fields, not full content. An email.received event should carry messageId, from, subject, and receivedAt — not the entire HTML body and attachments. Let the agent decide whether the event is worth handling and fetch full content on demand via authorized MCP tools.
  • Cap delivery size. SEP-3415 recommends keeping webhook bodies at or under 256 KiB. Receivers and WAFs may reject larger bodies with 413 Payload Too Large, which servers must treat as non-retryable.
  • Support payload-shaping arguments where appropriate. Event types can expose options like redact_pii: true or include_body_preview: false in inputSchema so sensitive fields never enter downstream logs or buffers.
  • Sandbox and delimit before the LLM sees it. Treat every event occurrence's data field as untrusted external text, never as live user approval. Even Claude Code's own scheduled tasks docs emphasize that a fired trigger is not live user consent for sensitive actions during a run.

Layer 2: Authorization at three checkpoints

SEP-3415 enforces authorization at three distinct points in the lifecycle. Skipping any one of them leaves a real privilege-escalation hole:

  1. Subscribe time. When a caller is authenticated, the server must verify the principal is allowed to watch that (name, arguments) combination — for example, checking that the user actually has access to a private Slack channel before subscribing. Unauthorized requests return Forbidden (-32024). Unauthenticated MCP servers may offer poll or push, but must not offer webhook mode, because without a principal in the subscription key (principal, delivery.url, name, arguments), any caller could guess another tenant's tuple to unsubscribe them or rotate their secret.
  2. Delivery time. Permissions change. A server should periodically re-check whether the principal still has access to the upstream resource. When access is revoked, the server terminates the subscription immediately — via notifications/events/terminated on push streams, a signed {"type":"terminated",...} control envelope on webhooks, or a Forbidden JSON-RPC error on the next poll.
  3. Action time. Receiving an event never grants permission to act. When the agent responds to an event by calling tools (reading files, editing code, running shell commands, commenting on a PR), every tool call must pass through normal MCP authorization and host policy checks.

Layer 3: Hardening MCP webhook delivery (SEP-3415 checklist)

If you are building an MCP Events server or a webhook forward proxy for events/subscribe, SEP-3415 specifies an unusually thorough set of transport requirements. Check every one of these before exposing webhook mode in production:

ControlSEP-3415 requirementWhat it prevents
TLS onlyReject non-https:// delivery.url with InvalidParams (-32602)Cleartext payloads and delivery.secret interception
Client-supplied HMAC secretRequire whsec_ + base64 of 24–64 CSPRNG random bytes; verify v1, HMAC-SHA256 over webhook-id + "." + webhook-timestamp + "." + rawBody before JSON parsingForged deliveries and post-subscribe secret write-back races
Freshness & deduplicationReject webhook-timestamp older than 5 minutes; deduplicate HTTP retries on webhook-id and app events on (X-MCP-Subscription-Id, eventId)Replay attacks and duplicate agent runs
Secret rotationClient supplies a new delivery.secret on refresh; server dual-signs with old and new keys (v1,... v1,...) during a short grace windowDropped events during rotation and long-lived leaked secrets
Optional server identityOptional v1a, Ed25519 signature verified against JWK signingKeys fetched from the MCP server's own Server Card origin (no cross-origin redirects)Server impersonation on shared multi-server gateways
Mandatory endpoint verificationConfirm intent before activating via challenge nonce ({"type":"verification","challenge":"..."} echoed in constant time), allowlist, out-of-band confirmation, or /.well-known/mcp-webhook-receiver.json, cached per (principal, url)Reflection and flooding DDoS against victim URLs
Delivery-time SSRF defenseResolve DNS at delivery time (not only subscribe time), block IANA special-purpose ranges (127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16, ::1, fc00::/7, fe80::/10), connect directly to the validated IP with original Host and TLS SNI, and disable HTTP redirectsSSRF into internal networks and DNS rebinding bypasses
Error sanitizationReport failures in deliveryStatus.lastError using fixed categories only (connection_refused, timeout, tls_error, http_4xx, http_5xx, challenge_failed) — never raw response bodies or headersUsing the MCP server as an internal network response oracle
TTLs & quotasNegotiate finite refreshBefore grants, enforce ResourceExhausted (-32025) subscription caps, and support events/unsubscribe kill switchesOrphaned subscriptions and resource exhaustion

One subtle implementation bug to watch for in receivers: always compute the Standard Webhooks HMAC over the exact raw HTTP body bytes, never over JSON.stringify(req.body) after parsing. And use the X-MCP-Subscription-Id header to look up the right secret before touching the body parser.

Layer 4: Practical guardrails for Claude Code triggers today

Most teams are not writing an MCP Events server from scratch this week — they are wiring Linear, GitHub, Slack, Sentry, or webhooks into Claude Code right now via channels, routines, or an agent orchestrator. The same threat model applies immediately:

  • Never trigger privileged runs on untrusted public sources. Cursor Automations explicitly blocks PR triggers from forks for this reason: running untrusted code or untrusted PR text with your repository's secrets and push permissions is an easy exfiltration path. Keep triggers scoped to trusted repos, private workspaces, or allowlisted senders.
  • Lock down sender allowlists on Claude Code channels. In Claude Code channels, anyone on the sender allowlist can not only inject messages into your live session, they can also answer permission relays if enabled. Pair explicitly and keep allowlists tight.
  • Restrict tool permissions by default. An event-triggered session investigating a bug or triaging a ticket does not need unrestricted shell access or production write credentials. Configure explicit tool allowlists — in Cyrus, allowed tools lets you scope exactly which commands and MCP tools a Linear, GitHub, or Slack session may execute.
  • Isolate execution and keep humans on the merge button. Run every triggered task in its own Git worktree or sandbox so a bad or injected run cannot corrupt other branches, and require human review before any agent-authored pull request merges.
  • Keep an instant kill switch and audit log. Make sure you can revoke a trigger, pause a repo's event transport, and inspect which upstream event started which session and tool call.

At Cyrus, this is why we built the event layer as a context router — a switchboard for agent context with guardrails and low latency sitting between your upstream tools and Claude Code. Cyrus verifies inbound webhook signatures, filters and routes events to the matching repository and isolated Git worktree, enforces configurable per-workflow tool permissions, documents our threat model in our agent security docs, and has completed an independent SOC 2 Type II audit. Cyrus also supports Claude Code channels, so teams can move at the speed of data across Linear, GitHub, Slack, and webhooks.

For the full protocol mechanics behind these controls, see What are MCP Events? and MCP Events vs webhooks vs polling (and Claude Code channels).

Frequently asked questions

Why are MCP event payloads treated as untrusted data?

Because event payloads originate in external systems — inbound emails, issue comments, chat messages, error stack traces — where third parties or attackers can control the text. An unattended agent reading that text without sandboxing and tool restrictions is vulnerable to indirect prompt injection.

Why does SEP-3415 require both HMAC signing and endpoint verification for webhooks?

HMAC signing with a client-supplied whsec_ secret stops an attacker from forging fake events to your receiver, because unsigned or mis-signed POSTs fail verification. It does not stop an attacker from subscribing a victim's URL with an attacker-chosen secret and flooding the victim with POST traffic. Mandatory endpoint verification (such as the challenge nonce handshake or /.well-known/mcp-webhook-receiver.json) closes the flooding vector.

Why is subscribe-time IP validation not enough to stop SSRF?

Because of DNS rebinding. An attacker's DNS server can return a public IP when the server validates delivery.url during events/subscribe, then return 169.254.169.254 or 127.0.0.1 minutes later when an event fires. SEP-3415 requires resolving DNS at delivery time, validating the resolved IP against IANA special-purpose blocklists, connecting directly to that IP with the original Host header and TLS SNI, and refusing HTTP redirects.

Does receiving an MCP Event authorize the agent to run tools?

No. SEP-3415 explicitly separates event receipt from action-time authorization. Any tool call an agent decides to make in response to an event must go through normal MCP authorization and the host runtime's tool-permission policies.

Team of engineers preparing a rocket for launch - Ship your next feature with Cyrus
Trusted by product teams at Retool, Gamma, TinyFish, and more

Break free from the terminal

As your Claude Code powered Linear agent, Cyrus is capable of accomplishing whatever large or small issues you throw at it. Get PMs, designers and the CEO shipping product.

MCP event payloads are untrusted: a practical security guide | Cyrus