Skip to content

Commit

Permalink
for dmarc reporting, be more conservate with sending reports to junky…
Browse files Browse the repository at this point in the history
… senders, and format textual dmarc report period in the message text in utc as claimed

before this change, a message in the rejects folder that was read and marked as
notjunk (e.g. automatically by webmail), could cause a dmarc report to be sent
for another junky message from the domain. we now require positive signals to
be for messages not in the rejects mailbox.

the text/plain body of a dmarc report contains the period, but it was in local
time while claiming to be in utc. make it utc, so we often get nicely rounded
whole 24h utc days.
  • Loading branch information
mjl- committed Nov 4, 2023
1 parent c955fad commit 2abac1a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dmarcdb/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,8 @@ specified in the "rua" field of the DMARC record for your domain.
Report domain: %s
Submitter: %s
Report-ID: %s
Period: %s - %s in UTC
`, dom, mox.Conf.Static.HostnameDomain, report.ReportMetadata.ReportID, beginTime.Format(time.DateTime), endTime.Format(time.DateTime))
Period: %s - %s UTC
`, dom, mox.Conf.Static.HostnameDomain, report.ReportMetadata.ReportID, beginTime.UTC().Format(time.DateTime), endTime.UTC().Format(time.DateTime))

// The attached file follows the naming convention from the RFC. ../rfc/7489:1812
reportFilename := fmt.Sprintf("%s!%s!%d!%d!%s.xml.gz", mox.Conf.Static.HostnameDomain.ASCII, dom.ASCII, beginTime.Unix(), endTime.Add(-time.Second).Unix(), report.ReportMetadata.ReportID)
Expand Down
1 change: 1 addition & 0 deletions smtpserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2480,6 +2480,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
q := bstore.QueryTx[store.Message](tx)
q.FilterNonzero(store.Message{MsgFromOrgDomain: m.MsgFromOrgDomain})
q.FilterEqual("Notjunk", true)
q.FilterEqual("IsReject", false)
exists, err := q.Exists()
if err != nil {
return fmt.Errorf("querying for non-junk message from organizational domain: %v", err)
Expand Down

0 comments on commit 2abac1a

Please sign in to comment.