Skip to content

Fix SPF record selection to prefer highest version regardless of DNS order - #38

Open
Munrok wants to merge 2 commits into
fastmail:mainfrom
Munrok:main
Open

Fix SPF record selection to prefer highest version regardless of DNS order#38
Munrok wants to merge 2 commits into
fastmail:mainfrom
Munrok:main

Conversation

@Munrok

@Munrok Munrok commented Aug 12, 2026

Copy link
Copy Markdown

ail::SPF::Server::select_record() currently determines the preferred
record class from $records[0]. This makes record selection depend on
the order of resource records returned by DNS.

When both a v=spf1 record and an applicable spf2.0/mfrom record are
present, reversing their DNS RR order can therefore change the result.

select_record() already documents that records of the highest
acceptable version should be selected. This change determines the
preferred class from the requested versions instead of from the first
DNS record.

A regression test has also been added with the v=spf1 record appearing
before the spf2.0/mfrom record.

This keeps the existing Sender ID support deterministic without
otherwise changing its behavior.

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