How to fix: SPF record uses macro expansion
The SPF record contains a macro expansion, which builds a DNS name out of the incoming message. Parts such as the sender's local part or the client IP are substituted into a name that is then queried.
Why it matters
Every macro-expanded lookup sends attacker-influenced data into a DNS query aimed at whichever nameserver the macro's domain points to. A sender who controls the local part of the envelope address can make your receivers emit a DNS query encoding data of their choosing, and where the macro domain is third-party, its operator sees every one of those queries. Macros used with exists: also multiply the query count against the ten-lookup budget.
Macros are a legitimate RFC 7208 feature and some large senders use them for per-user authorisation, so this is informational rather than a defect. It is surfaced because macros are rare, hard to review, and easy to inherit from a vendor setup guide without understanding what gets queried or by whom. If you did not add it deliberately, trace which include brought it in.
How to fix it
- 1Confirm the macro is deliberate and that you know which nameserver receives the expanded queries.
- 2Prefer plain ip4, ip6 and include mechanisms where per-sender granularity is not actually needed.
- 3If the macro came from a third-party include, ask the vendor what the expanded queries are used for.
Code examples
What a macro expands to
v=spf1 exists:%{l}._spf.%{d} -all
; for MAIL FROM [email protected] the receiver queries
; alice._spf.example.comReferences
Detected automatically by VulnRadar. The check id is email-spf-macro-mechanism, stable across every scan so you can filter or diff on it.
More email checks
- LowDMARC Forensic Report URI (ruf=) Missing
- MediumDMARC Aggregate Report URI (rua=) Missing
- MediumMTA-STS (SMTP Strict Transport Security)
- LowTLS-RPT Record Missing rua= Reporting URI
- HighSPF Exceeds 10 DNS Lookup Limit
- HighSPF Redirect Loop
- LowDMARC pct= Below 100
- MediumDMARC Policy Set to Monitor-Only (p=none)
Questions
- How severe is SPF record uses macro expansion?
- VulnRadar rates this info severity in the email category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id email-spf-macro-mechanism, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does SPF record uses macro expansion map to?
- It maps to CWE-200. In the OWASP Top 10 it falls under A05:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.