from-header-binding: the sender check, what it costs, its pages; guide, architecture, security
test / test (push) Canceled after 0s
test / test (push) Canceled after 0s
A message's From: line is held against the application that sends it, under the rule Postfix holds the envelope sender to. OpenDKIM chooses the key by that line, so until now an application could have mail signed as another domain of the server or as the server itself. The check (internal/milter/sender.go) - A role of the panel on a socket of its own (SENDER_CHECK_SOCKET), first in smtpd_milters and strict: default_action=tempfail. The journal milter keeps its socket and stays fail-open. postfix-wrapper waits for the new socket. - It reads no database: what an application may send as comes from Postfix's own sender_login_maps, what the server signs for from OpenDKIM's SigningTable. Both are read again when they change; one that cannot be read defers mail. - One From: field, one address, allowed by the envelope's lookup; then no other name of the SigningTable may appear anywhere in the raw line. Refused: 550 5.7.1 naming the line, reduced to printable ASCII. - A refusal is a send-log row with reason "from" and the header address (migration 0006), written by another goroutine and not waited for. The journal's refusals record their reason too (limit, client), and the notifier takes only a limit's. What it costs (docs/plans/from-header-binding.md, Statistics) - The role marks itself alive every 2 s; at start the gap since the mark is downtime, counted from Postfix's start if later and not at all when supervisord says Postfix is not running. - The log tailer counts the connections Postfix turned away: a warning that names the socket, then milter-reject "Service unavailable" from the same smtpd. Seen on the stand: the client is refused from CONNECT on and leaves at AUTH (454), so no MAIL line is ever written. - sender_check_days, a row per UTC day, kept a year. Pages - Health: the card "Sender check", the socket's row, and the cards layout - boxes numbered by importance in two stacks read in rows; the left stack polls, the three readings of the right one are swapped in by id. - Outbound log: a refused row says why in its tag (wrong From, wrong client, rate-limited); the message's page shows the From: line and what the application may send as. - Help: topic "Sender check", word for word the mockup's. Found by the stand, fixed here: the names for the second look came from the sender bindings, and a domain with a key and no application yet was not among them. e2e: negative_journal_milter_fail_open is gone - it proved that mail passes with the panel down, which is no longer so. In its place sender_check_holds_the_from_line (another domain's From:, the hostname's, a stranger's, an address off the list, another sender in the display name - refused; own addresses - delivered) and panel_down_defers_mail (4xx with the panel stopped, the container alive, mail again after, downtime and one deferred message on Health, the card warning). Test server, this tree before the last cosmetic edits (a fixture row, a fact's size, docs): go vet ok, go test 23 packages ok, make e2e ok (337 s). Locally after them: internal/web/view ok. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -63,15 +63,15 @@ func testLevel2RateLimit(t *testing.T, sc *scenario) {
|
||||
t.Fatalf("over the level-2 limit, two MAIL FROM on one connection were answered %v and %v, want both refused", errs[0], errs[1])
|
||||
}
|
||||
|
||||
if err := waitFor("a rejected row for l2app in the send log", 15*time.Second, 500*time.Millisecond, func() (bool, error) {
|
||||
if err := waitFor("a rate-limited row for l2app in the send log", 15*time.Second, 500*time.Millisecond, func() (bool, error) {
|
||||
rows, err := sc.panel.sendLogRows(senderDomain, login)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if containsCell(rows, "rejected") {
|
||||
if containsCell(rows, "rate-limited") {
|
||||
return true, nil
|
||||
}
|
||||
return false, fmt.Errorf("no rejected row for l2app yet")
|
||||
return false, fmt.Errorf("no rate-limited row for l2app yet")
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -127,46 +127,6 @@ func testForeignRelayRejected(t *testing.T, sc *scenario) {
|
||||
}
|
||||
}
|
||||
|
||||
// testJournalMilterFailOpen is plan C.4 negative check 6: the journal-milter
|
||||
// is monitoring-only and fails open (architecture.md § Mail path) — stopping
|
||||
// the panel process (which owns the milter socket) must not block mail, and
|
||||
// must not crash the container (crashexit only fires on PROCESS_STATE_FATAL, a
|
||||
// clean supervisor stop is STOPPED, see build/crashexit.py).
|
||||
func testJournalMilterFailOpen(t *testing.T, sc *scenario) {
|
||||
if _, err := h.execIn("selfpost", "supervisorctl", "-c", "/etc/supervisor/supervisord.conf", "stop", "panel"); err != nil {
|
||||
t.Fatalf("stop panel: %v", err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
_, _ = h.execIn("selfpost", "supervisorctl", "-c", "/etc/supervisor/supervisord.conf", "start", "panel")
|
||||
})
|
||||
|
||||
res := attemptSend(sendAttempt{
|
||||
authLogin: sc.appLogin, authPassword: sc.appPassword,
|
||||
from: "alerts@" + senderDomain, to: recipient,
|
||||
subject: "e2e " + uniqueToken("failopen"), body: "must still be accepted",
|
||||
})
|
||||
if !res.ok() {
|
||||
t.Fatalf("send with the journal-milter down was rejected, want fail-open accept: dial=%v auth=%v mail=%v rcpt=%v data=%v",
|
||||
res.dialErr, res.authErr, res.mailErr, res.rcptErr, res.dataErr)
|
||||
}
|
||||
|
||||
if err := checkContainerAlive(h); err != nil {
|
||||
t.Fatalf("container did not survive the panel stopping: %v", err)
|
||||
}
|
||||
|
||||
// Restart the panel (also undone by t.Cleanup, redundantly and harmlessly,
|
||||
// in case a later step needs it sooner than cleanup order guarantees).
|
||||
if _, err := h.execIn("selfpost", "supervisorctl", "-c", "/etc/supervisor/supervisord.conf", "start", "panel"); err != nil {
|
||||
t.Fatalf("restart panel: %v", err)
|
||||
}
|
||||
if err := waitFor("panel HTTP to answer again", 15*time.Second, 300*time.Millisecond, func() (bool, error) {
|
||||
_, err := sc.panel.status()
|
||||
return err == nil, err
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// checkContainerAlive confirms the container is still up after a component
|
||||
// stop — the crashexit listener must not have brought it down.
|
||||
func checkContainerAlive(s *stack) error {
|
||||
|
||||
Reference in New Issue
Block a user