From 7681f8bdc8cb60777d1bb9bbcd73c0d293f1ad8f Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Sun, 12 Mar 2023 21:42:28 +0100 Subject: [PATCH] for localserve, validate the incoming message it must be completely parsable. normally, if we receive a message that we cannot fully parse, we accept it and treat it as opaque application/octet-stream. also make it more clear that localserve accepts email intended for any email address. --- doc.go | 4 ++-- localserve.go | 6 +++--- smtpserver/server.go | 12 ++++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc.go b/doc.go index 3af054b..bf43b5e 100644 --- a/doc.go +++ b/doc.go @@ -307,8 +307,8 @@ automatically initialized with configuration files, an account with email address mox@localhost and password moxmoxmox, and a newly generated self-signed TLS certificate. -All incoming email is accepted (if checks pass), unless the recipient localpart -ends with: +All incoming email to any address is accepted (if checks pass), unless the +recipient localpart ends with: - "temperror": fail with a temporary error code - "permerror": fail with a permanent error code diff --git a/localserve.go b/localserve.go index a782443..a6d9635 100644 --- a/localserve.go +++ b/localserve.go @@ -47,8 +47,8 @@ automatically initialized with configuration files, an account with email address mox@localhost and password moxmoxmox, and a newly generated self-signed TLS certificate. -All incoming email is accepted (if checks pass), unless the recipient localpart -ends with: +All incoming email to any address is accepted (if checks pass), unless the +recipient localpart ends with: - "temperror": fail with a temporary error code - "permerror": fail with a permanent error code @@ -120,7 +120,7 @@ during those commands instead of during "data". golog.Printf("the default admin password is moxadmin") golog.Printf("port numbers are those common for the services + 1000") golog.Printf("tls uses generated self-signed certificate %s", filepath.Join(dir, "localhost.crt")) - golog.Printf("all incoming email is accepted (if checks pass), unless the recipient localpart ends with:") + golog.Printf("all incoming email to any address is accepted (if checks pass), unless the recipient localpart ends with:") golog.Print("") golog.Printf(`- "temperror": fail with a temporary error code.`) golog.Printf(`- "permerror": fail with a permanent error code.`) diff --git a/smtpserver/server.go b/smtpserver/server.go index 6223efb..d05df65 100644 --- a/smtpserver/server.go +++ b/smtpserver/server.go @@ -1515,6 +1515,18 @@ func (c *conn) cmdData(p *parser) { } } + if Localserve { + // Require that message can be parsed fully. + p, err := message.Parse(dataFile) + if err == nil { + err = p.Walk(nil) + } + if err != nil { + // ../rfc/6409:541 + xsmtpUserErrorf(smtp.C554TransactionFailed, smtp.SeMsg6Other0, "malformed message: %v", err) + } + } + // Prepare "Received" header. // ../rfc/5321:2051 ../rfc/5321:3302 // ../rfc/5321:3311 ../rfc/6531:578