Skip to content

Log DMARC DNS lookup failures instead of silently skipping protection - #2074

Open
paulmenzel wants to merge 1 commit into
sympa-community:mainfrom
paulmenzel:dmarc-log-dns-lookup-failure
Open

Log DMARC DNS lookup failures instead of silently skipping protection#2074
paulmenzel wants to merge 1 commit into
sympa-community:mainfrom
paulmenzel:dmarc-log-dns-lookup-failure

Conversation

@paulmenzel

Copy link
Copy Markdown

No description provided.

`_check_dmarc_rr()` uses `Net::DNS::Resolver::query()`, which returns undef
both when the sender domain publishes no DMARC record and when the lookup
itself fails. The failure case is therefore taken for "no record", From: is
left unmunged and the message is rejected by receivers enforcing DMARC, with
no log entry at any log level - not even at `log_level 5`, which shows only:

    [debug] DMARC protection on
    [debug] From address: <someone@gmx.de>

Lookups do fail in practice. In issue sympa-community#1969 SELinux blocked the daemon's UDP
socket, the only trace being an AVC in /var/log/audit/audit.log:

    type=AVC msg=audit(1752302753.696:85038): avc:  denied  { create } for pid=1739896 comm="bulk.pl" scontext=system_u:system_r:sympa_t:s0 tcontext=system_u:system_r:sympa_t:s0 tclass=udp_socket permissive=0

A systemd sandbox, a firewall or a broken resolver produce the same silence.

Use `send()`, which returns a packet whenever the resolver replied at all –
including NXDOMAIN and NOERROR with an empty answer section – and undef only
on a real transport or resolver failure, and report that failure:

    [err] DNS lookup of "_dmarc.gmx.de" TXT failed: Network is unreachable.  DMARC protection is not applied

`$packet->answer` stays empty for domains without a record, so the remaining
logic is unchanged.

Verified against sympa 6.2.76~dfsg-1 on Debian 13 (trixie), Net::DNS 1.56,
perl 5.40.1: From: someone@gmx.de (v=DMARC1; p=quarantine) with
`dmarc_protection.mode=dmarc_reject,dmarc_quarantine` is still munged with
working DNS, the new err entry appears with the network removed, and
someone@iana.org (p=none, and a NXDOMAIN subdomain of it) logs no error.

Assisted-by: Claude Opus 5 (Claude Code)
@paulmenzel

Copy link
Copy Markdown
Author

Description is in the commit message.

@ikedas ikedas added this to the 6.2.82 milestone Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants