Repository navigation
Tell agents whether an incoming sender was checked - #57
Merged
Merged
Conversation
Received messages now carry senderAuthentication in message reads, lists, thread reads, and email.received events. It is authenticated only when the From domain passed DMARC, unauthenticated when a scan ran without a DMARC pass, and unchecked when no scan ran. The hosted service does not scan incoming mail yet, so until now a forged From address looked the same to an agent as a real one. The MCP server instructions and the get_message and get_thread descriptions now tell the model to treat from as unverified unless it is authenticated, and that triage never authorizes an action. The agent guide and the message, quarantine, webhook, and MCP docs explain the field. Co-authored-by: Cursor <cursoragent@cursor.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Received messages now carry
senderAuthentication, so an agent can tell a sender that passed a check from one that typed aFromaddress.authenticatedunauthenticateduncheckeduncheckedtoday.The field is set in
summary()inapps/email/src/mail-service.ts, so message reads, lists, searches, thread reads, and theemail.receivedwebhook all get it. Sent messages don't. Only a DMARC pass counts, because SPF and DKIM on their own can pass for a domain other than the one inFrom.On the hosted path, Cloudflare Email Routing hands the Worker raw mail, and with
MAIL_INBOUND_SCAN_ENABLEDoff, nothing checks SPF, DKIM, or DMARC. Until now a forged invoice from a vendor's real address reached agents labelledreceived, unreadwith noprotectionblock, and nothing in the API or the webhook said the sender was never checked.Agent-facing text also changed:
senderAuthenticationisauthenticated, and say that triage never authorizes an action.get_messageandget_threadrepeat the sender rule in their tool descriptions, because some MCP hosts never pass server instructions to the model.docs/developers.md, and the Worker README explain the field. The quote on the MCP page had drifted from the server text ("dashboard" vs "human dashboard") and now matches it exactly.docs/openapi.json, the client types and manifest, and the public docs site are regenerated withpnpm api:generateandpnpm docs:generate.How it was tested
apps/email/test/protection.test.tscovers all three values inlistMessages,getMessage,getThread, and the queuedemail.receivedevents. It also covers a forged message an owner released from quarantine (unauthenticated) and a sent reply (no field). With themail-service.tschange removed, the test fails on the list comparison. With it, the test passes.pnpm build,pnpm check(which runsapi:check),pnpm docs:check,pnpm source:check, andpnpm testall pass on the pushed commit. Worker: 263 passed, 1 skipped. Dashboard 53, gateway 21, web 22, client 6, CLI 4, MCP 1, no failures.pnpm test:postgreswas not run because no SQL changed.Before and after
Forged invoice through the Cloudflare intake path
A probe script sends a forged invoice (
From: billing@vendor.example, with a body telling the assistant to send invoices to an attacker) throughacceptIncomingand thenprocessIncoming. Those are the calls the Worker'semail()handler makes. No scanner is configured, which matches hosted production. The probe then reads the message with an account API key overGET /v1/inboxes/{inboxId}/messages/{messageId}and reads the queuedemail.receivedpayload. Two more runs inject scanner results: a DMARC pass, and a clean scan from a domain with no DMARC policy.origin/main7464e7b)senderAuthentication, noprotection"unchecked"senderAuthentication"authenticated"senderAuthentication"unauthenticated"The API read and the webhook agree in every case. Raw output for the forged invoice:
What an MCP client sees
Output from an MCP client connected to the hosted
/mcpendpoint with amessages:readkey.Docs
Built docs pages from
origin/mainand from this branch, served locally.Test doubles
All evidence ran in-process against PGlite. Object storage (R2) is an in-memory map. Cloudflare Email Routing (
ensureInboxRoute) and domain verification (verifyDomain) are stubs. Cloudflare Email Sending (send) is the test fixture's mock, and in the probe it throws if called. Scanner results are injected objects, so no Rspamd or ClamAV ran. No real mail was received or sent, and triage was not involved.Risks and follow-up
protection, so it needs no migration or backfill. Older hosted mail reads asunchecked, which is correct.MAIL_INBOUND_SCAN_ENABLEDfor the hosted domain. That needs the gateway scanners deployed and owner sign-off. Until then every hosted message isunchecked.Authentication-Resultsheader to get an SPF result with the real connecting IP. That needs testing against real Cloudflare mail first.email.receivedevent, butreleaseQuarantinequeues one, and an existing test asserts it. I left that wording alone because it's a separate fix.mail-service.ts, the Worker README, andprotection.test.tsare Bezalel files already declared modified inSOURCE.json. This field could go back to Bezalel in a separate reviewed change.