Your SPF record can be valid, published, and completely ignored
There's a failure mode in SPF that produces no error anywhere you'd think to look. Your record is syntactically valid. dig returns it. Your DNS provider is happy. Your own test mail arrives fine. And yet some of your mail is failing authentication at the receiver, and nothing in your infrastructure will tell you. The cause is usually that you've gone past ten DNS lookups. Ten is a hard ceiling,…
A subtle issue exists with SPF records that can cause them to be ignored even when syntactically valid. The failure occurs when the DNS resolution tree surpasses ten lookups, which is a strict limit set by RFC 7208. If the limit is exceeded, the receiver treats the entire SPF record as invalid and fails authentication.
This issue is not easily noticeable since the record is valid syntactically and passes tests like dig. Moreover, receivers do not degrade gracefully, so they treat the entire record as unusable once the limit is exceeded. Consequently, the problem is only detectable through DMARC aggregate reports, which many users may not be monitoring.
The limit is not within the control of the domain owner; it applies to the entire resolution tree, not just the domain's record. Adding more includes to the SPF record can easily cause it to exceed the limit. For example, if one vendor includes six other vendors in their SPF record, and each of those vendors includes additional hosts, the total count can easily exceed ten.
To identify and resolve this problem, one can use a tool like notspoofed, which walks the complete include tree, handles redirect= correctly, counts against the real limit, and generates a corrected record by flattening the SPF as needed. By aiming for a lower number, such as seven or eight, there is more headroom to add new senders without causing SPF failures.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.