Repository navigation
fix(email): authorize private replies with recipient-bound Message-IDs (WI-2365) - #567
stefan-ernst wants to merge 4 commits into
Conversation
Inbound email attributed every message to a portal customer and admitted replies to a private thread based on the attacker-controlled From header. Neither the customer match nor the thread-participant guard consulted Authentication-Results, Received-SPF, DKIM, or DMARC, so anyone able to deliver a spoofed From could post into a private thread, become a persistent participant, or create a request as a customer. Evaluate the receiving MTA's Authentication-Results (falling back to Received-SPF) against the From domain and require an aligned SPF, DKIM, or DMARC pass. Only headers above the first Received header are trusted, so a sender-injected Authentication-Results below the receiving MTA's Received header is ignored. Under the default strict policy, mail whose sender cannot be authenticated is held: no item or comment is created, no portal customer is matched or created under the claimed identity, and the outcome is recorded on the tracking row for the admin diagnostics view and channel email log. Mailbox and intake policies can be set to strict or off for providers that do not add authentication headers. - internal/email/sender_auth.go: parser, alignment, and policy resolution - parser records header order so injected results can be rejected - email_message_tracking.sender_auth and intakes.sender_authentication - mailbox and per-intake sender-authentication controls in the UI
- Trust only results above a mailbox-specific receiver boundary: the first Received hop whose host matches the mailbox's trusted authserv-ids (explicit config, provider defaults, or the mail host). A result from an untrusted authserv-id is rejected, and a message with no trusted hop fails closed instead of trusting an arbitrary header. An internal delivery hop above a genuine result no longer discards it. - Parse Authentication-Results per RFC 8601: clauses split outside quoted strings and comments, and a method is accepted only as the first token of a clause, so a quoted diagnostic can never be read as a verdict. - Reject Received-SPF passes without an envelope-from; a HELO pass authenticates the sending host, not the sender. - Use organizational-domain comparison for SPF and DKIM alignment, and compare a DMARC header.from to the actual From domain directly, so sibling subdomains under one organizational domain align. - Give authentication holds a distinct action: the scheduler leaves the original in the mailbox (never delete or mark read) and reports the hold, including on a deduplicated retry. - Preserve an explicit per-intake strict override when editing an intake; it is no longer collapsed into inherit. - Return and display skipped_reason in the channel email log so a held message is identified instead of showing a raw spf=pass summary. - Read header order line by line instead of splitting the whole body.
…s (WI-2365) Supersede the strict sender-authentication hold (WI-2362): intake no longer requires an SPF/DKIM/DMARC pass, and the claimed From is never an identity. - Mint a cryptographically random, per-recipient Message-ID for every replyable outbound delivery. The reply outbox persists item, recipient and Message-ID together, so an outbox retry reuses the same reply key. - Authorize an email reply onto an existing private request only when it references a Windshift-issued outbound Message-ID whose intended recipient is the claimed sender, and that sender is still the creator or an active participant. Inbound/legacy/missing IDs and removed or unverified senders start a separate staff-visible request instead. - Build In-Reply-To/References per recipient so another participant's reply key is never exposed. - Authorize before creating a portal customer or granting access; a new request records a contact address without granting portal access.
|
Size Change: 0 B 🆕 Total Size: 0 B |
- Reply keys expire after 30 days but outbox rows are retained for 90 days before pruning, so an expired key can never authorize and the row stays available for audit. - A staff reply is no longer dropped when the original mail had no Message-ID: empty threading headers still enqueue and send the reply. - Automation and participant notices persist their reply key before crossing the SMTP boundary, so a sent notice can always be replied to. - Pre-upgrade outbound IDs (no recipient-bound outbox row) are tolerated only on the ticket that recorded them; a ticket with a recipient-bound key, and every new ticket, requires an exact reply key. - Remove the strict sender-authentication controls: the mailbox and intake policy fields, the frontend selectors and locale strings, the scheduler hold handling, and the policy helpers. The SPF/DKIM/DMARC verdict is still recorded for diagnostics, but intake never gates on it.
e5e84ce to
7b884c0
Compare
|
Request changes. The random per-recipient IDs are a good foundation, but this PR still treats some historical IDs as credentials and some unverified senders as request owners. Findings below are against
Verification: |
Summary
Fixes WI-2365. Supersedes the strict sender-authentication hold from WI-2362 / #566: intake no longer requires an SPF/DKIM/DMARC pass, and the claimed
Fromis never treated as an identity. Whether a message may update a private conversation is decided by a recipient-bound outbound Message-ID (a reply key).The branch is stacked on the WI-2362 branch, so the diff includes that foundation; the WI-2362 hold itself is removed here.
What changed
Reply keys
newReplyMessageID, 128 bits fromcrypto/rand). It is generated once and persisted on theemail_reply_outboxrow, so a delivery retry reuses the same key. The existing mailbox address is kept (no plus-addressing).Authorization (
internal/email/processor.go)lookupReplyKey→email_reply_outbox), andRecipient-specific threading (
internal/services/email_reply_service.go)loadItemThread+threadHeadersForRecipientbuildIn-Reply-To/Referencesper recipient: the conversation root, inbound messages, and only that recipient's own prior reply keys. Another recipient's reply key is never copied into the headers.Strict sender-authentication controls removed
email_sender_authenticationand intakesender_authenticationfields, the frontend selectors and locale strings, the scheduler hold handling, and the policy helpers.Acceptance criteria
Fromgrants no portal/thread access.In-Reply-To/References; mailbox address unchanged.Testing
go build ./...,go vet,gofmt,golangci-linton touched packages: clean../overlay.sh ../core -- -tags=test -count=1 ./internal/services/...passes../internal/handlers/...,./internal/database/...pass.npm run checkandnpm run typecheck: clean.core-testsrepository.