panel-notifications: findings of the technical and security reviews
test / test (push) Canceled after 0s
test / test (push) Canceled after 0s
Neither review (read-only agents, Opus and Fable, over 972a9f8..400aa76) has a Critical finding. Both found the same serious one, and more: - The notification about refused mail was built on what a rejected row says of itself. Its domain is the one in MAIL FROM, which the client typed and Postfix has not yet held against the login when the milter refuses: an application over its limit could have had the panel write a message per made-up domain, to another tenant's users among others. And the same status is written when an application is refused for its client address, which is no limit. Refusals are now counted by the domain the login is registered under, only for logins that exist and only while a limit is set on the login or its domain; one subject per sending domain. They are read through a partial index of their own (migration 0005): the query walked the whole send log every minute. - Account and user e-mails were checked with the DMARC report validator, which refuses Gmail and the like - the owner's own kind of address. A new validate.AccountEmail accepts them and refuses a local part beginning "-". - "Said" now means sent: what arises while nobody can be told, or while Postfix does not take the message, is told at a later check. Its ending with nobody left to tell is simply over. - Two DNS checks must be 45 minutes apart as well as two: the last check before a restart and the first after it were minutes apart. - The notifier's own mail waiting in the queue, and its bounce coming back to postmaster@ this server, are not the queue's subject. A listing cut at its size limit or with a line too long to read is no listing; postqueue -j gets 30 seconds. - The tables must name the selector the panel shows, not only have the line. - An a/mx lookup that did not answer inside the SPF check made the record "not authorising"; it is "cannot tell" now, for the pages too. - A ceiling of 60 messages an hour; a pass stops between domains when the process is asked to stop; sendmail gets a WaitDelay; days are rounded as a person counts; a failed read of the switch shows it on, not off. Recorded as accepted in security.md, with a roadmap candidate (from-header-binding): an application can have a message signed as the server's own name - or, as always, as another registered domain - by writing it into the From: header, which nothing holds against the login. Left as found: a recipient whose copy failed while another's went out is not tried again; a certificate that lives under 14 days is reported at each renewal. On the test server, for this tree: go vet clean, go test ./... 23 packages ok, make e2e ok (326 s). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+24
-13
@@ -163,22 +163,33 @@ func (o *OpenDKIM) Rebuild(domains []SigningDomain) error {
|
||||
return o.reload()
|
||||
}
|
||||
|
||||
// signs reports whether the SigningTable on disk has a line for name. A table
|
||||
// that does not exist yet signs nothing.
|
||||
func (o *OpenDKIM) signs(name string) (bool, error) {
|
||||
data, err := os.ReadFile(o.signingTablePath)
|
||||
if os.IsNotExist(err) {
|
||||
// signs reports whether the tables on disk sign name with the key of
|
||||
// selector: a line for the name in the SigningTable, and in the KeyTable the
|
||||
// line that gives it that selector. Tables that do not exist yet sign nothing.
|
||||
// The selector is part of the question because the panel shows and checks the
|
||||
// record of one key; tables that name another would have OpenDKIM sign with a
|
||||
// key whose record nobody is told to publish.
|
||||
func (o *OpenDKIM) signs(name, selector string) (bool, error) {
|
||||
has := func(path, prefix string) (bool, error) {
|
||||
data, err := os.ReadFile(path)
|
||||
if os.IsNotExist(err) {
|
||||
return false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("read %s: %w", filepath.Base(path), err)
|
||||
}
|
||||
for _, line := range strings.Split(string(data), "\n") {
|
||||
if strings.HasPrefix(line, prefix) {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("read SigningTable: %w", err)
|
||||
signed, err := has(o.signingTablePath, "*@"+name+" ")
|
||||
if err != nil || !signed {
|
||||
return false, err
|
||||
}
|
||||
for _, line := range strings.Split(string(data), "\n") {
|
||||
if strings.HasPrefix(line, "*@"+name+" ") {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
return has(o.keyTablePath, name+" "+name+":"+selector+":")
|
||||
}
|
||||
|
||||
// Reload asks OpenDKIM to re-read its tables without regenerating them. It
|
||||
|
||||
@@ -126,11 +126,35 @@ func TestEnsureServerSignedRebuildsOnce(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
other.SetServerName("mail.example.org")
|
||||
if signed, err := otherOdk.signs("mail.example.org"); err != nil || signed {
|
||||
if signed, err := otherOdk.signs("mail.example.org", "selfpost"); err != nil || signed {
|
||||
t.Errorf("a longer name was taken for the server's: %v, %v", signed, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Tables that sign the server's name with the key of another selector - the
|
||||
// default selector was changed - are rebuilt: OpenDKIM must sign with the key
|
||||
// whose record the panel shows.
|
||||
func TestEnsureServerSignedFollowsTheSelector(t *testing.T) {
|
||||
svc, odk := newTestService(t, &fakeApps{})
|
||||
svc.SetServerName("mail.example.org")
|
||||
if _, err := svc.EnsureServerSigned(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
svc.selector = "sp2027"
|
||||
if rebuilt, err := svc.EnsureServerSigned(); err != nil || !rebuilt {
|
||||
t.Fatalf("after the selector changed: rebuilt = %v, %v; want a rebuild", rebuilt, err)
|
||||
}
|
||||
kt, _ := readTables(t, odk)
|
||||
if !strings.Contains(kt, "mail.example.org mail.example.org:sp2027:") || strings.Contains(kt, ":selfpost:") {
|
||||
t.Errorf("KeyTable after the rebuild:\n%s", kt)
|
||||
}
|
||||
mail, err := svc.ServerMail()
|
||||
if err != nil || mail.Selector != "sp2027" {
|
||||
t.Errorf("the panel shows selector %q (%v), the tables sign with sp2027", mail.Selector, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Without a hostname nothing is added and nothing is signed for it.
|
||||
func TestNoServerName(t *testing.T) {
|
||||
svc, odk := newTestService(t, &fakeApps{})
|
||||
|
||||
@@ -87,12 +87,18 @@ func (s *Service) ServerMail() (ServerMail, error) {
|
||||
// server's own name, rebuilding them if they do not. The tables are otherwise
|
||||
// rebuilt only when a domain is added or deleted, so an installation that was
|
||||
// upgraded to a version with notifications would go on sending them unsigned
|
||||
// until then. It reports whether it had to rebuild.
|
||||
// until then, and one whose DKIM_SELECTOR_DEFAULT was changed would go on
|
||||
// signing with the key of the old selector while the panel shows the record
|
||||
// of the new. It reports whether it had to rebuild.
|
||||
func (s *Service) EnsureServerSigned() (bool, error) {
|
||||
if s.serverName == "" {
|
||||
return false, nil
|
||||
}
|
||||
signed, err := s.odk.signs(s.serverName)
|
||||
selector, err := s.serverSelector()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
signed, err := s.odk.signs(s.serverName, selector)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -203,8 +209,10 @@ func (s *Service) Delete(id int64) error {
|
||||
return fmt.Errorf("rebuild sender map after deleting %s: %w", d.Name, err)
|
||||
}
|
||||
// A sending domain named like the server shared its key with the server's
|
||||
// own mail, which goes on being signed with it (resync above kept the name
|
||||
// in the tables).
|
||||
// own mail. The resync above kept the name in the tables under the default
|
||||
// selector: the same key if that was the domain's selector, a new one -
|
||||
// with a new record to publish, which Settings shows - if it was not.
|
||||
// Either way the directory holds the key now in use.
|
||||
if d.Name == s.serverName {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user