Skip to content

mail-ingest: relay on an authenticated, local-only listener - #29

Merged
tcoretech merged 1 commit into
hardening/2026-09-26from
fix/mail-ingest-authenticated-relay
Nov 19, 2026
Merged

tcoretech merged 1 commit into
hardening/2026-09-26from
fix/mail-ingest-authenticated-relay

Conversation

@tcoretech

@tcoretech tcoretech commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

With PERMIT_DOCKER=none, mail-ingest isn't in mynetworks, so Postfix runs the SPF policy on every message it relays. It checks the original sender's SPF against mail-ingest's container address, so every sender that publishes -all is rejected with 550 5.7.23. The upstream provider has already checked SPF and DKIM by that point.

mailserver: a tracked config/user-patches.sh, copied in by prepare.sh, adds an smtpd on 10587 that isn't published on the host. It:

  • requires STARTTLS and a login as mail-ingest@<domain>; no other login is accepted (check_sasl_access)
  • uses reject_unauth_destination in both relay and recipient restrictions, so it can't relay even when authenticated
  • skips the policyd-spf check and keeps the quota policy
  • withholds the auth macros from milters, so Rspamd, OpenDKIM and OpenDMARC treat the message as inbound
  • refuses the same login on 587/465, so the credential can't send out

secrets.sh generates the password and startup.sh provisions the account, the same way as the other mail accounts.

mail-ingest: logs in after STARTTLS, verifying the certificate against MAILSERVER_WEBMAIL_HOSTNAME. It also checks RCPT replies, so a refused recipient is reported instead of being dropped when others are accepted.

Alternatives considered:

  • PERMIT_DOCKER=network/connected-networks reopens the relay to every container.
  • A static IP in skip_addresses ties trust to Docker addressing.
  • Plain SASL on 587 would let the credential relay out.

Tests: unit tests cover STARTTLS before login, no login without STARTTLS, the unauthenticated fallback, and refused and partly refused recipients. user-patches.sh was run twice against the DMS image: it's idempotent and passes postfix check.

…ops rejecting inbound

Since PERMIT_DOCKER=none, mail-ingest is no longer in mynetworks, so Postfix
runs the SPF policy on every message it relays. That checks the original
sender's SPF against mail-ingest's Docker address, so every sender that
publishes -all has been rejected with 550 5.7.23 (hotmail, Amazon SES,
Postmark, dribbble). ~all senders were delivered, which is why it went
unnoticed. Mailgun has already checked SPF and DKIM by the time we see the
message.

mailserver gets a second smtpd on 10587, added by a tracked user-patches.sh:
STARTTLS and a login as mail-ingest@ only, local recipients only, no SPF
policy, and the login hidden from the milters so Rspamd, OpenDKIM and
OpenDMARC still treat the message as inbound. The same login is refused on
587/465, so a leaked credential cannot send out. The password is generated by
secrets.sh and the account created by startup.sh, like the other mail
accounts.

mail-ingest logs in on that port, verifying the certificate against the
mailserver's public name. It now also checks RCPT replies: a refused
recipient used to surface only as "no valid recipients" at DATA, and with
several recipients a refused one was silently dropped.
@tcoretech
tcoretech merged commit ae1a771 into hardening/2026-09-26 Nov 19, 2026
@tcoretech
tcoretech deleted the fix/mail-ingest-authenticated-relay branch November 19, 2026 02:22
@tcoretech tcoretech changed the title mail-ingest: relay on an authenticated, local-only listener so SPF stops rejecting inbound mail-ingest: relay on an authenticated, local-only listener Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant