skip to content

What does an SPF record ending in +all authorise, and how do its qualifiers and left-to-right matching produce a result?

level: juniorimportance: must knowfreq 48%

answer

  1. all always matches
  2. plus is the silent default
  3. first match ends the evaluation
  4. four qualifiers, four results

basics

~20 s

An SPF record ending in +all authorises every IP address: all always matches and + makes a match pass. Mechanisms are tried left to right; the first match's qualifier (+ pass, - fail, ~ softfail, ? neutral) is the result.

solid answer

~40 s

SPF evaluates a record's mechanisms strictly left to right. The first one that matches ends the evaluation, and its qualifier becomes the result: `+` pass, `-` fail, `~` softfail, `?` neutral; a mechanism written without a qualifier is `+`. `all` matches every address, so it belongs last, and any mechanism after it is never tested. A record ending in `+all` therefore returns pass for any host on the Internet that reaches it, which makes every earlier term decoration and removes the one thing SPF is for: narrowing who may send with the domain. The fix is to list the real senders and end with `-all` or `~all`. Which of those two to publish is a separate policy decision about how receivers should treat the failure.

code

dns · 5 lines
dns
; found in review: every client address ends in pass
example.com. 3600 IN TXT "v=spf1 ip4:192.0.2.25 include:_spf.crm.example.net +all"

; repaired: unlisted clients reach -all and get fail
example.com. 3600 IN TXT "v=spf1 ip4:192.0.2.25 include:_spf.crm.example.net -all"

go deeper

for a junior

Recall the four qualifiers and their results, that plus is the default, and that the first matching mechanism decides. Be able to say in one line why +all authorises everyone.

for a middle

Trace a record term by term for a given client address, including what happens when nothing matches and why terms after all are never reached.

for a senior

In a review, check what every included record ends in as well as your own ending, and spot dead terms such as a redirect beside an all.

for a principal

Treat a permissive ending as a governance failure, not a typo: decide who may edit the record and how changes are reviewed before they reach DNS.

## What an SPF record is made of A domain publishes its **Sender Policy Framework** policy (RFC 7208, April 2014) as one DNS TXT record beginning `v=spf1`. After the version tag comes an ordered list of **terms**. A receiver runs the check, which the RFC describes as the function `check_host()`, with three inputs: - the **IP address** of the SMTP client that connected to it; - the **domain** being checked: the domain of the envelope `MAIL FROM`, or the HELO name; - the **sender** identity itself. Terms come in two kinds. **Mechanisms** (`all`, `include`, `a`, `mx`, `ptr`, `ip4`, `ip6`, `exists`) test the client IP and either match or do not. **Modifiers** (`redirect=`, `exp=`) carry extra information and never match anything themselves. ## The four qualifiers Every mechanism can carry a one-character **qualifier** in front of it. The qualifier decides which result the check returns if that mechanism matches: | Qualifier | Example | Result when the mechanism matches | |---|---|---| | `+` | `+mx` | `pass` | | `-` | `-all` | `fail` | | `~` | `~all` | `softfail` | | `?` | `?include:_spf.example.net` | `neutral` | The qualifier is optional and **defaults to `+`**, so `mx` and `+mx` mean the same thing. That default is why most records show qualifiers only on the final `all`. ## Left to right, first match wins RFC 7208 section 4.6.2 defines the evaluation order: 1. The mechanisms are considered one at a time, from left to right. 2. If a mechanism **matches**, processing stops and its qualifier's result is the result of the record. 3. If it **does not match**, evaluation moves to the next mechanism. 4. If it returns an **exception**, for example a DNS server error that yields `temperror`, evaluation stops with that exception. 5. If nothing matched, a `redirect=` modifier is followed when one is present; otherwise the result is `neutral`, exactly as if `?all` had been written at the end. Two rules follow from section 5.1. Mechanisms written after `all` are never tested and MUST be ignored. A `redirect=` modifier MUST be ignored whenever the record contains `all`, wherever the two sit. ## Why a record ending in +all is a finding `all` is the mechanism that always matches. With the default `+` qualifier it returns `pass` for any client address at all. RFC 7208's own example list puts it bluntly: for `v=spf1 +all`, any address passes. Consider the record a review turned up while the company was consolidating its outbound gateway, its CRM and its ticketing system into one policy: ```dns example.com. 3600 IN TXT "v=spf1 ip4:192.0.2.25 include:_spf.crm.example.net +all" ``` Trace a client at 203.0.113.99, a host the company has never heard of: 1. `ip4:192.0.2.25` does not match. 2. `include:_spf.crm.example.net` does not match, because the CRM's record does not pass that address. 3. `+all` matches, so the result is `pass`. Every host on the Internet gets the same answer, so the first two terms change nothing. The domain has published an SPF policy that authorises everyone to send with it, which is worse than ambiguous: receivers that weigh an SPF pass favourably now weigh it favourably for any sender using the domain in its envelope. The repair is to make sure every legitimate sender is listed and then end the record with `-all` (unlisted hosts get `fail`) or `~all` (unlisted hosts get `softfail`). Choosing between those two is a policy decision about receiver handling, covered with SPF results and forwarding; the mechanism point is only that the ending must not be `+all`, and that leaving `all` off entirely gives `neutral`. ## What to check in a review - **Is there an `all` term, and is it last?** Anything after it is dead text. - **Which qualifier does it carry?** `+all` authorises everyone; `?all` states no opinion about unlisted hosts. - **What does each included record end in?** An `include` matches whenever the record it names returns `pass`, so a vendor record ending in `+all` makes your `include` match every address. - **Is a `redirect=` sitting beside an `all`?** It is ignored and only misleads the next reader. A `+all` is legitimate in one narrow construct: RFC 7208 Appendix A.4 shows it inside a sub-record reached through a `-include:`, where the sub-record's `pass` makes the `-include` match and return `fail`. In a domain's own published record it is a misconfiguration.

  • Is +all ever correct in a published SPF record?
    Not as a domain's own policy: there it authorises every address. RFC 7208 Appendix A.4 shows the one construct where it is useful, a sub-record reached through `-include:` that lists the allowed range with `-` and ends in `+all`. An address outside the range gets `pass` from the sub-record, which makes the `-include` match and return `fail`, so the `+all` ends up restrictive.
  • What does an SPF record that simply stops after its last mechanism return for a host it does not list?
    `neutral`. RFC 7208 section 4.7 treats a record with no `all` and no `redirect=` as if it ended in `?all`. The RFC still recommends writing the ending explicitly, because it makes the intended default visible to anyone debugging the record.
  • Can an SPF evaluation stop before reaching a mechanism that would have matched?
    Yes. If a mechanism's DNS query gets a server error or times out, evaluation stops with `temperror`, even when a later term would have matched. A syntax error anywhere in the record stops the check with `permerror` before any mechanism is evaluated.

  • Ending a record in +all is the safest choice because no legitimate mail can fail.
  • A mechanism placed after all is still checked as a fallback.
  • A mechanism written without a qualifier counts as neutral.
  • A record with no all term fails every host it does not list.
  • SPF picks the most specific matching mechanism, not the first one.