#26

Harden outbound mail delivery checks

MergedstylesshOwnermerged intofrom

Summary

  • reject duplicate SPF and DMARC policies during domain verification, even when one record matches the generated value
  • show a specific Multiple records state with actionable consolidation guidance in domain settings
  • document the production Cloudflare-over-TLS resolver requirement and its restore verification
  • fail the existing Stalwart production check when bogus DNSSEC/DANE events appear in recent logs

Production state

  • the Stalwart resolver is already set to Cloudflare DNS with TLS and persisted in the production data volume
  • the affected queued messages were rescheduled and accepted by the recipient provider; the queue is empty
  • the updated production check helper is installed, currently reports a healthy container and zero recent bogus-DNSSEC events, and retains the prior helper as a rollback copy

Validation

  • corepack pnpm test — 112 passed
  • corepack pnpm build — passed with Next.js 16.3.3
  • ESLint across the changed TypeScript, TSX, and MJS files — passed
  • bash -n deploy/stalwart/redakt-stalwart-deploy — passed
  • git diff --check origin/main...HEAD — passed
  • browser-tested the duplicate-SPF status and recovery copy at desktop and 320px; no horizontal overflow at 320px

Existing limitation

  • repository-wide pnpm lint still reports the two pre-existing CommonJS require findings in babel.config.js and postcss.config.js; neither file is changed here

Activity

4
mikeyreviewed3mo ago
mikey3mo ago

Review summary

Focused on the SPF/DMARC duplicate-policy detection (lib/dns/doh.ts, dns-records.tsx), the Stalwart deploy hardening (deploy/stalwart/redakt-stalwart-deploy), and the docs.

Correctness of the duplicate-policy detection is solid. policyConflict in lib/dns/doh.ts correctly anchors the SPF/DMARC regexes, normalizes chunked/quoted TXT data before comparing, only flags a conflict when more than one answer at the record's own host matches the same policy type, and leaves DKIM/other TXT records untouched. The new tests exercise the "single SPF among unrelated TXT records" (no false positive), "duplicate SPF", and "duplicate DMARC" cases, and summarizeRequiredDnsChecks/partitionDnsRecords/the Stalwart and demo providers all key off ok, so a conflict correctly keeps a domain out of the ready/ok state without any special-casing gaps. The UI change in dns-records.tsx renders the new "Multiple records" status and copy consistently with the existing mismatch-rendering pattern.

Non-blocking: the new DNSSEC check changes stalwart-update's exit-code semantics. Left an inline comment on deploy/stalwart/redakt-stalwart-deploy: the new "recent bogus DNSSEC events" gate in report_status is invoked both by the standalone stalwart-check probe and automatically at the end of a successful stalwart-update, after the rollback traps are already cleared. That means a transient/stale DANE log line in the 15-minute window can make an already-completed, healthy image swap exit non-zero, which .trylle/workflows/stalwart.yml (running under set -euo pipefail) will surface as a failed deploy — with no rollback and no way to distinguish "the update failed" from "the update succeeded but delivery is currently unhealthy." Worth deciding whether that conflation is intentional; if not, keep the DNSSEC gate scoped to stalwart-check or downgrade it to a warning after a successful update.

No security, auth, or data-handling issues found in this diff, and no missing tests for the new SPF/DMARC branch logic.

stylessh merged commit 25943a4 into main3mo ago

Branch stylessh/fix-durable-mail-delivery has been merged.

Checking branch