Dev.to Security 🔐 Cybersecurity 👁 0 📖 1 min read

SPF flattening: pros, cons and safer options

Flattening swaps include: entries for the IP addresses behind them, to get under SPF's 10-lookup limit. It works, but breaks silently when a service changes its addresses. What flattening is An SPF record may

Flattening swaps include: entries for the IP addresses behind them, to get under SPF's 10-lookup limit. It works, but breaks silently when a service changes its addresses.

What flattening is

An SPF record may use at most 10 DNS lookups. Each include: costs at least one, and the services you include often add more. Flattening replaces each include with the IP addresses it points to (ip4: and ip6: entries), which cost no lookups.

Pros

  • Gets you under the 10-lookup limit at once.
  • No change at your email services.

Cons

  • It goes stale. When a service adds or changes a sending address, your copied list is wrong and its email fails SPF, with no warning.
  • Long records may need splitting, and big lists are hard to read and check.

Safer options, in order

  1. Remove services you no longer use. This fixes most records.
  2. Move a bulk sender to its own subdomain (for example news.yourbusiness.com) with its own SPF record.
  3. Rely on DKIM for tools that support it, so they don't need to be in SPF for DMARC to pass.
  4. If you still need flattening, use a service that re-checks the addresses automatically, and watch your DMARC reports.

Common questions

Is SPF flattening bad?

Not by itself, but a hand-flattened record breaks when a service changes its addresses. Only flatten with automatic updates.

How do I count my SPF lookups?

Run the SPF checker: it counts every lookup, including the ones inside each include.

First published on DNSFix. Check your own domain free at dnsfix.com.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.