From eb9e915805bdf9140e1b3cbdddc82201fa52dc48 Mon Sep 17 00:00:00 2001 From: tgiachi Date: Mon, 9 Nov 2026 20:23:07 +0100 Subject: [PATCH] fix(security): hold posts whose From header does not match the sender - Judge membership on the envelope sender and require the From header to name the same address - Hold mismatches (and missing, unparsable or multiple From addresses) for the admin instead of delivering - Record why a message was held: new held.reason column, migrated, shown in the API, CLI and UI - Accept an empty message in the held queue - Document who may post --- README.md | 5 ++ admin/src/lib/api.ts | 2 + admin/src/tabs/HeldTab.test.tsx | 16 ++++++ admin/src/tabs/HeldTab.tsx | 2 + internal/api/api.go | 3 +- internal/api/api_test.go | 5 +- internal/cli/cli_test.go | 8 +-- internal/cli/commands.go | 5 +- internal/router/identity_test.go | 97 ++++++++++++++++++++++++++++++++ internal/router/m2_test.go | 2 +- internal/router/m3_test.go | 19 +++++-- internal/router/router.go | 50 ++++++++++++++-- internal/router/router_test.go | 4 +- internal/store/m2_test.go | 36 +++++++++++- internal/store/store.go | 32 ++++++++--- 15 files changed, 252 insertions(+), 34 deletions(-) create mode 100644 internal/router/identity_test.go diff --git a/README.md b/README.md index e012e8e..41e7b58 100644 --- a/README.md +++ b/README.md @@ -208,6 +208,11 @@ lists.example.org lmtp:inet:127.0.0.1:2424 The daemon logs a warning at startup when LMTP is reachable beyond the machine and `lmtp.allow` is empty. `allow` does not apply to unix sockets: use the permissions of the socket file. +- **Who is posting.** A post is accepted when the SMTP sender is a member *and* the `From` header names the same + address. The SMTP sender can be forged by anyone who can send mail to your MX, and the archive, the rewritten `From` + and `Reply-To` come from the header; so a post whose header names someone else (or has no usable `From`, or several + addresses) is held for moderation instead of delivered, with the reason shown to the admin (API, CLI, UI). Let Postfix + reject forged senders too (SPF, DKIM, DMARC checks on inbound mail). - The API and the admin UI use one bearer token and no TLS: put them behind a reverse proxy with TLS and keep the `api` listener private. diff --git a/admin/src/lib/api.ts b/admin/src/lib/api.ts index a33e798..4cab84b 100644 --- a/admin/src/lib/api.ts +++ b/admin/src/lib/api.ts @@ -28,6 +28,8 @@ export interface Held { subject: string size: number created_at: string + /** Why the message was held, for the admin. */ + reason: string } export interface Message { diff --git a/admin/src/tabs/HeldTab.test.tsx b/admin/src/tabs/HeldTab.test.tsx index 939a393..3a0c169 100644 --- a/admin/src/tabs/HeldTab.test.tsx +++ b/admin/src/tabs/HeldTab.test.tsx @@ -10,6 +10,7 @@ const held = (id: number, over: Partial = {}): Held => ({ subject: `Subject ${id}`, size: 2048, created_at: '2030-01-02T03:04:05Z', + reason: 'the list is moderated', ...over, }) @@ -30,6 +31,21 @@ describe('held tab', () => { expect(screen.getByText('(no subject)')).toBeInTheDocument() }) + it('tells the admin why each message was held', async () => { + await setup([ + held(1), + held(2, { reason: 'the From header does not match the sender of the message (From: bob@example.com)' }), + held(3, { reason: '' }), + ]) + const one = (await screen.findByText('Subject 1')).closest('tr')! + expect(within(one).getByText('the list is moderated')).toBeInTheDocument() + const two = screen.getByText('Subject 2').closest('tr')! + expect(within(two).getByText(/From header does not match the sender/)).toBeInTheDocument() + const three = screen.getByText('Subject 3').closest('tr')! + expect(within(three).getByText('—')).toBeInTheDocument() // messages held before this was recorded + expect(screen.getByRole('columnheader', { name: /reason/i })).toBeInTheDocument() + }) + it('says nothing is waiting', async () => { await setup([]) expect(await screen.findByText(/nothing is waiting/i)).toBeInTheDocument() diff --git a/admin/src/tabs/HeldTab.tsx b/admin/src/tabs/HeldTab.tsx index 2abf69d..bccaa48 100644 --- a/admin/src/tabs/HeldTab.tsx +++ b/admin/src/tabs/HeldTab.tsx @@ -63,6 +63,7 @@ export function HeldTab() { From Received Size + Reason Actions @@ -73,6 +74,7 @@ export function HeldTab() { {h.sender} {formatDate(h.created_at)} {formatBytes(h.size)} + {h.reason || '—'}