1
2
3
4
5
6
7Internet Engineering Task Force (IETF) S. Kitterman
8Request for Comments: 7208 Kitterman Technical Services
9Obsoletes: 4408 April 2014
10Category: Standards Track
11ISSN: 2070-1721
12
13
14 Sender Policy Framework (SPF)
15 for Authorizing Use of Domains in Email, Version 1
16
17Abstract
18
19 Email on the Internet can be forged in a number of ways. In
20 particular, existing protocols place no restriction on what a sending
21 host can use as the "MAIL FROM" of a message or the domain given on
22 the SMTP HELO/EHLO commands. This document describes version 1 of
23 the Sender Policy Framework (SPF) protocol, whereby ADministrative
24 Management Domains (ADMDs) can explicitly authorize the hosts that
25 are allowed to use their domain names, and a receiving host can check
26 such authorization.
27
28 This document obsoletes RFC 4408.
29
30Status of This Memo
31
32 This is an Internet Standards Track document.
33
34 This document is a product of the Internet Engineering Task Force
35 (IETF). It represents the consensus of the IETF community. It has
36 received public review and has been approved for publication by the
37 Internet Engineering Steering Group (IESG). Further information on
38 Internet Standards is available in Section 2 of RFC 5741.
39
40 Information about the current status of this document, any errata,
41 and how to provide feedback on it may be obtained at
42 http://www.rfc-editor.org/info/rfc7208.
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58Kitterman Standards Track [Page 1]
59
60RFC 7208 Sender Policy Framework (SPF) April 2014
61
62
63Copyright Notice
64
65 Copyright (c) 2014 IETF Trust and the persons identified as the
66 document authors. All rights reserved.
67
68 This document is subject to BCP 78 and the IETF Trust's Legal
69 Provisions Relating to IETF Documents
70 (http://trustee.ietf.org/license-info) in effect on the date of
71 publication of this document. Please review these documents
72 carefully, as they describe your rights and restrictions with respect
73 to this document. Code Components extracted from this document must
74 include Simplified BSD License text as described in Section 4.e of
75 the Trust Legal Provisions and are provided without warranty as
76 described in the Simplified BSD License.
77
78 This document may contain material from IETF Documents or IETF
79 Contributions published or made publicly available before November
80 10, 2008. The person(s) controlling the copyright in some of this
81 material may not have granted the IETF Trust the right to allow
82 modifications of such material outside the IETF Standards Process.
83 Without obtaining an adequate license from the person(s) controlling
84 the copyright in such materials, this document may not be modified
85 outside the IETF Standards Process, and derivative works of it may
86 not be created outside the IETF Standards Process, except to format
87 it for publication as an RFC or to translate it into languages other
88 than English.
89
90Table of Contents
91
92 1. Introduction ....................................................5
93 1.1. Terminology ................................................5
94 1.1.1. Key Words ...........................................5
95 1.1.2. Imported Definitions ................................5
96 1.1.3. MAIL FROM Definition ................................6
97 1.1.4. HELO Definition .....................................6
98 1.2. check_host() ...............................................6
99 2. Operational Overview ............................................6
100 2.1. Publishing Authorization ...................................6
101 2.2. Checking Authorization .....................................7
102 2.3. The "HELO" Identity ........................................8
103 2.4. The "MAIL FROM" Identity ...................................9
104 2.5. Location of Checks .........................................9
105 2.6. Results of Evaluation ......................................9
106 2.6.1. None ...............................................10
107 2.6.2. Neutral ............................................10
108 2.6.3. Pass ...............................................10
109 2.6.4. Fail ...............................................10
110
111
112
113
114Kitterman Standards Track [Page 2]
115
116RFC 7208 Sender Policy Framework (SPF) April 2014
117
118
119 2.6.5. Softfail ...........................................10
120 2.6.6. Temperror ..........................................10
121 2.6.7. Permerror ..........................................10
122 3. SPF Records ....................................................11
123 3.1. DNS Resource Records ......................................11
124 3.2. Multiple DNS Records ......................................12
125 3.3. Multiple Strings in a Single DNS Record ...................12
126 3.4. Record Size ...............................................13
127 3.5. Wildcard Records ..........................................13
128 4. The check_host() Function ......................................14
129 4.1. Arguments .................................................14
130 4.2. Results ...................................................15
131 4.3. Initial Processing ........................................15
132 4.4. Record Lookup .............................................15
133 4.5. Selecting Records .........................................15
134 4.6. Record Evaluation .........................................16
135 4.6.1. Term Evaluation ....................................16
136 4.6.2. Mechanisms .........................................16
137 4.6.3. Modifiers ..........................................17
138 4.6.4. DNS Lookup Limits ..................................17
139 4.7. Default Result ............................................18
140 4.8. Domain Specification ......................................19
141 5. Mechanism Definitions ..........................................20
142 5.1. "all" .....................................................21
143 5.2. "include" .................................................21
144 5.3. "a" .......................................................23
145 5.4. "mx" ......................................................23
146 5.5. "ptr" (do not use) ........................................23
147 5.6. "ip4" and "ip6" ...........................................25
148 5.7. "exists" ..................................................25
149 6. Modifier Definitions ...........................................26
150 6.1. redirect: Redirected Query ................................26
151 6.2. exp: Explanation ..........................................27
152 7. Macros .........................................................28
153 7.1. Formal Specification ......................................29
154 7.2. Macro Definitions .........................................29
155 7.3. Macro Processing Details ..................................30
156 7.4. Expansion Examples ........................................32
157 8. Result Handling ................................................33
158 8.1. None ......................................................34
159 8.2. Neutral ...................................................34
160 8.3. Pass ......................................................34
161 8.4. Fail ......................................................35
162 8.5. Softfail ..................................................35
163 8.6. Temperror .................................................36
164 8.7. Permerror .................................................36
165
166
167
168
169
170Kitterman Standards Track [Page 3]
171
172RFC 7208 Sender Policy Framework (SPF) April 2014
173
174
175 9. Recording the Result ...........................................36
176 9.1. The Received-SPF Header Field .............................37
177 9.2. SPF Results in the Authentication-Results Header Field ....39
178 10. Effects on Infrastructure .....................................39
179 10.1. Sending Domains ..........................................40
180 10.1.1. DNS Resource Considerations .......................40
181 10.1.2. Administrator's Considerations ....................41
182 10.1.3. Bounces ...........................................41
183 10.2. Receivers ................................................42
184 10.3. Mediators ................................................42
185 11. Security Considerations .......................................43
186 11.1. Processing Limits ........................................43
187 11.2. SPF-Authorized Email May Contain Other False Identities ..44
188 11.3. Spoofed DNS and IP Data ..................................44
189 11.4. Cross-User Forgery .......................................44
190 11.5. Untrusted Information Sources ............................45
191 11.5.1. Recorded Results ..................................45
192 11.5.2. External Explanations .............................45
193 11.5.3. Macro Expansion ...................................46
194 11.6. Privacy Exposure .........................................46
195 11.7. Delivering Mail Producing a "Fail" Result ................46
196 12. Collected ABNF ................................................46
197 13. Contributors and Acknowledgements .............................48
198 14. IANA Considerations ...........................................49
199 14.1. The SPF DNS Record Type ..................................49
200 14.2. The Received-SPF Mail Header Field .......................50
201 14.3. SPF Modifier Registry ....................................50
202 15. References ....................................................50
203 15.1. Normative References .....................................50
204 15.2. Informative References ...................................51
205 Appendix A. Extended Examples .....................................54
206 A.1. Simple Examples ............................................55
207 A.2. Multiple Domain Example ....................................56
208 A.3. DNS Blacklist (DNSBL) Style Example ........................56
209 A.4. Multiple Requirements Example ..............................57
210 Appendix B. Changes in Implementation Requirements from RFC 4408 ..57
211 Appendix C. Further Testing Advice ................................58
212 Appendix D. SPF/Mediator Interactions .............................59
213 D.1. Originating ADMDs ..........................................59
214 D.2. Mediators ..................................................60
215 D.3. Receiving ADMDs ............................................60
216 Appendix E. Mail Services .........................................61
217 Appendix F. MTA Relays ............................................61
218 Appendix G. Local Policy Considerations ...........................62
219 G.1. Policy for SPF Pass ........................................62
220 G.2. Policy for SPF Fail ........................................62
221 G.3. Policy for SPF Permerror ...................................63
222 G.4. Policy for SPF Temperror ...................................63
223
224
225
226Kitterman Standards Track [Page 4]
227
228RFC 7208 Sender Policy Framework (SPF) April 2014
229
230
2311. Introduction
232
233 The current email infrastructure has the property that any host
234 injecting mail into the system can use any DNS domain name it wants
235 in each of the various identifiers specified by [RFC5321] and
236 [RFC5322]. Although this feature is desirable in some circumstances,
237 it is a major obstacle to reducing Unsolicited Bulk Email (UBE, aka
238 spam). Furthermore, ADMDs (as described in [RFC5598]) are
239 understandably concerned about the ease with which other entities can
240 make use of their domain names, often with malicious intent.
241
242 This document defines a protocol by which ADMDs can authorize hosts
243 to use their domain names in the "MAIL FROM" or "HELO" identities.
244 Compliant ADMDs publish Sender Policy Framework (SPF) records in the
245 DNS specifying which hosts are permitted to use their names, and
246 compliant mail receivers use the published SPF records to test the
247 authorization of sending Mail Transfer Agents (MTAs) using a given
248 "HELO" or "MAIL FROM" identity during a mail transaction.
249
250 An additional benefit to mail receivers is that after the use of an
251 identity is verified, local policy decisions about the mail can be
252 made based on the sender's domain, rather than the host's IP address.
253 This is advantageous because reputation of domain names is likely to
254 be more accurate than reputation of host IP addresses since domains
255 are likely to be more stable over a longer period. Furthermore, if a
256 claimed identity fails verification, local policy can take stronger
257 action against such email, such as rejecting it.
258
2591.1. Terminology
260
2611.1.1. Key Words
262
263 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
264 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
265 "OPTIONAL" in this document are to be interpreted as described in
266 [RFC2119].
267
2681.1.2. Imported Definitions
269
270 ABNF (Augmented Backus-Naur Form) ABNF is defined in [RFC5234], as
271 are the tokens "ALPHA", "DIGIT", and "SP" (space).
272
273 The tokens "Local-part", "Domain", and "Mailbox" are defined in
274 [RFC5321].
275
276 "dot-atom", "quoted-string", "comment", "CFWS" (comment folded white
277 space), "FWS" (folded white space), and "CRLF" (carriage-return/
278 line-feed) are defined in [RFC5322].
279
280
281
282Kitterman Standards Track [Page 5]
283
284RFC 7208 Sender Policy Framework (SPF) April 2014
285
286
2871.1.3. MAIL FROM Definition
288
289 This document is concerned with the identity of the sender of a mail
290 message, as referred to in [RFC5321]:
291
292 The transaction starts with a MAIL command that gives the sender
293 identification.
294
295 Since there are many other names for this identity, it is important
296 to choose a name that is:
297
298 1. commonly used
299
300 2. well defined
301
302 As such, throughout this document the term "MAIL FROM" will be used,
303 which is defined as the RFC5321.MailFrom (reverse-path) identity
304 described in [RFC5598].
305
3061.1.4. HELO Definition
307
308 This document also makes use of the HELO/EHLO identity. The "HELO"
309 identity derives from either the SMTP HELO or EHLO command (see
310 [RFC5321]). Since HELO and EHLO can, in many cases, be used
311 interchangeably, they are identified commonly as "HELO" in this
312 document. This means RFC5321.HELO/.EHLO as defined in [RFC5598].
313 These commands supply the identity of the SMTP client (sending host)
314 for the SMTP session.
315
3161.2. check_host()
317
318 Section 4 introduces an algorithm to evaluate an SPF policy against
319 an arriving email transaction. In an early implementation, this
320 algorithm was encoded in a function called check_host(). That name
321 is used in this document as symbolic of the SPF evaluation algorithm,
322 but of course implementers are not required to use this name.
323
3242. Operational Overview
325
3262.1. Publishing Authorization
327
328 An SPF-compliant domain publishes valid SPF records as described in
329 Section 3. These records authorize the use of the relevant domain
330 names in the "HELO" and "MAIL FROM" identities by the MTAs specified
331 therein.
332
333
334
335
336
337
338Kitterman Standards Track [Page 6]
339
340RFC 7208 Sender Policy Framework (SPF) April 2014
341
342
343 SPF results can be used to make both positive (source is authorized)
344 and negative (source is not authorized) determinations. If ADMDs
345 choose to publish SPF records and want to support receivers making
346 negative authorization determinations, it is necessary for them to
347 publish records that end in "-all", or redirect to other records that
348 do; otherwise, no definitive determination of authorization can be
349 made. Potential issues and mitigations associated with negative
350 determinations are discussed in Section 10.
351
352 ADMDs that wish to declare that no hosts are authorized to use their
353 DNS domain names in the HELO or MAIL FROM commands during SMTP
354 sessions can publish SPF records that say so for domain names that
355 are neither used in the domain part of email addresses nor expected
356 to originate mail.
357
358 When changing SPF records, care has to be taken to ensure that there
359 is a transition period so that the old policy remains valid until all
360 legitimate email can reasonably expect to have been checked.
361 [RFC5321], Section 4.5.4.1 discusses how long a message might be in
362 transit. While offline checks are possible, the closer to the
363 original transmission time checks are performed, the more likely they
364 are to get an SPF result that matches the sending ADMD intent at the
365 time the message was sent.
366
3672.2. Checking Authorization
368
369 A mail receiver can perform a set of SPF checks for each mail message
370 it receives. An SPF check tests the authorization of a client host
371 to emit mail with a given identity. Typically, such checks are done
372 by a receiving MTA, but can be performed elsewhere in the mail
373 processing chain so long as the required information is available and
374 reliable. The "MAIL FROM" and "HELO" identities are checked as
375 described in Sections 2.4 and 2.3, respectively.
376
377 Without explicit approval of the publishing ADMD, checking other
378 identities against SPF version 1 records is NOT RECOMMENDED because
379 there are cases that are known to give incorrect results. For
380 example, almost all mailing lists rewrite the "MAIL FROM" identity
381 (see Section 10.3), but some do not change any other identities in
382 the message. Documents that define other identities will have to
383 define the method for explicit approval.
384
385 It is possible that mail receivers will use the SPF check as part of
386 a larger set of tests on incoming mail. The results of other tests
387 might influence whether or not a particular SPF check is performed.
388 For example, finding the sending host's IP address on a local
389 whitelist might cause all other tests to be skipped and all mail from
390 that host to be accepted.
391
392
393
394Kitterman Standards Track [Page 7]
395
396RFC 7208 Sender Policy Framework (SPF) April 2014
397
398
399 When a mail receiver decides to perform an SPF check, it has to use a
400 correctly implemented check_host() function (Section 4) evaluated
401 with the correct parameters. Although the test as a whole is
402 optional, once it has been decided to perform a test it has to be
403 performed as specified so that the correct semantics are preserved
404 between publisher and receiver.
405
406 To make the test, the mail receiver MUST evaluate the check_host()
407 function with the arguments described in Section 4.1.
408
409 Although invalid, malformed, or non-existent domains cause SPF checks
410 to return "none" because no SPF record can be found, it has long been
411 the policy of many MTAs to reject email from such domains, especially
412 in the case of invalid "MAIL FROM". Rejecting email will prevent one
413 method of circumventing of SPF records.
414
415 Implementations have to take care to correctly extract the <domain>
416 from the data given with the SMTP MAIL FROM command as many MTAs will
417 still accept such things as source routes (see Appendix C of
418 [RFC5321]), the %-hack (see [RFC1123]), and bang paths (see
419 [RFC1983]). These archaic features have been maliciously used to
420 bypass security systems.
421
4222.3. The "HELO" Identity
423
424 It is RECOMMENDED that SPF verifiers not only check the "MAIL FROM" ../spf/spf.go:248
425 identity but also separately check the "HELO" identity by applying
426 the check_host() function (Section 4) to the "HELO" identity as the
427 <sender>. Checking "HELO" promotes consistency of results and can
428 reduce DNS resource usage. If a conclusive determination about the
429 message can be made based on a check of "HELO", then the use of DNS
430 resources to process the typically more complex "MAIL FROM" can be
431 avoided. Additionally, since SPF records published for "HELO"
432 identities refer to a single host, when available, they are a very
433 reliable source of host authorization status. Checking "HELO" before
434 "MAIL FROM" is the RECOMMENDED sequence if both are checked.
435
436 Note that requirements for the domain presented in the EHLO or HELO
437 command are not always clear to the sending party, and SPF verifiers
438 have to be prepared for the identity to be an IP address literal (see
439 [RFC5321], Section 4.1.3) or simply be malformed. This SPF check can
440 only be performed when the "HELO" string is a valid, multi-label
441 domain name.
442
443
444
445
446
447
448
449
450Kitterman Standards Track [Page 8]
451
452RFC 7208 Sender Policy Framework (SPF) April 2014
453
454
4552.4. The "MAIL FROM" Identity
456
457 SPF verifiers MUST check the "MAIL FROM" identity if a "HELO" check
458 either has not been performed or has not reached a definitive policy
459 result by applying the check_host() function to the "MAIL FROM"
460 identity as the <sender>.
461
462 [RFC5321] allows the reverse-path to be null (see Section 4.5.5 in
463 [RFC5321]). In this case, there is no explicit sender mailbox, and
464 such a message can be assumed to be a notification message from the
465 mail system itself. When the reverse-path is null, this document
466 defines the "MAIL FROM" identity to be the mailbox composed of the
467 local-part "postmaster" and the "HELO" identity (which might or might
468 not have been checked separately before).
469
4702.5. Location of Checks
471
472 The authorization check SHOULD be performed during the processing of ../smtpserver/server.go:2351
473 the SMTP transaction that receives the mail. This reduces the
474 complexity of determining the correct IP address to use as an input
475 to check_host() and allows errors to be returned directly to the
476 sending MTA by way of SMTP replies. Appendix D of [RFC7001] provides
477 a more thorough discussion of this topic.
478
479 The authorization check is performed during the SMTP transaction at
480 the time of the MAIL command, and uses the MAIL FROM value and the
481 client IP address. Performing the check at later times or with other
482 input can cause problems such as the following:
483
484 o It might be difficult to accurately extract the required
485 information from potentially deceptive headers.
486
487 o Legitimate email might fail the authorization check because the
488 sender's policy has since changed.
489
490 Generating non-delivery notifications to forged identities that have ../queue/dsn.go:266
491 failed the authorization check often constitutes backscatter, i.e.,
492 nuisance rejection notices that are not actionable. Operators are
493 strongly advised to avoid such practices. Section 2 of [RFC3834]
494 describes backscatter and the problems it causes.
495
4962.6. Results of Evaluation
497
498 Section 4 defines check_host(), a model function definition that uses
499 the inputs defined above and the sender's policy published in the DNS
500 to reach a conclusion about client authorization. An SPF verifier
501 implements something semantically equivalent to the function defined
502 there.
503
504
505
506Kitterman Standards Track [Page 9]
507
508RFC 7208 Sender Policy Framework (SPF) April 2014
509
510
511 This section enumerates and briefly defines the possible outputs of
512 that function. Note, however, that the protocol establishes no
513 normative requirements for handling any particular result.
514 Discussion of handling options for each result can be found in
515 Section 8.
516
5172.6.1. None ../spf/spf.go:67
518
519 A result of "none" means either (a) no syntactically valid DNS domain
520 name was extracted from the SMTP session that could be used as the
521 one to be authorized, or (b) no SPF records were retrieved from
522 the DNS.
523
5242.6.2. Neutral
525
526 A "neutral" result means the ADMD has explicitly stated that it is
527 not asserting whether the IP address is authorized.
528
5292.6.3. Pass
530
531 A "pass" result is an explicit statement that the client is
532 authorized to inject mail with the given identity.
533
5342.6.4. Fail
535
536 A "fail" result is an explicit statement that the client is not
537 authorized to use the domain in the given identity.
538
5392.6.5. Softfail
540
541 A "softfail" result is a weak statement by the publishing ADMD that
542 the host is probably not authorized. It has not published a
543 stronger, more definitive policy that results in a "fail".
544
5452.6.6. Temperror
546
547 A "temperror" result means the SPF verifier encountered a transient
548 (generally DNS) error while performing the check. A later retry may
549 succeed without further DNS operator action.
550
5512.6.7. Permerror
552
553 A "permerror" result means the domain's published records could not
554 be correctly interpreted. This signals an error condition that
555 definitely requires DNS operator intervention to be resolved.
556
557
558
559
560
561
562Kitterman Standards Track [Page 10]
563
564RFC 7208 Sender Policy Framework (SPF) April 2014
565
566
5673. SPF Records
568
569 An SPF record is a DNS record that declares which hosts are, and are
570 not, authorized to use a domain name for the "HELO" and "MAIL FROM"
571 identities. Loosely, the record partitions hosts into permitted and
572 not-permitted sets (though some hosts might fall into neither
573 category).
574
575 The SPF record is expressed as a single string of text found in the
576 RDATA of a single DNS TXT resource record; multiple SPF records are ../spf/spf.go:159
577 not permitted for the same owner name. The record format and the
578 process for selecting records are described below in Section 4. An
579 example record is the following:
580
581 v=spf1 +mx a:colo.example.com/28 -all
582
583 This record has a version of "spf1" and three directives: "+mx",
584 "a:colo.example.com/28" (the "+" is implied), and "-all".
585
586 Each SPF record is placed in the DNS tree at the owner name it ../spf/spf.go:131
587 pertains to, not in a subdomain under the owner name. This is
588 similar to how SRV records [RFC2782] are done.
589
590 The example in this section might be published via these lines in a
591 domain zone file:
592
593 example.com. TXT "v=spf1 +mx a:colo.example.com/28 -all"
594
595 Since TXT records have multiple uses, beware of other TXT records ../spf/spf.go:152
596 published there for other purposes. They might cause problems with
597 size limits (see Section 3.4), and care has to be taken to ensure
598 that only SPF records are used for SPF processing.
599
600 ADMDs publishing SPF records ought to keep the amount of DNS
601 information needed to evaluate a record to a minimum. Sections 4.6.4
602 and 10.1.1 provide some suggestions about "include" mechanisms and
603 chained "redirect" modifiers.
604
6053.1. DNS Resource Records
606
607 SPF records MUST be published as a DNS TXT (type 16) Resource Record
608 (RR) [RFC1035] only. The character content of the record is encoded
609 as [US-ASCII]. Use of alternative DNS RR types was supported in
610 SPF's experimental phase but has been discontinued.
611
612 In 2003, when SPF was first being developed, the requirements for
613 assignment of a new DNS RR type were considerably more stringent than
614 they are now. Additionally, support for easy deployment of new DNS
615
616
617
618Kitterman Standards Track [Page 11]
619
620RFC 7208 Sender Policy Framework (SPF) April 2014
621
622
623 RR types was not widely deployed in DNS servers and provisioning
624 systems. As a result, developers of SPF found it easier and more
625 practical to use the TXT RR type for SPF records.
626
627 In its review of [RFC4408], the SPFbis working group concluded that
628 its dual RR type transition model was fundamentally flawed since it
629 contained no common RR type that implementers were required to serve
630 and required to check. Many alternatives were considered to resolve
631 this issue, but ultimately the working group concluded that
632 significant migration to the SPF RR type in the foreseeable future
633 was very unlikely and that the best solution for resolving this
634 interoperability issue was to drop support for the SPF RR type from
635 SPF version 1. See Appendix A of [RFC6686] for further information.
636
637 The circumstances surrounding SPF's initial deployment a decade ago
638 are unique. If a future update to SPF were developed that did not
639 reuse existing SPF records, it could use the SPF RR type. SPF's use
640 of the TXT RR type for structured data should in no way be taken as
641 precedent for future protocol designers. Further discussion of
642 design considerations when using new DNS RR types can be found in
643 [RFC5507].
644
6453.2. Multiple DNS Records
646
647 A domain name MUST NOT have multiple records that would cause an
648 authorization check to select more than one record. See Section 4.5
649 for the selection rules.
650
6513.3. Multiple Strings in a Single DNS Record
652
653 As defined in [RFC1035], Sections 3.3 and 3.3.14, a single text DNS
654 record can be composed of more than one string. If a published
655 record contains multiple character-strings, then the record MUST be
656 treated as if those strings are concatenated together without adding
657 spaces. For example:
658
659 IN TXT "v=spf1 .... first" "second string..."
660
661 is equivalent to:
662
663 IN TXT "v=spf1 .... firstsecond string..."
664
665 TXT records containing multiple strings are useful in constructing
666 records that would exceed the 255-octet maximum length of a
667 character-string within a single TXT record.
668
669
670
671
672
673
674Kitterman Standards Track [Page 12]
675
676RFC 7208 Sender Policy Framework (SPF) April 2014
677
678
6793.4. Record Size
680
681 The published SPF record for a given domain name SHOULD remain small
682 enough that the results of a query for it will fit within 512 octets.
683 Otherwise, there is a possibility of exceeding a DNS protocol limit.
684 This UDP limit is defined in [RFC1035], Section 2.3.4, although it
685 was raised by [RFC2671]. Staying below 512 octets ought to prevent
686 older DNS implementations from failing over to TCP and will work with
687 UDP in the absence of EDNS0 [RFC6891] support. Since the answer size
688 is dependent on many things outside the scope of this document, it is
689 only possible to give this guideline: If the size of the DNS message,
690 the combined length of the DNS name and the text of all the records
691 of a given type is under 450 octets, then DNS answers ought to fit in
692 UDP packets. Records that are too long to fit in a single UDP packet
693 could be silently ignored by SPF verifiers due to firewall and other
694 issues that interfere with the operation of DNS over TCP or using
695 ENDS0.
696
697 Note that when computing the sizes for replies to queries of the TXT
698 format, one has to take into account any other TXT records published
699 at the domain name. Similarly, the sizes for replies to all queries
700 related to SPF have to be evaluated to fit in a single 512-octet UDP
701 packet (i.e., DNS message size limited to 450 octets).
702
7033.5. Wildcard Records
704
705 Use of wildcard records for publishing is discouraged, and care has
706 to be taken if they are used. If a zone includes wildcard MX
707 records, it might want to publish wildcard declarations, subject to
708 the same requirements and problems. In particular, the declaration
709 MUST be repeated for any host that has any RR records at all, and for
710 subdomains thereof. Consider the example in [RFC1034],
711 Section 4.3.3. Based on that, we can do the following:
712
713 EXAMPLE.COM. MX 10 A.EXAMPLE.COM
714 EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all"
715
716 *.EXAMPLE.COM. MX 10 A.EXAMPLE.COM
717 *.EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all"
718
719 A.EXAMPLE.COM. A 203.0.113.1
720 A.EXAMPLE.COM. MX 10 A.EXAMPLE.COM
721 A.EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all"
722
723 *.A.EXAMPLE.COM. MX 10 A.EXAMPLE.COM
724 *.A.EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all"
725
726
727
728
729
730Kitterman Standards Track [Page 13]
731
732RFC 7208 Sender Policy Framework (SPF) April 2014
733
734
735 SPF records have to be listed twice for every name within the zone:
736 once for the name, and once with a wildcard to cover the tree under
737 the name, in order to cover all domains in use in outgoing mail.
738
7394. The check_host() Function
740
741 This description is not an application programming interface
742 definition, but rather a function description used to illustrate the
743 algorithm. A compliant SPF implementation MUST produce results
744 semantically equivalent to this description.
745
746 The check_host() function fetches SPF records, parses them, and
747 evaluates them to determine whether a particular host is or is not
748 permitted to send mail with a given identity. Receiving ADMDs that
749 perform this check MUST correctly evaluate the check_host() function
750 as described here.
751
752 Implementations MAY use a different algorithm than the canonical
753 algorithm defined here, so long as the results are the same in all
754 cases.
755
7564.1. Arguments
757
758 The check_host() function takes these arguments:
759
760 <ip> - the IP address of the SMTP client that is emitting
761 the mail, either IPv4 or IPv6.
762
763 <domain> - the domain that provides the sought-after authorization
764 information; initially, the domain portion of the
765 "MAIL FROM" or "HELO" identity.
766
767 <sender> - the "MAIL FROM" or "HELO" identity.
768
769 For recursive evaluations, the domain portion of <sender> might not
770 be the same as the <domain> argument when check_host() is initially
771 evaluated. In most other cases it will be the same (see Section 5.2
772 below). The overall DNS lookup limit for SPF terms described below
773 in Section 4.6.4 must be tracked as a single global limit for all
774 evaluations, not just for a single instance of a recursive
775 evaluation.
776
777 Note that the <domain> argument might not be a well-formed domain
778 name. For example, if the reverse-path was null, then the EHLO/HELO ../spf/spf.go:247
779 domain is used, with its associated problems (see Section 2.3). In
780 these cases, check_host() is defined in Section 4.3 to return a
781 "none" result.
782
783
784
785
786Kitterman Standards Track [Page 14]
787
788RFC 7208 Sender Policy Framework (SPF) April 2014
789
790
7914.2. Results
792
793 The check_host() function can return one of several results described
794 in Section 2.6. Based on the result, the action to be taken is
795 determined by the local policies of the receiver. This is discussed
796 in Section 8.
797
7984.3. Initial Processing
799
800 If the <domain> is malformed (e.g., label longer than 63 characters, ../spf/spf.go:873
801 zero-length label not at the end, etc.) or is not a multi-label
802 domain name, or if the DNS lookup returns "Name Error" (RCODE 3, also
803 known as "NXDOMAIN" [RFC2308]), check_host() immediately returns the
804 result "none". DNS RCODEs are defined in [RFC1035]. Properly formed
805 domains are fully qualified domains as defined in [RFC1983]. That
806 is, in the DNS they are implicitly qualified relative to the root
807 (see Section 3.1 of [RFC1034]). Internationalized domain names MUST
808 be encoded as A-labels, as described in Section 2.3 of [RFC5890].
809
810 If the <sender> has no local-part, substitute the string "postmaster" ../spf/spf.go:259
811 for the local-part.
812
8134.4. Record Lookup
814
815 In accordance with how the records are published (see Section 3
816 above), a DNS query needs to be made for the <domain> name, querying
817 for type TXT only.
818
819 If the DNS lookup returns a server failure (RCODE 2) or some other
820 error (RCODE other than 0 or 3), or if the lookup times out, then
821 check_host() terminates immediately with the result "temperror".
822
8234.5. Selecting Records
824
825 Records begin with a version section: ../spf/parse.go:133
826
827 record = version terms *SP
828 version = "v=spf1"
829
830 Starting with the set of records that were returned by the lookup,
831 discard records that do not begin with a version section of exactly
832 "v=spf1". Note that the version section is terminated by either an
833 SP character or the end of the record. As an example, a record with
834 a version section of "v=spf10" does not match and is discarded.
835
836 If the resultant record set includes no records, check_host()
837 produces the "none" result. If the resultant record set includes ../spf/spf.go:166
838 more than one record, check_host() produces the "permerror" result.
839
840
841
842Kitterman Standards Track [Page 15]
843
844RFC 7208 Sender Policy Framework (SPF) April 2014
845
846
8474.6. Record Evaluation
848
849 The check_host() function parses and interprets the SPF record to
850 find a result for the current test. The syntax of the record is
851 validated first, and if there are any syntax errors anywhere in the
852 record, check_host() returns immediately with the result "permerror", ../spf/spf.go:155
853 without further interpretation or evaluation.
854
8554.6.1. Term Evaluation
856
857 There are two types of terms: mechanisms (defined in Section 5) and
858 modifiers (defined in Section 6). A record contains an ordered list
859 of these as specified in the following Augmented Backus-Naur Form
860 (ABNF).
861
862 terms = *( 1*SP ( directive / modifier ) )
863
864 directive = [ qualifier ] mechanism
865 qualifier = "+" / "-" / "?" / "~"
866 mechanism = ( all / include
867 / a / mx / ptr / ip4 / ip6 / exists )
868 modifier = redirect / explanation / unknown-modifier
869 unknown-modifier = name "=" macro-string
870 ; where name is not any known modifier
871
872 name = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." )
873
874 Most mechanisms allow a ":" or "/" character after the name.
875
876 Modifiers always contain an equals ('=') character immediately after
877 the name, and before any ":" or "/" characters that might be part of
878 the macro-string.
879
880 Terms that do not contain any of "=", ":", or "/" are mechanisms, as
881 defined in Section 5.
882
883 As per the definition of the ABNF notation in [RFC5234], mechanism
884 and modifier names are case-insensitive.
885
8864.6.2. Mechanisms
887
888 Each mechanism is considered in turn from left to right. If there
889 are no more mechanisms, the result is the default result as described
890 in Section 4.7.
891
892 When a mechanism is evaluated, one of three things can happen: it can
893 match, not match, or return an exception.
894
895
896
897
898Kitterman Standards Track [Page 16]
899
900RFC 7208 Sender Policy Framework (SPF) April 2014
901
902
903 If it matches, processing ends and the qualifier value is returned as
904 the result of that record. If it does not match, processing
905 continues with the next mechanism. If it returns an exception,
906 mechanism processing ends and the exception value is returned.
907
908 The possible qualifiers, and the results they cause check_host() to
909 return, are as follows:
910
911 "+" pass
912 "-" fail
913 "~" softfail
914 "?" neutral
915
916 The qualifier is optional and defaults to "+".
917
918 When a mechanism matches and the qualifier is "-", then a "fail"
919 result is returned and the explanation string is computed as
920 described in Section 6.2.
921
922 The specific mechanisms are described in Section 5.
923
9244.6.3. Modifiers
925
926 Modifiers are not mechanisms. They do not return match or not-match.
927 Instead, they provide additional information. Although modifiers do
928 not directly affect the evaluation of the record, the "redirect"
929 modifier has an effect after all the mechanisms have been evaluated.
930
9314.6.4. DNS Lookup Limits
932
933 Some mechanisms and modifiers (collectively, "terms") cause DNS
934 queries at the time of evaluation, and some do not. The following
935 terms cause DNS queries: the "include", "a", "mx", "ptr", and
936 "exists" mechanisms, and the "redirect" modifier. SPF
937 implementations MUST limit the total number of those terms to 10 ../spf/spf.go:672 ../spf/spf.go:960
938 during SPF evaluation, to avoid unreasonable load on the DNS. If
939 this limit is exceeded, the implementation MUST return "permerror".
940 The other terms -- the "all", "ip4", and "ip6" mechanisms, and the
941 "exp" modifier -- do not cause DNS queries at the time of SPF
942 evaluation (the "exp" modifier only causes a lookup at a later time),
943 and their use is not subject to this limit.
944
945 When evaluating the "mx" mechanism, the number of "MX" resource ../spf/spf.go:445
946 records queried is included in the overall limit of 10 mechanisms/
947 modifiers that cause DNS lookups as described above. In addition to ../spf/spf.go:441
948 that limit, the evaluation of each "MX" record MUST NOT result in
949
950
951
952
953
954Kitterman Standards Track [Page 17]
955
956RFC 7208 Sender Policy Framework (SPF) April 2014
957
958
959 querying more than 10 address records -- either "A" or "AAAA"
960 resource records. If this limit is exceeded, the "mx" mechanism MUST
961 produce a "permerror" result.
962
963 When evaluating the "ptr" mechanism or the %{p} macro, the number of ../spf/spf.go:490
964 "PTR" resource records queried is included in the overall limit of 10
965 mechanisms/modifiers that cause DNS lookups as described above. In
966 addition to that limit, the evaluation of each "PTR" record MUST NOT
967 result in querying more than 10 address records -- either "A" or
968 "AAAA" resource records. If this limit is exceeded, all records
969 other than the first 10 MUST be ignored.
970
971 The reason for the disparity is that the set of and contents of the
972 MX record are under control of the publishing ADMD, while the set of
973 and contents of PTR records are under control of the owner of the IP
974 address actually making the connection.
975
976 These limits are per mechanism or macro in the record, and are in
977 addition to the lookup limits specified above.
978
979 MTAs or other processors SHOULD impose a limit on the maximum amount
980 of elapsed time to evaluate check_host(). Such a limit SHOULD allow
981 at least 20 seconds. If such a limit is exceeded, the result of
982 authorization SHOULD be "temperror".
983
984 As described at the end of Section 11.1, there may be cases where it 7208-eid6595:1 7208:1382 ../spf/spf.go:38 ../spf/spf.go:527
985 is useful to limit the number of "terms" for which DNS queries return
986 either a positive answer (RCODE 0) with an answer count of 0, or a
987 "Name Error" (RCODE 3) answer. These are sometimes collectively
988 referred to as "void lookups". SPF implementations SHOULD limit ../spf/spf.go:964
989 "void lookups" to two. An implementation MAY choose to make such a
990 limit configurable. In this case, a default of two is RECOMMENDED.
991 Exceeding the limit produces a "permerror" result.
992
9934.7. Default Result
994
995 If none of the mechanisms match and there is no "redirect" modifier,
996 then the check_host() returns a result of "neutral", just as if 7208:2095 ../spf/spf.go:578
997 "?all" were specified as the last directive. If there is a
998 "redirect" modifier, check_host() proceeds as defined in Section 6.1.
999
1000 It is better to use either a "redirect" modifier or an "all"
1001 mechanism to explicitly terminate processing. Although there is an
1002 implicit "?all" at the end of every record that is not explicitly
1003 terminated, it aids debugging efforts when it is explicitly provided.
1004
1005
1006
1007
1008
1009
1010Kitterman Standards Track [Page 18]
1011
1012RFC 7208 Sender Policy Framework (SPF) April 2014
1013
1014
1015 For example:
1016
1017 v=spf1 +mx -all
1018
1019 or
1020
1021 v=spf1 +mx redirect=_spf.example.com
1022
10234.8. Domain Specification
1024
1025 Several of these mechanisms and modifiers have a <domain-spec>
1026 section. The <domain-spec> string is subject to macro expansion (see
1027 Section 7). The resulting string is the common presentation form of
1028 a fully qualified DNS name: a series of labels separated by periods.
1029 This domain is called the <target-name> in the rest of this document.
1030
1031 Note: The result of the macro expansion is not subject to any further
1032 escaping. Hence, this facility cannot produce all characters that
1033 are legal in a DNS label (e.g., the control characters). However,
1034 this facility is powerful enough to express legal host names and
1035 common utility labels (such as "_spf") that are used in DNS.
1036
1037 For several mechanisms, the <domain-spec> is optional. If it is not ../spf/spf.go:585
1038 provided, the <domain> from the check_host() arguments (see
1039 Section 4.1) is used as the <target-name>. "domain" and
1040 <domain-spec> are syntactically identical after macro expansion.
1041 "domain" is an input value for check_host(), while <domain-spec> is
1042 computed by check_host().
1043
1044 The result of evaluating check_host() with a syntactically invalid
1045 domain is undefined.
1046
1047 Note: This document and its predecessors make no provisions for ../spf/spf.go:608
1048 defining correct handling of a syntactically invalid <domain-spec>
1049 (which might be the result of macro expansion), per [RFC1035].
1050 Examples include names with empty labels, such as "foo..example.com",
1051 and labels that are longer than 63 characters. Some implementations
1052 choose to treat such errors as not-match and therefore ignore such
1053 names, while others return a "permerror" exception.
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066Kitterman Standards Track [Page 19]
1067
1068RFC 7208 Sender Policy Framework (SPF) April 2014
1069
1070
10715. Mechanism Definitions
1072
1073 This section defines two types of mechanisms: basic language
1074 framework mechanisms and designated sender mechanisms.
1075
1076 Basic mechanisms contribute to the language framework. They do not
1077 specify a particular type of authorization scheme. The basic
1078 mechanisms are as follows:
1079
1080 all
1081 include
1082
1083 Designated sender mechanisms are used to identify a set of <ip>
1084 addresses as being permitted or not permitted to use the <domain> for
1085 sending mail. The designated sender mechanisms are as follows:
1086
1087 a
1088 mx
1089 ptr (do not use)
1090 ip4
1091 ip6
1092 exists
1093
1094 The following conventions apply to all mechanisms that perform a
1095 comparison between <ip> and an IP address at any point:
1096
1097 If no CIDR prefix length is given in the directive, then <ip> and the ../spf/spf.go:325
1098 IP address are compared for equality. (Here, CIDR is Classless
1099 Inter-Domain Routing, described in [RFC4632].)
1100
1101 If a CIDR prefix length is specified, then only the specified number
1102 of high-order bits of <ip> and the IP address are compared for
1103 equality.
1104
1105 When any mechanism fetches host addresses to compare with <ip>, when
1106 <ip> is an IPv4, "A" records are fetched; when <ip> is an IPv6
1107 address, "AAAA" records are fetched. SPF implementations on IPv6
1108 servers need to handle both "AAAA" and "A" records, for clients on
1109 IPv4-mapped IPv6 addresses [RFC4291]. IPv4 <ip> addresses are only
1110 listed in an SPF record using the "ip4" mechanism.
1111
1112 Several mechanisms rely on information fetched from the DNS. For
1113 these DNS queries, except where noted, if the DNS server returns an
1114 error (RCODE other than 0 or 3) or the query times out, the mechanism
1115 stops and the topmost check_host() returns "temperror". If the
1116 server returns "Name Error" (RCODE 3), then evaluation of the ../spf/spf.go:356
1117 mechanism continues as if the server returned no error (RCODE 0) and
1118 zero answer records.
1119
1120
1121
1122Kitterman Standards Track [Page 20]
1123
1124RFC 7208 Sender Policy Framework (SPF) April 2014
1125
1126
11275.1. "all" ../spf/spf.go:380
1128
1129 all = "all"
1130
1131 The "all" mechanism is a test that always matches. It is used as the
1132 rightmost mechanism in a record to provide an explicit default.
1133
1134 For example:
1135
1136 v=spf1 a mx -all
1137
1138 Mechanisms after "all" will never be tested. Mechanisms listed after
1139 "all" MUST be ignored. Any "redirect" modifier (Section 6.1) MUST be
1140 ignored when there is an "all" mechanism in the record, regardless of
1141 the relative ordering of the terms.
1142
11435.2. "include" ../spf/spf.go:384
1144
1145 include = "include" ":" domain-spec
1146
1147 The "include" mechanism triggers a recursive evaluation of
1148 check_host().
1149
1150 1. The <domain-spec> is expanded as per Section 7.
1151
1152 2. check_host() is evaluated with the resulting string as the
1153 <domain>. The <ip> and <sender> arguments remain the same as in
1154 the current evaluation of check_host().
1155
1156 3. The recursive evaluation returns match, not-match, or an error.
1157
1158 4. If it returns match, then the appropriate result for the
1159 "include" mechanism is used (e.g., include or +include produces a
1160 "pass" result and -include produces "fail").
1161
1162 5. If it returns not-match or an error, the parent check_host()
1163 resumes processing as per the table below, with the previous
1164 value of <domain> restored.
1165
1166 In hindsight, the name "include" was poorly chosen. Only the
1167 evaluated result of the referenced SPF record is used, rather than
1168 literally including the mechanisms of the referenced record in the
1169 first. For example, evaluating a "-all" directive in the referenced
1170 record does not terminate the overall processing and does not
1171 necessarily result in an overall "fail". (Better names for this
1172 mechanism would have been "if-match", "on-match", etc.)
1173
1174
1175
1176
1177
1178Kitterman Standards Track [Page 21]
1179
1180RFC 7208 Sender Policy Framework (SPF) April 2014
1181
1182
1183 The "include" mechanism makes it possible for one domain to designate
1184 multiple administratively independent domains. For example, a vanity
1185 domain "example.net" might send mail using the servers of
1186 administratively independent domains example.com and example.org.
1187
1188 Example.net could say
1189
1190 IN TXT "v=spf1 include:example.com include:example.org -all"
1191
1192 This would direct check_host() to, in effect, check the records of
1193 example.com and example.org for a "pass" result. Only if the host
1194 were not permitted for either of those domains would the result be
1195 "fail".
1196
1197 Whether this mechanism matches, does not match, or returns an
1198 exception depends on the result of the recursive evaluation of
1199 check_host():
1200
1201 +---------------------------------+---------------------------------+
1202 | A recursive check_host() result | Causes the "include" mechanism | ../spf/spf.go:395
1203 | of: | to: |
1204 +---------------------------------+---------------------------------+
1205 | pass | match |
1206 | | |
1207 | fail | not match |
1208 | | |
1209 | softfail | not match |
1210 | | |
1211 | neutral | not match |
1212 | | |
1213 | temperror | return temperror |
1214 | | |
1215 | permerror | return permerror |
1216 | | |
1217 | none | return permerror |
1218 +---------------------------------+---------------------------------+
1219
1220 The "include" mechanism is intended for crossing administrative
1221 boundaries. When remaining within one administrative authority,
1222 "include" is usually not the best choice. For example, if
1223 example.com and example.org were managed by the same entity, and if
1224 the permitted set of hosts for both domains was "mx:example.com", it
1225 would be possible for example.org to specify "include:example.com",
1226 but it would be preferable to specify "redirect=example.com" or even
1227 "mx:example.com".
1228
1229
1230
1231
1232
1233
1234Kitterman Standards Track [Page 22]
1235
1236RFC 7208 Sender Policy Framework (SPF) April 2014
1237
1238
1239 With the "include" mechanism, an administratively external set of
1240 hosts can be authorized, but determination of sender policy is still
1241 a function of the original domain's SPF record (as determined by the
1242 "all" mechanism in that record). The "redirect" modifier is more
1243 suitable for consolidating both authorizations and policy into a
1244 common set to be shared within an ADMD. Redirect is much more like a
1245 common code element to be shared among records in a single ADMD. It
1246 is possible to control both authorized hosts and policy for an
1247 arbitrary number of domains from a single record.
1248
12495.3. "a" ../spf/spf.go:406
1250
1251 This mechanism matches if <ip> is one of the <target-name>'s IP
1252 addresses. For clarity, this means the "a" mechanism also matches
1253 AAAA records.
1254
1255 a = "a" [ ":" domain-spec ] [ dual-cidr-length ]
1256
1257 An address lookup is done on the <target-name> using the type of
1258 lookup (A or AAAA) appropriate for the connection type (IPv4 or
1259 IPv6). The <ip> is compared to the returned address(es). If any
1260 address matches, the mechanism matches.
1261
12625.4. "mx" ../spf/spf.go:423
1263
1264 This mechanism matches if <ip> is one of the MX hosts for a domain
1265 name.
1266
1267 mx = "mx" [ ":" domain-spec ] [ dual-cidr-length ]
1268
1269 check_host() first performs an MX lookup on the <target-name>. Then
1270 it performs an address lookup on each MX name returned. The <ip> is
1271 compared to each returned IP address. To prevent denial-of-service
1272 (DoS) attacks, the processing limits defined in Section 4.6.4 MUST be
1273 followed. If the MX lookup limit is exceeded, then "permerror" is
1274 returned and the evaluation is terminated. If any address matches,
1275 the mechanism matches.
1276
1277 Note regarding implicit MXes: If the <target-name> has no MX record,
1278 check_host() MUST NOT apply the implicit MX rules of [RFC5321] by
1279 querying for an A or AAAA record for the same name.
1280
12815.5. "ptr" (do not use) ../spf/spf.go:465
1282
1283 This mechanism tests whether the DNS reverse-mapping for <ip> exists
1284 and correctly points to a domain name within a particular domain.
1285 This mechanism SHOULD NOT be published. See the note at the end of
1286 this section for more information.
1287
1288
1289
1290Kitterman Standards Track [Page 23]
1291
1292RFC 7208 Sender Policy Framework (SPF) April 2014
1293
1294
1295 ptr = "ptr" [ ":" domain-spec ]
1296
1297 The <ip>'s name is looked up using this procedure: 7208-eid5227:1 ../spf/spf.go:37
1298
1299 o Perform a DNS reverse-mapping for <ip>: Look up the corresponding
1300 PTR record in "in-addr.arpa." if the address is an IPv4 address
1301 and in "ip6.arpa." if it is an IPv6 address.
1302
1303 o For each record returned, validate the domain name by looking up
1304 its IP addresses. To prevent DoS attacks, the PTR processing
1305 limits defined in Section 4.6.4 MUST be applied. If they are
1306 exceeded, processing is terminated and the mechanism does not
1307 match.
1308
1309 o If <ip> is among the returned IP addresses, then that domain name
1310 is validated.
1311
1312 Check all validated domain names to see if they either match the
1313 <target-name> domain or are a subdomain of the <target-name> domain.
1314 If any do, this mechanism matches. If no validated domain name can
1315 be found, or if none of the validated domain names match or are a
1316 subdomain of the <target-name>, this mechanism fails to match. If a
1317 DNS error occurs while doing the PTR RR lookup, then this mechanism
1318 fails to match. If a DNS error occurs while doing an A RR lookup,
1319 then that domain name is skipped and the search continues.
1320
1321 This mechanism matches if
1322
1323 o the <target-name> is a subdomain of a validated domain name, or 7208-eid4751:1 ../spf/spf.go:485
1324
1325 o the <target-name> and a validated domain name are the same.
1326
1327 For example, "mail.example.com" is within the domain "example.com",
1328 but "mail.bad-example.com" is not.
1329
1330 Note: This mechanism is slow, it is not as reliable as other
1331 mechanisms in cases of DNS errors, and it places a large burden on
1332 the .arpa name servers. If used, proper PTR records have to be in
1333 place for the domain's hosts and the "ptr" mechanism SHOULD be one of
1334 the last mechanisms checked. After many years of SPF deployment
1335 experience, it has been concluded that it is unnecessary and more
1336 reliable alternatives should be used instead. It is, however, still
1337 in use as part of the SPF protocol, so compliant check_host()
1338 implementations MUST support it.
1339
1340
1341
1342
1343
1344
1345
1346Kitterman Standards Track [Page 24]
1347
1348RFC 7208 Sender Policy Framework (SPF) April 2014
1349
1350
13515.6. "ip4" and "ip6" ../spf/spf.go:506
1352
1353 These mechanisms test whether <ip> is contained within a given
1354 IP network.
1355
1356 ip4 = "ip4" ":" ip4-network [ ip4-cidr-length ]
1357 ip6 = "ip6" ":" ip6-network [ ip6-cidr-length ]
1358
1359 ip4-cidr-length = "/" ("0" / %x31-39 0*1DIGIT) ; value range 0-32
1360 ip6-cidr-length = "/" ("0" / %x31-39 0*2DIGIT) ; value range 0-128
1361 dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ]
1362
1363 ip4-network = qnum "." qnum "." qnum "." qnum
1364 qnum = DIGIT ; 0-9
1365 / %x31-39 DIGIT ; 10-99
1366 / "1" 2DIGIT ; 100-199
1367 / "2" %x30-34 DIGIT ; 200-249
1368 / "25" %x30-35 ; 250-255
1369 ; as per conventional dotted-quad notation, e.g., 192.0.2.0
1370
1371 ip6-network = <as per Section 2.2 of [RFC4291]>
1372 ; e.g., 2001:db8::cd30
1373
1374 The <ip> is compared to the given network. If CIDR prefix length
1375 high-order bits match, the mechanism matches.
1376
1377 If ip4-cidr-length is omitted, it is taken to be "/32". If
1378 ip6-cidr-length is omitted, it is taken to be "/128". It is not
1379 permitted to omit parts of the IP address instead of using CIDR
1380 notations. That is, use 192.0.2.0/24 instead of 192.0.2.
1381
13825.7. "exists" 7208:984 ../spf/spf.go:517 ../spf/spf.go:527
1383
1384 This mechanism is used to construct an arbitrary domain name that is
1385 used for a DNS A record query. It allows for complicated schemes
1386 involving arbitrary parts of the mail envelope to determine what is
1387 permitted.
1388
1389 exists = "exists" ":" domain-spec
1390
1391 The <domain-spec> is expanded as per Section 7. The resulting domain
1392 name is used for a DNS A RR lookup (even when the connection type is
1393 IPv6). If any A record is returned, this mechanism matches.
1394
1395 Domains can use this mechanism to specify arbitrarily complex
1396 queries. For example, suppose example.com publishes the record:
1397
1398 v=spf1 exists:%{ir}.%{l1r+-}._spf.%{d} -all
1399
1400
1401
1402Kitterman Standards Track [Page 25]
1403
1404RFC 7208 Sender Policy Framework (SPF) April 2014
1405
1406
1407 The <target-name> might expand to
1408 "1.2.0.192.someuser._spf.example.com". This makes fine-grained
1409 decisions possible at the level of the user and client IP address.
1410
14116. Modifier Definitions
1412
1413 Modifiers are name/value pairs that provide additional information.
1414 Modifiers always have an "=" separating the name and the value.
1415
1416 The modifiers defined in this document ("redirect" and "exp") SHOULD
1417 appear at the end of the record, after all mechanisms, though
1418 syntactically they can appear anywhere in the record. Ordering of
1419 these two modifiers does not matter. These two modifiers MUST NOT ../spf/parse.go:163 ../spf/parse.go:170
1420 appear in a record more than once each. If they do, then
1421 check_host() exits with a result of "permerror".
1422
1423 Unrecognized modifiers MUST be ignored no matter where, or how often, ../spf/spf.go:559
1424 they appear in a record. This allows implementations conforming to
1425 this document to gracefully handle records with modifiers that are
1426 defined in other specifications.
1427
14286.1. redirect: Redirected Query
1429
1430 The "redirect" modifier is intended for consolidating both
1431 authorizations and policy into a common set to be shared within a
1432 single ADMD. It is possible to control both authorized hosts and
1433 policy for an arbitrary number of domains from a single record.
1434
1435 redirect = "redirect" "=" domain-spec
1436
1437 If all mechanisms fail to match, and a "redirect" modifier is
1438 present, then processing proceeds as follows:
1439
1440 The <domain-spec> portion of the redirect section is expanded as per ../spf/spf.go:561
1441 the macro rules in Section 7. Then check_host() is evaluated with
1442 the resulting string as the <domain>. The <ip> and <sender>
1443 arguments remain the same as in the current evaluation of
1444 check_host().
1445
1446 The result of this new evaluation of check_host() is then considered
1447 the result of the current evaluation with the exception that if no
1448 SPF record is found, or if the <target-name> is malformed, the result
1449 is a "permerror" rather than "none".
1450
1451 Note that the newly queried domain can itself specify redirect
1452 processing.
1453
1454
1455
1456
1457
1458Kitterman Standards Track [Page 26]
1459
1460RFC 7208 Sender Policy Framework (SPF) April 2014
1461
1462
1463 This facility is intended for use by organizations that wish to apply
1464 the same record to multiple domains. For example:
1465
1466 la.example.com. TXT "v=spf1 redirect=_spf.example.com"
1467 ny.example.com. TXT "v=spf1 redirect=_spf.example.com"
1468 sf.example.com. TXT "v=spf1 redirect=_spf.example.com"
1469 _spf.example.com. TXT "v=spf1 mx:example.com -all"
1470
1471 In this example, mail from any of the three domains is described by
1472 the same record. This can be an administrative advantage.
1473
1474 Note: In general, the domain "A" cannot reliably use a redirect to
1475 another domain "B" not under the same administrative control. Since
1476 the <sender> stays the same, there is no guarantee that the record at
1477 domain "B" will correctly work for mailboxes in domain "A",
1478 especially if domain "B" uses mechanisms involving local-parts. An
1479 "include" directive will generally be more appropriate.
1480
1481 For clarity, any "redirect" modifier SHOULD appear as the very last
1482 term in a record. Any "redirect" modifier MUST be ignored if there
1483 is an "all" mechanism anywhere in the record.
1484
14856.2. exp: Explanation ../spf/spf.go:915
1486
1487 explanation = "exp" "=" domain-spec
1488
1489 If check_host() results in a "fail" due to a mechanism match (such as ../spf/spf.go:548
1490 "-all"), and the "exp" modifier is present, then the explanation
1491 string returned is computed as described below. If no "exp" modifier ../spf/spf.go:925
1492 is present, then either a default explanation string or an empty
1493 explanation string MUST be returned to the calling application.
1494
1495 The <domain-spec> is macro expanded (see Section 7) and becomes the
1496 <target-name>. The DNS TXT RRset for the <target-name> is fetched.
1497
1498 If there are any DNS processing errors (any RCODE other than 0), or
1499 if no records are returned, or if more than one record is returned,
1500 or if there are syntax errors in the explanation string, then proceed
1501 as if no "exp" modifier was given.
1502
1503 The fetched TXT record's strings are concatenated with no spaces, and
1504 then treated as an explain-string, which is macro-expanded. This
1505 final result is the explanation string. Implementations MAY limit
1506 the length of the resulting explanation string to allow for other
1507 protocol constraints and/or reasonable processing limits. Since the todo: ../spf/spf.go:660
1508 explanation string is intended for an SMTP response and Section 2.4
1509 of [RFC5321] says that responses are in [US-ASCII], the explanation
1510 string MUST be limited to [US-ASCII].
1511
1512
1513
1514Kitterman Standards Track [Page 27]
1515
1516RFC 7208 Sender Policy Framework (SPF) April 2014
1517
1518
1519 Software evaluating check_host() can use this string to communicate
1520 information from the publishing domain in the form of a short message
1521 or URL. Software SHOULD make it clear that the explanation string
1522 comes from a third party. For example, it can prepend the macro
1523 string "%{o} explains: " to the explanation, as shown in the example
1524 in Section 8.4.
1525
1526 Suppose example.com has this record:
1527
1528 v=spf1 mx -all exp=explain._spf.%{d}
1529
1530 Here are some examples of possible explanation TXT records at
1531 explain._spf.example.com:
1532
1533 "Mail from example.com should only be sent by its own servers."
1534
1535 -- a simple, constant message
1536
1537 "%{i} is not one of %{d}'s designated mail servers."
1538
1539 -- a message with a little more information, including the
1540 IP address that failed the check
1541
1542 "See http://%{d}/why.html?s=%{S}&i=%{I}"
1543
1544 -- a complicated example that constructs a URL with the
1545 arguments to check_host() so that a web page can be
1546 generated with detailed, custom instructions
1547
1548 Note: During recursion into an "include" mechanism, an "exp" modifier ../spf/spf.go:392 ../spf/spf.go:569 ../spf/spf.go:919
1549 from the <target-name> MUST NOT be used. In contrast, when executing
1550 a "redirect" modifier, an "exp" modifier from the original domain
1551 MUST NOT be used. This is because "include" is meant to cross
1552 administrative boundaries and the explanation provided should be the
1553 one from the receiving ADMD, while "redirect" is meant to operate as
1554 a tool to consolidate policy records within an ADMD so the redirected
1555 explanation is the one that ought to have priority.
1556
15577. Macros
1558
1559 When evaluating an SPF policy record, certain character sequences are
1560 intended to be replaced by parameters of the message or of the
1561 connection. These character sequences are referred to as "macros".
1562
1563
1564
1565
1566
1567
1568
1569
1570Kitterman Standards Track [Page 28]
1571
1572RFC 7208 Sender Policy Framework (SPF) April 2014
1573
1574
15757.1. Formal Specification
1576
1577 The ABNF description for a macro is as follows:
1578
1579 domain-spec = macro-string domain-end ../spf/parse.go:271
1580 domain-end = ( "." toplabel [ "." ] ) / macro-expand
1581
1582 toplabel = ( *alphanum ALPHA *alphanum ) /
1583 ( 1*alphanum "-" *( alphanum / "-" ) alphanum )
1584 alphanum = ALPHA / DIGIT
1585
1586 explain-string = *( macro-string / SP )
1587
1588 macro-string = *( macro-expand / macro-literal ) ../spf/parse.go:315
1589 macro-expand = ( "%{" macro-letter transformers *delimiter "}" )
1590 / "%%" / "%_" / "%-"
1591 macro-literal = %x21-24 / %x26-7E
1592 ; visible characters except "%"
1593 macro-letter = "s" / "l" / "o" / "d" / "i" / "p" / "h" /
1594 "c" / "r" / "t" / "v"
1595 transformers = *DIGIT [ "r" ]
1596 delimiter = "." / "-" / "+" / "," / "/" / "_" / "="
1597
1598 The "toplabel" construction is subject to the letter-digit-hyphen
1599 (LDH) rule plus additional top-level domain (TLD) restrictions. See
1600 Section 2 of [RFC3696] for background.
1601
1602 Some special cases:
1603
1604 o A literal "%" is expressed by "%%".
1605
1606 o "%_" expands to a single " " space.
1607
1608 o "%-" expands to a URL-encoded space, viz., "%20".
1609
16107.2. Macro Definitions
1611
1612 The following macro letters are expanded in term arguments:
1613
1614 s = <sender>
1615 l = local-part of <sender>
1616 o = domain of <sender>
1617 d = <domain>
1618 i = <ip>
1619 p = the validated domain name of <ip> (do not use)
1620 v = the string "in-addr" if <ip> is ipv4, or "ip6" if <ip> is ipv6
1621 h = HELO/EHLO domain ../spf/spf.go:736
1622
1623
1624
1625
1626Kitterman Standards Track [Page 29]
1627
1628RFC 7208 Sender Policy Framework (SPF) April 2014
1629
1630
1631 <domain>, <sender>, and <ip> are defined in Section 4.1.
1632
1633 The following macro letters are allowed only in "exp" text:
1634
1635 c = SMTP client IP (easily readable format)
1636 r = domain name of host performing the check
1637 t = current timestamp
1638
16397.3. Macro Processing Details ../spf/spf.go:607
1640
1641 A '%' character not followed by a '{', '%', '-', or '_' character is ../spf/spf.go:606
1642 a syntax error. So:
1643
1644 -exists:%(ir).sbl.example.org
1645
1646 is incorrect and will cause check_host() to yield a "permerror".
1647 Instead, the following is legal:
1648
1649 -exists:%{ir}.sbl.example.org
1650
1651 Optional transformers are the following:
1652
1653 *DIGIT = zero or more digits
1654
1655 'r' = reverse value, splitting on dots by default ../spf/spf.go:775 ../spf/spf.go:805
1656
1657 If transformers or delimiters are provided, the replacement value for
1658 a macro letter is split into parts separated by one or more of the
1659 specified delimiter characters. After performing any reversal ../spf/spf.go:816
1660 operation and/or removal of left-hand parts, the parts are rejoined
1661 using "." and not the original splitting characters.
1662
1663 By default, strings are split on "." (dots). Note that no special
1664 treatment is given to leading, trailing, or consecutive delimiters in
1665 input strings, and so the list of parts might contain empty strings.
1666 Some older implementations of SPF prohibit trailing dots in domain
1667 names, so trailing dots SHOULD NOT be published, although they MUST
1668 be accepted by implementations conforming to this document. Macros
1669 can specify delimiter characters that are used instead of ".".
1670
1671 The "r" transformer indicates a reversal operation: if the client IP
1672 address were 192.0.2.1, the macro %{i} would expand to "192.0.2.1"
1673 and the macro %{ir} would expand to "1.2.0.192".
1674
1675 The DIGIT transformer indicates the number of right-hand parts to
1676 use, after optional reversal. If a DIGIT is specified, the value
1677 MUST be nonzero. If no DIGITs are specified, or if the value
1678 specifies more parts than are available, all the available parts are
1679
1680
1681
1682Kitterman Standards Track [Page 30]
1683
1684RFC 7208 Sender Policy Framework (SPF) April 2014
1685
1686
1687 used. If the DIGIT was 5, and only 3 parts were available, the macro
1688 interpreter would pretend the DIGIT was 3. Implementations MUST
1689 support at least a value of 127, as that is the maximum number of
1690 labels in a domain name (less the zero-length label at the end).
1691
1692 The "s" macro expands to the <sender> argument. It is an email
1693 address with a local-part, an "@" character, and a domain. The "l"
1694 macro expands to just the local-part. The "o" macro expands to just
1695 the domain part. Note that these values remain the same during
1696 recursive and chained evaluations due to "include" and/or "redirect".
1697 Note also that if the original <sender> had no local-part, the
1698 local-part was set to "postmaster" in initial processing (see
1699 Section 4.3).
1700
1701 For IPv4 addresses, both the "i" and "c" macros expand to the
1702 standard dotted-quad format.
1703
1704 For IPv6 addresses, the "i" macro expands to a dot-format address; it
1705 is intended for use in %{ir}. The "c" macro can expand to any of the
1706 hexadecimal colon-format addresses specified in Section 2.2 of
1707 [RFC4291]. It is intended for humans to read.
1708
1709 The "p" macro expands to the validated domain name of <ip>. The ../spf/spf.go:680 ../spf/spf.go:724
1710 procedure for finding the validated domain name is defined in
1711 Section 5.5. If the <domain> is present in the list of validated
1712 domains, it SHOULD be used. Otherwise, if a subdomain of the
1713 <domain> is present, it SHOULD be used. Otherwise, any name from the
1714 list can be used. If there are no validated domain names or if a DNS ../spf/spf.go:694
1715 error occurs, the string "unknown" is used.
1716
1717 This macro SHOULD NOT be published (see Section 5.5 for the
1718 discussion).
1719
1720 The "h" macro expands to the parameter that was provided to the SMTP
1721 server via the HELO or EHLO SMTP verb. For sessions where that verb
1722 was provided more than once, the most recent instance is used.
1723
1724 The "r" macro expands to the name of the receiving MTA. This SHOULD
1725 be a fully qualified domain name, but if one does not exist (as when
1726 the checking is done by a Mail User Agent (MUA)) or if policy
1727 restrictions dictate otherwise, the word "unknown" SHOULD be
1728 substituted. The domain name can be different from the name found in
1729 the MX record that the client MTA used to locate the receiving MTA.
1730
1731
1732
1733
1734
1735
1736
1737
1738Kitterman Standards Track [Page 31]
1739
1740RFC 7208 Sender Policy Framework (SPF) April 2014
1741
1742
1743 The "t" macro expands to the decimal representation of the
1744 approximate number of seconds since the Epoch (Midnight, January 1,
1745 1970, UTC) at the time of the evaluation. This is the same value as
1746 the value that is returned by the Portable Operating System Interface
1747 (POSIX) time() function in most standards-compliant libraries.
1748
1749 When the result of macro expansion is used in a domain name query, if ../spf/spf.go:834
1750 the expanded domain name exceeds 253 characters (the maximum length
1751 of a domain name in this format), the left side is truncated to fit,
1752 by removing successive domain labels (and their following dots) until
1753 the total length does not exceed 253 characters.
1754
1755 Uppercase macros expand exactly as their lowercase equivalents, and ../spf/spf.go:820
1756 are then URL escaped. URL escaping MUST be performed for characters
1757 not in the "unreserved" set, which is defined in [RFC3986].
1758
1759 Care has to be taken by the sending ADMD so that macro expansion for
1760 legitimate email does not exceed the 63-character limit on DNS
1761 labels. The local-part of email addresses, in particular, can have
1762 more than 63 characters between dots.
1763
1764 To minimize DNS lookup resource requirements, it is better if sending
1765 ADMDs avoid using the "s", "l", "o", or "h" macros in conjunction
1766 with any mechanism directive. Although these macros are powerful and
1767 allow per-user records to be published, they severely limit the
1768 ability of implementations to cache results of check_host() and they
1769 reduce the effectiveness of DNS caches.
1770
1771 If no directive processed during the evaluation of check_host()
1772 contains an "s", "l", "o", or "h" macro, then the results of the
1773 evaluation can be cached on the basis of <domain> and <ip> alone for
1774 as long as the DNS record involved with the shortest Time to Live
1775 (TTL) has not expired.
1776
17777.4. Expansion Examples ../spf/spf_test.go:94
1778
1779 The <sender> is strong-bad@email.example.com. The IPv4 SMTP client
1780 IP is 192.0.2.3. The IPv6 SMTP client IP is 2001:db8::cb01. The PTR
1781 domain name of the client IP is mx.example.org.
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794Kitterman Standards Track [Page 32]
1795
1796RFC 7208 Sender Policy Framework (SPF) April 2014
1797
1798
1799 macro expansion
1800 ------- ----------------------------
1801 %{s} strong-bad@email.example.com
1802 %{o} email.example.com
1803 %{d} email.example.com
1804 %{d4} email.example.com
1805 %{d3} email.example.com
1806 %{d2} example.com
1807 %{d1} com
1808 %{dr} com.example.email
1809 %{d2r} example.email
1810 %{l} strong-bad
1811 %{l-} strong.bad
1812 %{lr} strong-bad
1813 %{lr-} bad.strong
1814 %{l1r-} strong
1815
1816 macro-string expansion
1817 --------------------------------------------------------------------
1818 %{ir}.%{v}._spf.%{d2} 3.2.0.192.in-addr._spf.example.com
1819 %{lr-}.lp._spf.%{d2} bad.strong.lp._spf.example.com
1820
1821 %{lr-}.lp.%{ir}.%{v}._spf.%{d2}
1822 bad.strong.lp.3.2.0.192.in-addr._spf.example.com
1823
1824 %{ir}.%{v}.%{l1r-}.lp._spf.%{d2}
1825 3.2.0.192.in-addr.strong.lp._spf.example.com
1826
1827 %{d2}.trusted-domains.example.net
1828 example.com.trusted-domains.example.net
1829
1830 IPv6:
1831 %{ir}.%{v}._spf.%{d2} 1.0.b.c.0.0.0.0.
1832 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6._spf.example.com
1833
18348. Result Handling
1835
1836 This section provides guidance for SPF verifier operators in response ../spf/spf.go:68
1837 to the various possible outputs of check_host() on a message.
1838 Definitions of SPF results are presented in Section 2.6; this section
1839 provides more detail on each for use in developing local policy for
1840 message handling.
1841
1842 Every operating environment is different. There are some receivers
1843 for whom strict adherence to SPF is appropriate, and definitive
1844 treatment of messages that are evaluated to be explicitly
1845 unauthorized ("fail" and sometimes "softfail") is the norm. There
1846 are others for which the "false negative" cases are more of a
1847
1848
1849
1850Kitterman Standards Track [Page 33]
1851
1852RFC 7208 Sender Policy Framework (SPF) April 2014
1853
1854
1855 concern. This concern is typically handled by merely recording the
1856 result in the header and allowing the message to pass on for
1857 additional processing. There are still others where SPF is one of
1858 several inputs to the message-handling decision. As such, there is
1859 no comprehensive normative requirement for message handling in
1860 response to any particular result. This section is provided to
1861 present a complete picture of the likely cause of each result and,
1862 where available, the experience gained during experimental
1863 deployment.
1864
1865 There are essentially two classes of handling choices:
1866
1867 o Handling within the SMTP session that attempted to deliver the
1868 message, such as by returning a permanent SMTP error (rejection)
1869 or temporary SMTP error ("try again later");
1870
1871 o Permitting the message to pass (a successful SMTP reply code) and
1872 adding an additional header field that indicates the result
1873 returned by check_host() and other salient details; this is
1874 discussed in more detail in Section 9.
1875
18768.1. None
1877
1878 With a "none" result, the SPF verifier has no information at all
1879 about the authorization or lack thereof of the client to use the
1880 checked identity or identities. The check_host() function completed
1881 without errors but was not able to reach any conclusion.
1882
18838.2. Neutral
1884
1885 A "neutral" result indicates that although a policy for the identity
1886 was discovered, there is no definite assertion (positive or negative)
1887 about the client.
1888
1889 A "neutral" result MUST be treated exactly like the "none" result;
1890 the distinction exists only for informational purposes. Treating
1891 "neutral" more harshly than "none" would discourage ADMDs from
1892 testing the use of SPF records (see Section 10.1).
1893
18948.3. Pass
1895
1896 A "pass" result means the client is authorized to inject mail with
1897 the given identity. The domain can now, in the sense of reputation,
1898 be considered responsible for sending the message. Further policy
1899 checks can now proceed with confidence in the legitimate use of the
1900 identity. This is further discussed in Appendix G.1.
1901
1902
1903
1904
1905
1906Kitterman Standards Track [Page 34]
1907
1908RFC 7208 Sender Policy Framework (SPF) April 2014
1909
1910
19118.4. Fail
1912
1913 A "fail" result is an explicit statement that the client is not
1914 authorized to use the domain in the given identity. Disposition of
1915 SPF fail messages is a matter of local policy. See Appendix G.2 for
1916 considerations on developing local policy.
1917
1918 If the checking software chooses to reject the mail during the SMTP
1919 transaction, then it SHOULD use an SMTP reply code of 550 (see
1920 [RFC5321]) and, if supported, the 5.7.1 enhanced status code (see
1921 [RFC3463], Section 3.8), in addition to an appropriate reply text.
1922 The check_host() function will return either a default explanation
1923 string or one from the domain that published the SPF records (see
1924 Section 6.2). If the information does not originate with the
1925 checking software, it is good to make it clear that the text is
1926 provided by the sender's domain. For example:
1927
1928 550 5.7.1 SPF MAIL FROM check failed: 7208-eid6721:1 ../spf/spf.go:36
1929 550 5.7.1 The domain example.com explains:
1930 550 5.7.1 Please see http://www.example.com/mailpolicy.html
1931
1932 If the checking software chooses not to reject the mail during the
1933 SMTP transaction, then it SHOULD add a Received-SPF or
1934 Authentication-Results header field (see Section 9) to communicate
1935 this result to downstream message processors. While this is true for
1936 all SPF results, it is of particular importance for "fail" results
1937 since the message is explicitly not authorized by the ADMD.
1938
19398.5. Softfail
1940
1941 A "softfail" result ought to be treated as somewhere between "fail"
1942 and "neutral"/"none". The ADMD believes the host is not authorized
1943 but is not willing to make a strong policy statement. Receiving
1944 software SHOULD NOT reject the message based solely on this result,
1945 but MAY subject the message to closer scrutiny than normal.
1946
1947 The ADMD wants to discourage the use of this host and thus desires
1948 limited feedback when a "softfail" result occurs. For example, the
1949 recipient's MUA could highlight the "softfail" status, or the
1950 receiving MTA could give the sender a message using greylisting
1951 [RFC6647], with a note the first time the message is received, but
1952 accept it on a later attempt based on receiver policy.
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962Kitterman Standards Track [Page 35]
1963
1964RFC 7208 Sender Policy Framework (SPF) April 2014
1965
1966
19678.6. Temperror
1968
1969 A "temperror" result means the SPF verifier encountered a transient
1970 (generally DNS) error while performing the check. Checking software
1971 can choose to accept or temporarily reject the message. If the
1972 message is rejected during the SMTP transaction for this reason, the
1973 software SHOULD use an SMTP reply code of 451 and, if supported, the
1974 4.4.3 enhanced status code (see Section 3.5 of [RFC3463]). These
1975 errors can be caused by problems in either the sender's or receiver's
1976 DNS software. See Appendix G.4 for considerations on developing
1977 local policy.
1978
19798.7. Permerror
1980
1981 A "permerror" result means the domain's published records could not
1982 be correctly interpreted. This signals an error condition that
1983 definitely requires DNS operator intervention to be resolved. If the
1984 message is rejected during the SMTP transaction for this reason, the
1985 software SHOULD use an SMTP reply code of 550 and, if supported, the
1986 5.5.2 enhanced status code (see [RFC3463], Section 3.6). Be aware
1987 that if the ADMD uses macros (Section 7), it is possible that this
1988 result is due to the checked identities having an unexpected format.
1989 It is also possible that this result is generated by certain SPF
1990 verifiers due to the input arguments having an unexpected format; see
1991 Section 4.8. See Appendix G.3 for considerations on developing local
1992 policy.
1993
19949. Recording the Result
1995
1996 To provide downstream agents, such as MUAs, with the information they
1997 might need in terms of evaluating or representing the apparent safety
1998 of the message content, it is RECOMMENDED that SMTP receivers record
1999 the result of SPF processing in the message header. For SPF verifier
2000 operators that choose to record SPF results in the header of the
2001 message for processing by internal filters or MUAs, two methods are
2002 presented: Section 9.1 defines the Received-SPF field, which is the
2003 results field originally defined for SPF use. Section 9.2 discusses
2004 the Authentication-Results header field [RFC7001], which was
2005 specified more recently and is designed for use by SPF and other
2006 authentication methods.
2007
2008 Both are in common use, and hence both are included here. However,
2009 it is important to note that they were designed to serve slightly
2010 different purposes. Received-SPF is intended to include enough
2011 information to enable reconstruction of the SPF evaluation of the
2012 message, while Authentication-Results is designed only to relay the
2013 result itself and related output details of likely use to end users
2014 (e.g., what property of the message was actually authenticated and
2015
2016
2017
2018Kitterman Standards Track [Page 36]
2019
2020RFC 7208 Sender Policy Framework (SPF) April 2014
2021
2022
2023 what it contained), leaving reconstructive work to the purview of
2024 system logs and the Received field contents. Also, Received-SPF
2025 relies on compliance of agents within the receiving ADMD to adhere to
2026 the header field ordering rules of [RFC5321] and [RFC5322], while
2027 Authentication-Results includes some provisions to protect against
2028 non-compliant implementations.
2029
2030 An SPF verifier operator could choose to use both to serve different
2031 downstream agents. In such cases, care needs to be taken to ensure
2032 that both fields are conveying the same details, or unexpected
2033 results can occur.
2034
20359.1. The Received-SPF Header Field
2036
2037 The Received-SPF header field is a trace field (see [RFC5322],
2038 Section 3.6.7) and SHOULD be prepended to the existing header, above ../smtpserver/server.go:2854
2039 the Received: field that is generated by the SMTP receiver. It MUST
2040 appear above all other Received-SPF fields in the message. The
2041 header field has the following format:
2042
2043 header-field = "Received-SPF:" [CFWS] result FWS [comment FWS] 7208-eid5436:1 ../spf/received.go:89 ../spf/spf.go:35
2044 [ key-value-list ] CRLF
2045
2046 result = "pass" / "fail" / "softfail" / "neutral" /
2047 "none" / "temperror" / "permerror"
2048
2049 key-value-list = key-value-pair *( ";" [CFWS] key-value-pair )
2050 [";"]
2051
2052 key-value-pair = key [CFWS] "=" ( dot-atom / quoted-string )
2053
2054 key = "client-ip" / "envelope-from" / "helo" /
2055 "problem" / "receiver" / "identity" /
2056 "mechanism" / name
2057
2058 identity = "mailfrom" ; for the "MAIL FROM" identity
2059 / "helo" ; for the "HELO" identity
2060 / name ; other identities
2061
2062 dot-atom = <unquoted word as per [RFC5322]>
2063 quoted-string = <quoted string as per [RFC5322]>
2064 comment = <comment string as per [RFC5322]>
2065 CFWS = <comment or folding white space as per [RFC5322]>
2066 FWS = <folding white space as per [RFC5322]>
2067 CRLF = <standard end-of-line token as per [RFC5322]>
2068
2069
2070
2071
2072
2073
2074Kitterman Standards Track [Page 37]
2075
2076RFC 7208 Sender Policy Framework (SPF) April 2014
2077
2078
2079 The header field SHOULD include a "(...)" style comment after the
2080 result, conveying supporting information for the result, such as
2081 <ip>, <sender>, and <domain>.
2082
2083 The following key-value pairs are designed for later machine parsing. ../spf/received.go:11
2084 SPF verifiers SHOULD give enough information so that the SPF results
2085 can be verified -- that is, at least "client-ip", "helo", and, if the
2086 "MAIL FROM" identity was checked, "envelope-from".
2087
2088 client-ip the IP address of the SMTP client
2089
2090 envelope-from the envelope sender mailbox ../spf/spf.go:224
2091
2092 helo the host name given in the HELO or EHLO command
2093
2094 mechanism the mechanism that matched (if no mechanisms matched,
2095 substitute the word "default") 7208:996 ../spf/spf.go:578
2096
2097 problem if an error was returned, details about the error
2098
2099 receiver the host name of the SPF verifier
2100
2101 identity the identity that was checked; see the <identity>
2102 ABNF rule
2103
2104 Other keys MAY be defined by SPF verifiers.
2105
2106 SPF verifiers MUST make sure that the Received-SPF header field does
2107 not contain invalid characters, is not excessively long (see
2108 [RFC5322], Section 2.1.1), and does not contain malicious data that
2109 has been provided by the sender.
2110
2111 Examples of various header field styles that could be generated are
2112 the following:
2113
2114 Received-SPF: pass (mybox.example.org: domain of
2115 myname@example.com designates 192.0.2.1 as permitted sender)
2116 receiver=mybox.example.org; client-ip=192.0.2.1;
2117 envelope-from="myname@example.com"; helo=foo.example.com;
2118
2119 Received-SPF: fail (mybox.example.org: domain of
2120 myname@example.com does not designate
2121 192.0.2.1 as permitted sender)
2122 identity=mailfrom; client-ip=192.0.2.1;
2123 envelope-from="myname@example.com";
2124
2125
2126
2127
2128
2129
2130Kitterman Standards Track [Page 38]
2131
2132RFC 7208 Sender Policy Framework (SPF) April 2014
2133
2134
2135 Received-SPF: pass (mybox.example.org: domain of
2136 myname@example.com designates 192.0.2.1 as permitted sender)
2137 receiver=mybox.example.org; client-ip=192.0.2.1;
2138 mechanism=ip4:192.0.2.1; envelope-from="myname@example.com";
2139 helo=foo.example.com;
2140
21419.2. SPF Results in the Authentication-Results Header Field ../smtpserver/server.go:2483
2142
2143 As mentioned in Section 9, the Authentication-Results header field is
2144 designed to communicate lists of tests a border MTA did and their
2145 results. The specified elements of the field provide less
2146 information than the Received-SPF field:
2147
2148 Authentication-Results: myhost.example.org; spf=pass
2149 smtp.mailfrom=example.net
2150
2151 Received-SPF: pass (myhost.example.org: domain of
2152 myname@example.com designates 192.0.2.1 as permitted sender)
2153 receiver=mybox.example.org; client-ip=192.0.2.1;
2154 envelope-from="myname@example.com"; helo=foo.example.com;
2155
2156 It is, however, possible to add CFWS in the "reason" part of an
2157 Authentication-Results header field and provide the equivalent
2158 information, if desired.
2159
2160 As an example, an expanded Authentication-Results header field might
2161 look like (for a "MAIL FROM" check in this example):
2162
2163 Authentication-Results: myhost.example.org; spf=pass
2164 reason="client-ip=192.0.2.1; smtp.helo=foo.example.com"
2165 smtp.mailfrom=user@example.net
2166
216710. Effects on Infrastructure ../smtpserver/reputation.go:99
2168
2169 This section outlines the major implications that adoption of this
2170 protocol will have on various entities involved in Internet email.
2171 It is intended to make clear to the reader where this protocol
2172 knowingly affects the operation of such entities. This section is
2173 not a "how-to" manual, or a "best practices" document, and it is not
2174 a comprehensive list of what such entities ought to do in light of
2175 this specification.
2176
2177 This section provides operational advice and instruction only. It is
2178 non-normative.
2179
2180 [RFC5598] describes the Internet email architecture. This section is
2181 organized based on the different segments of the architecture.
2182
2183
2184
2185
2186Kitterman Standards Track [Page 39]
2187
2188RFC 7208 Sender Policy Framework (SPF) April 2014
2189
2190
219110.1. Sending Domains
2192
2193 Originating ADMDs (ADministrative Management Domains --
2194 Sections 2.2.1 and 2.3 of [RFC5598]) that wish to be compliant with
2195 this specification will need to determine the list of relays
2196 ([RFC5598], Section 2.2.2) that they allow to use their domain name
2197 in the "HELO" and "MAIL FROM" identities when relaying to other
2198 ADMDs. It is recognized that forming such a list is not just a
2199 simple technical exercise, but involves policy decisions with both
2200 technical and administrative considerations.
2201
220210.1.1. DNS Resource Considerations
2203
2204 Minimizing the DNS resources needed for SPF lookups can be done by
2205 choosing directives that require less DNS information and by placing
2206 lower-cost mechanisms earlier in the SPF record.
2207
2208 Section 4.6.4 specifies the limits receivers have to use. It is
2209 essential to publish records that do not exceed these requirements.
2210 It is also required to carefully weigh the cost and the
2211 maintainability of licit solutions.
2212
2213 For example, consider a domain set up as follows:
2214
2215 example.com. IN MX 10 mx.example.com.
2216 IN MX 20 mx2.example.com.
2217 mx.example.com. IN A 192.0.2.1
2218 mx2.example.com. IN A 192.0.2.129
2219
2220 Assume the administrative point is to authorize (pass) mx and mx2
2221 while failing every other host. Compare the following solutions:
2222
2223 Best record:
2224 example.com. IN TXT "v=spf1 ip4:192.0.2.1 ip4:192.0.2.129 -all"
2225
2226 Good record:
2227 $ORIGIN example.com.
2228 @ IN TXT "v=spf1 a:authorized-spf.example.com -all"
2229 authorized-spf IN A 192.0.2.1
2230 IN A 192.0.2.129
2231
2232 Expensive record:
2233 example.com. IN TXT "v=spf1 mx:example.com -all"
2234
2235 Wasteful, bad record:
2236 example.com. IN TXT "v=spf1 ip4:192.0.2.0/24 mx -all"
2237
2238
2239
2240
2241
2242Kitterman Standards Track [Page 40]
2243
2244RFC 7208 Sender Policy Framework (SPF) April 2014
2245
2246
224710.1.2. Administrator's Considerations
2248
2249 There might be administrative considerations: using "a" over "ip4" or
2250 "ip6" allows hosts to be renumbered easily at the cost of a DNS query
2251 per receiver. Using "mx" over "a" allows the set of mail hosts to be
2252 changed easily. Unless such changes are common, it is better to use
2253 the less resource-intensive mechanisms like "ip4" and "ip6" over "a"
2254 or "a" over "mx".
2255
2256 In some specific cases, standard advice on record content is
2257 appropriate. Publishing SPF records for domains that send no mail is
2258 a well-established best practice. The record for a domain that sends
2259 no mail is:
2260
2261 www.example.com. IN TXT "v=spf1 -all"
2262
2263 Publishing SPF records for individual hosts is also best practice. 7208:2287 ../mox-/admin.go:753 ../webadmin/admin.go:1017
2264 The host name is generally the identity used in the 5321.HELO/.EHLO
2265 command. In the case of messages with a null 5321.MailFrom, this is
2266 used as the domain for 5321.MailFrom SPF checks, in addition to being
2267 used in 5321.HELO/.EHLO-based SPF checks. The standard SPF record
2268 for an individual host that is involved in mail processing is:
2269
2270 relay.example.com. IN TXT "v=spf1 a -all"
2271
2272 Validating correct deployment is difficult. [RFC6652] describes one
2273 mechanism for soliciting feedback on SPF failures. Another
2274 suggestion can be found in Appendix C.
2275
2276 Regardless of the method used, understanding the ADMD's outbound mail
2277 architecture is essential to effective deployment.
2278
227910.1.3. Bounces
2280
2281 As explained in Section 2.4, [RFC5321] allows the MAIL FROM to be
2282 null, which is typical of some Delivery Status Notifications
2283 [RFC3464], commonly called email bounces. In this case, the only
2284 entity available for performing an SPF check is the "HELO" identity
2285 defined in Section 1.1.4. SPF functionality is enhanced by
2286 administrators ensuring this identity is set correctly and has an
2287 appropriate SPF record. It is normal to have the "HELO" identity set 7208:2263 ../mox-/admin.go:753 ../webadmin/admin.go:1017
2288 to the host name instead of the domain. Zone file generation for
2289 significant numbers of hosts can be consolidated using the "redirect"
2290 modifier and scripted for initial deployment. Specific deployment
2291 advice is given above in Section 10.1.2.
2292
2293
2294
2295
2296
2297
2298Kitterman Standards Track [Page 41]
2299
2300RFC 7208 Sender Policy Framework (SPF) April 2014
2301
2302
230310.2. Receivers
2304
2305 SPF results can be used in combination with other methods to
2306 determine the final local disposition (either positive or negative)
2307 of a message. It can also be considered dispositive on its own.
2308
2309 An attempt to have one organization (sender) direct the email-
2310 handling policies of another (receiver) is inherently challenging and
2311 often controversial. As stated elsewhere in this document, there is
2312 no comprehensive normative requirement for specific handling of a
2313 message based on SPF results. The information presented in Section 8
2314 and in Appendix G is offered for receiver consideration when forming
2315 local handling policies.
2316
2317 The primary considerations are that SPF might return "pass" for mail
2318 that is ultimately harmful (e.g., spammers that arrange for SPF to
2319 pass using disposable domain names, or virus or spam outbreaks from
2320 within trusted sources), and might also return "fail" for mail that
2321 is ultimately legitimate (e.g., legitimate mail that has traversed a
2322 mail alias). It is important to take both of these cases under
2323 consideration when establishing local handling policy.
2324
232510.3. Mediators
2326
2327 Mediators are a type of User Actor [RFC5598]. That is, a mediator
2328 takes 'delivery' of a message and posts a 'submission' of a new
2329 message. The mediator can make the newly posted message be as
2330 similar to or as different from the original message as they wish.
2331 Examples include mailing lists (see Section 5.3 of [RFC5598]) and
2332 ReSenders (Section 5.2 of [RFC5598]). This is discussed in
2333 [RFC5321], Section 3.9. For the operation of SPF, the essential
2334 concern is the email address in the 5321.MailFrom command for the new
2335 message.
2336
2337 Because SPF evaluation is based on the IP address of the "last"
2338 sending SMTP server, the address of the mediator will be used, rather
2339 than the address of the SMTP server that sent the message to the
2340 mediator. Some mediators retain the email address from the original
2341 message, while some use a new address.
2342
2343 If the address is the same as for the original message, and the
2344 original message had an associated SPF record, then the SPF
2345 evaluation will fail unless mitigations such as those described in
2346 Appendix D are used.
2347
2348
2349
2350
2351
2352
2353
2354Kitterman Standards Track [Page 42]
2355
2356RFC 7208 Sender Policy Framework (SPF) April 2014
2357
2358
235911. Security Considerations
2360
236111.1. Processing Limits
2362
2363 As with most aspects of email, there are a number of ways that
2364 malicious parties could use the protocol as an avenue for a DoS
2365 attack. The processing limits outlined in Section 4.6.4 are designed
2366 to prevent attacks such as the following:
2367
2368 o A malicious party could create an SPF record with many references
2369 to a victim's domain and send many emails to different SPF
2370 verifiers; those SPF verifiers would then create a DoS attack. In
2371 effect, the SPF verifiers are being used to amplify the attacker's
2372 bandwidth by using fewer octets in the SMTP session than are used
2373 by the DNS queries. Using SPF verifiers also allows the attacker
2374 to hide the true source of the attack. This potential attack is
2375 based on large volumes of mail being transmitted.
2376
2377 o Whereas implementations of check_host() are supposed to limit the
2378 number of DNS lookups, malicious domains could publish records
2379 that exceed these limits in an attempt to waste computation effort
2380 at their targets when they send them mail. Malicious domains
2381 could also design SPF records that cause particular
2382 implementations to use excessive memory or CPU or to trigger bugs.
2383 If a receiver is configured to accept mail with an SPF result of
2384 "temperror", such an attack might result in mail that would
2385 otherwise have been rejected due to an SPF "fail" result being
2386 accepted. This potential attack is based on specially crafted SPF
2387 records being used to exhaust DNS resources of the victim.
2388
2389 o Malicious parties could send a large volume of mail purporting to
2390 come from the intended target to a wide variety of legitimate mail
2391 hosts. These legitimate machines would then present a DNS load on
2392 the target as they fetched the relevant records.
2393
2394 o Malicious parties could, in theory, use SPF records as a vehicle
2395 for DNS lookup amplification for a DoS attack. In this scenario,
2396 the attacker publishes an SPF record in its own DNS that uses "a"
2397 and "mx" mechanisms directed toward the intended victim, e.g.,
2398 "a:example.com a:foo.example.com a:bar.example.com ..." and then
2399 distributes mail with a MAIL FROM value including its own domain
2400 in large volume to a wide variety of destinations. Any such
2401 destination operating an SPF verifier will begin querying all of
2402 the names associated with the "a" mechanisms in that record. The
2403 names used in the record needn't exist for the attack to be
2404 effective. Operational experience since the publication of
2405 [RFC4408] suggests that mitigation of this class of attack can be
2406 accomplished with minimal impact on the deployed base by having
2407
2408
2409
2410Kitterman Standards Track [Page 43]
2411
2412RFC 7208 Sender Policy Framework (SPF) April 2014
2413
2414
2415 the verifier abort processing and return "permerror"
2416 (Section 2.6.7) as soon as more than two "void lookups" have been
2417 encountered (defined in Section 4.6.4).
2418
2419 Of these, the case of a third party referenced in the SPF record is
2420 the easiest for a DoS attack to effectively exploit. As a result,
2421 limits that might seem reasonable for an individual mail server can
2422 still allow an unreasonable amount of bandwidth amplification.
2423 Therefore, the processing limits need to be quite low.
2424
242511.2. SPF-Authorized Email May Contain Other False Identities
2426
2427 The "MAIL FROM" and "HELO" identity authorizations do not provide
2428 assurance about the authorization/authenticity of other identities
2429 used in the message. It is entirely possible for a malicious sender
2430 to inject a message using his own domain in the identities used by
2431 SPF and have that domain's SPF record authorize the sending host, and
2432 yet the message can easily list other identities in its header.
2433 Unless the user or the MUA takes care to note that the authorized
2434 identity does not match the other more commonly presented identities
2435 (such as the From: header field), the user might be lulled into a
2436 false sense of security.
2437
243811.3. Spoofed DNS and IP Data
2439
2440 There are two aspects of this protocol that malicious parties could
2441 exploit to undermine the validity of the check_host() function:
2442
2443 o The evaluation of check_host() relies heavily on DNS. A malicious
2444 attacker could attack the DNS infrastructure and cause
2445 check_host() to see spoofed DNS data, and then return incorrect
2446 results. This could include returning "pass" for an <ip> value
2447 where the actual domain's record would evaluate to "fail". See
2448 [RFC3833] for a description of DNS weaknesses, and see [RFC4033]
2449 for a countermeasure.
2450
2451 o The client IP address, <ip>, is assumed to be correct. In a
2452 modern, correctly configured system, the risk of this not being
2453 true is nil.
2454
245511.4. Cross-User Forgery
2456
2457 By definition, SPF policies just map domain names to sets of
2458 authorized MTAs, not whole email addresses to sets of authorized
2459 users. Although the "l" macro (Section 7) provides a limited way to
2460 define individual sets of authorized MTAs for specific email
2461 addresses, it is generally impossible to verify, through SPF, the use
2462 of specific email addresses by individual users of the same MTA.
2463
2464
2465
2466Kitterman Standards Track [Page 44]
2467
2468RFC 7208 Sender Policy Framework (SPF) April 2014
2469
2470
2471 It is up to mail services and their MTAs to directly prevent
2472 cross-user forgery: based on SMTP AUTH ([RFC4954]), users have to be
2473 restricted to using only those email addresses that are actually
2474 under their control (see Section 6.1 of [RFC6409]). Another means to
2475 verify the identity of individual users is message cryptography, such
2476 as Pretty Good Privacy (PGP) ([RFC4880]) or S/MIME ([RFC5751]).
2477
247811.5. Untrusted Information Sources
2479
2480 An SPF-compliant receiver gathers information from the SMTP commands
2481 it receives and from the published DNS records of the sending domain
2482 holder (e.g., "HELO" domain name, the "MAIL FROM" address from the
2483 envelope, and SPF DNS records published by the domain holder). These
2484 parameters are not validated in the SMTP process.
2485
2486 All of these pieces of information are generated by actors outside of
2487 the authority of the receiver, and thus are not guaranteed to be
2488 accurate or legitimate.
2489
249011.5.1. Recorded Results
2491
2492 This information, passed to the receiver in the Received-SPF: or
2493 Authentication-Results: trace fields, can be returned to the client
2494 MTA as an SMTP rejection message. If such an SMTP rejection message
2495 is generated, the information from the trace fields has to be checked
2496 for such problems as invalid characters and excessively long lines.
2497
249811.5.2. External Explanations
2499
2500 When the authorization check fails, an explanation string could be
2501 included in the reject response. Both the sender and the rejecting
2502 receiver need to be aware that the explanation was determined by the
2503 publisher of the SPF record checked and, in general, not the
2504 receiver. The explanation can contain malicious URLs, or it might be
2505 offensive or misleading.
2506
2507 Explanations returned to sender domains due to "exp" modifiers
2508 (Section 6.2) were generated by the sender policy published by the
2509 domain holders themselves. As long as messages are only returned
2510 with non-delivery notifications ([RFC3464]) to domains publishing the
2511 explanation strings from their own DNS SPF records, the only affected
2512 parties are the original publishers of the domain's SPF records.
2513
2514 In practice, such non-delivery notifications can be misdirected, such
2515 as when an MTA accepts an email and only later generates the
2516 notification to a forged address, or when an email forwarder does not
2517 direct the bounce back to the original sender.
2518
2519
2520
2521
2522Kitterman Standards Track [Page 45]
2523
2524RFC 7208 Sender Policy Framework (SPF) April 2014
2525
2526
252711.5.3. Macro Expansion
2528
2529 Macros (Section 7) allow senders to inject arbitrary text (any ../smtpserver/server.go:2518
2530 non-null [US-ASCII] character) into receiver DNS queries. It is
2531 necessary to be prepared for hostile or unexpected content.
2532
253311.6. Privacy Exposure
2534
2535 Checking SPF records causes DNS queries to be sent to the domain
2536 owner. These DNS queries, especially if they are caused by the
2537 "exists" mechanism, can contain information about who is sending
2538 email and likely to which MTA the email is being sent. This can
2539 introduce some privacy concerns, which are more or less of an issue
2540 depending on local laws and the relationship between the ADMD and the
2541 person sending the email.
2542
254311.7. Delivering Mail Producing a "Fail" Result
2544
2545 Operators that choose to deliver mail for which SPF produces a "fail"
2546 result need to understand that they are admitting content that is
2547 explicitly not authorized by the purported sender. While there are
2548 known failure modes that can be considered "false negatives", the
2549 distinct choice to admit those messages increases end-user exposure
2550 to likely harm. This is especially true for domains belonging to
2551 known good actors that are typically well-behaved; unauthorized mail
2552 from those sources might well be subjected to much higher skepticism
2553 and content analysis.
2554
2555 SPF does not, however, include the capacity to distinguish good
2556 actors from bad ones, nor does it handle the concept of known actors
2557 versus unknown ones. Those notions are out of scope for this
2558 specification.
2559
256012. Collected ABNF
2561
2562 This section is normative, and any discrepancies with the ABNF
2563 fragments in the preceding text are to be resolved in favor of this
2564 grammar.
2565
2566 See [RFC5234] for ABNF notation. Please note that as per this ABNF
2567 definition, literal text strings (those in quotes) are case-
2568 insensitive. Hence, "mx" matches "mx", "MX", "mX", and "Mx".
2569
2570 record = version terms *SP
2571 version = "v=spf1"
2572
2573 terms = *( 1*SP ( directive / modifier ) )
2574
2575
2576
2577
2578Kitterman Standards Track [Page 46]
2579
2580RFC 7208 Sender Policy Framework (SPF) April 2014
2581
2582
2583 directive = [ qualifier ] mechanism
2584 qualifier = "+" / "-" / "?" / "~"
2585 mechanism = ( all / include ../spf/parse.go:177
2586 / a / mx / ptr / ip4 / ip6 / exists )
2587
2588 all = "all"
2589 include = "include" ":" domain-spec
2590 a = "a" [ ":" domain-spec ] [ dual-cidr-length ]
2591 mx = "mx" [ ":" domain-spec ] [ dual-cidr-length ]
2592 ptr = "ptr" [ ":" domain-spec ]
2593 ip4 = "ip4" ":" ip4-network [ ip4-cidr-length ]
2594 ip6 = "ip6" ":" ip6-network [ ip6-cidr-length ]
2595 exists = "exists" ":" domain-spec
2596
2597 modifier = redirect / explanation / unknown-modifier ../spf/parse.go:146
2598 redirect = "redirect" "=" domain-spec
2599 explanation = "exp" "=" domain-spec
2600 unknown-modifier = name "=" macro-string ../spf/parse.go:149
2601 ; where name is not any known modifier
2602
2603 ip4-cidr-length = "/" ("0" / %x31-39 0*1DIGIT) ; value range 0-32
2604 ip6-cidr-length = "/" ("0" / %x31-39 0*2DIGIT) ; value range 0-128
2605 dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ]
2606
2607 ip4-network = qnum "." qnum "." qnum "." qnum ../spf/parse.go:437
2608 qnum = DIGIT ; 0-9
2609 / %x31-39 DIGIT ; 10-99
2610 / "1" 2DIGIT ; 100-199
2611 / "2" %x30-34 DIGIT ; 200-249
2612 / "25" %x30-35 ; 250-255
2613 ; conventional dotted-quad notation, e.g., 192.0.2.0
2614 ip6-network = <as per Section 2.2 of [RFC4291]> ../spf/parse.go:456
2615 ; e.g., 2001:db8::cd30
2616
2617 domain-spec = macro-string domain-end
2618 domain-end = ( "." toplabel [ "." ] ) / macro-expand
2619
2620 toplabel = ( *alphanum ALPHA *alphanum ) /
2621 ( 1*alphanum "-" *( alphanum / "-" ) alphanum )
2622 ; LDH rule plus additional TLD restrictions
2623 ; (see Section 2 of [RFC3696] for background)
2624 alphanum = ALPHA / DIGIT
2625
2626 explain-string = *( macro-string / SP )
2627
2628 macro-string = *( macro-expand / macro-literal )
2629 macro-expand = ( "%{" macro-letter transformers *delimiter "}" )
2630 / "%%" / "%_" / "%-"
2631
2632
2633
2634Kitterman Standards Track [Page 47]
2635
2636RFC 7208 Sender Policy Framework (SPF) April 2014
2637
2638
2639 macro-literal = %x21-24 / %x26-7E
2640 ; visible characters except "%"
2641 macro-letter = "s" / "l" / "o" / "d" / "i" / "p" / "h" /
2642 "c" / "r" / "t" / "v"
2643 transformers = *DIGIT [ "r" ]
2644 delimiter = "." / "-" / "+" / "," / "/" / "_" / "="
2645
2646 name = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." )
2647
2648 header-field = "Received-SPF:" [CFWS] result FWS [comment FWS]
2649 [ key-value-list ] CRLF
2650
2651 result = "pass" / "fail" / "softfail" / "neutral" /
2652 "none" / "temperror" / "permerror"
2653
2654 key-value-list = key-value-pair *( ";" [CFWS] key-value-pair )
2655 [";"]
2656
2657 key-value-pair = key [CFWS] "=" ( dot-atom / quoted-string )
2658
2659 key = "client-ip" / "envelope-from" / "helo" /
2660 "problem" / "receiver" / "identity" /
2661 "mechanism" / name
2662
2663 identity = "mailfrom" ; for the "MAIL FROM" identity
2664 / "helo" ; for the "HELO" identity
2665 / name ; other identities
2666
2667 sender = Mailbox
2668 ip = ip4-network / ip6-network
2669 ALPHA = <A-Z / a-z as per [RFC5234]>
2670 DIGIT = <0-9 as per [RFC5234]>
2671 SP = <space character as per [RFC5234]>
2672 dot-atom = <unquoted word as per [RFC5322]>
2673 quoted-string = <quoted string as per [RFC5322]>
2674 comment = <comment string as per [RFC5322]>
2675 CFWS = <comment or folding white space as per [RFC5322]>
2676 FWS = <folding white space as per [RFC5322]>
2677 CRLF = <standard end-of-line token as per [RFC5322]>
2678
267913. Contributors and Acknowledgements
2680
2681 This document is largely based on the work of Meng Weng Wong, Mark
2682 Lentczner, and Wayne Schlitt. Although, as this section
2683 acknowledges, many people have contributed to this document, a very
2684 large portion of the writing and editing is due to Meng, Mark, and
2685 Wayne.
2686
2687
2688
2689
2690Kitterman Standards Track [Page 48]
2691
2692RFC 7208 Sender Policy Framework (SPF) April 2014
2693
2694
2695 This design owes a debt of parentage to [RMX] by Hadmut Danisch and
2696 to [DMP] by Gordon Fecyk. The idea of using a DNS record to check
2697 the legitimacy of an email address traces its ancestry further back
2698 through messages on the namedroppers mailing list by Paul Vixie
2699 [Vixie] (based on suggestion by Jim Miller) and by David Green
2700 [Green].
2701
2702 Philip Gladstone contributed the concept of macros to the
2703 specification, multiplying the expressiveness of the language and
2704 making per-user and per-IP lookups possible.
2705
2706 The authors of both this document and [RFC4408] would also like to
2707 thank the literally hundreds of individuals who have participated in
2708 the development of this design. They are far too numerous to name,
2709 but they include the following:
2710
2711 The participants in the SPFbis working group. The folks on the
2712 spf-discuss mailing list. The folks on the SPAM-L mailing list.
2713 The folks on the IRTF ASRG mailing list. The folks on the IETF
2714 MARID mailing list. The folks on #perl.
2715
271614. IANA Considerations
2717
271814.1. The SPF DNS Record Type
2719
2720 Per [RFC4408], the IANA assigned the Resource Record Type and Qtype
2721 from the "Domain Name System (DNS) Parameters" registry for the SPF
2722 RR type with code 99. The format of this type is identical to the
2723 TXT RR [RFC1035]. The character content of the record is encoded as
2724 [US-ASCII].
2725
2726 Studies have shown that RRTYPE 99 has not seen any substantial use,
2727 and in fact its existence and mechanism defined in [RFC4408] have led
2728 to some interoperability issues. Accordingly, its use is no longer
2729 appropriate for SPF version 1; implementations are not to use it.
2730
2731 IANA has updated the "Resource Record (RR) TYPEs" registry to
2732 indicate that this document is the reference document for that
2733 RRTYPE.
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746Kitterman Standards Track [Page 49]
2747
2748RFC 7208 Sender Policy Framework (SPF) April 2014
2749
2750
275114.2. The Received-SPF Mail Header Field
2752
2753 Per [RFC3864], the "Received-SPF:" header field is added to the IANA
2754 "Permanent Message Header Field Names" registry. The following is
2755 the registration template:
2756
2757 Header field name: Received-SPF Applicable protocol: mail
2758 ([RFC5322]) Status: standard Author/Change controller: IETF
2759 Specification document(s): RFC 7208
2760
276114.3. SPF Modifier Registry
2762
2763 IANA has changed the reference for the "exp" and "redirect" modifiers
2764 in the "Modifier Names" registry, under Sender Policy Framework
2765 Parameters, from [RFC4408] to this document. Their status is
2766 unchanged.
2767
276815. References
2769
277015.1. Normative References
2771
2772 [RFC1035] Mockapetris, P., "Domain names - implementation and
2773 specification", STD 13, RFC 1035, November 1987.
2774
2775 [RFC1123] Braden, R., "Requirements for Internet Hosts - Application
2776 and Support", STD 3, RFC 1123, October 1989.
2777
2778 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
2779 Requirement Levels", BCP 14, RFC 2119, March 1997.
2780
2781 [RFC3463] Vaudreuil, G., "Enhanced Mail System Status Codes",
2782 RFC 3463, January 2003.
2783
2784 [RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration
2785 Procedures for Message Header Fields", BCP 90, RFC 3864,
2786 September 2004.
2787
2788 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
2789 Resource Identifier (URI): Generic Syntax", STD 66,
2790 RFC 3986, January 2005.
2791
2792 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing
2793 Architecture", RFC 4291, February 2006.
2794
2795 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax
2796 Specifications: ABNF", STD 68, RFC 5234, January 2008.
2797
2798
2799
2800
2801
2802Kitterman Standards Track [Page 50]
2803
2804RFC 7208 Sender Policy Framework (SPF) April 2014
2805
2806
2807 [RFC5321] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321,
2808 October 2008.
2809
2810 [RFC5322] Resnick, P., Ed., "Internet Message Format", RFC 5322,
2811 October 2008.
2812
2813 [RFC5598] Crocker, D., "Internet Mail Architecture", RFC 5598,
2814 July 2009.
2815
2816 [RFC5890] Klensin, J., "Internationalized Domain Names for
2817 Applications (IDNA): Definitions and Document Framework",
2818 RFC 5890, August 2010.
2819
2820 [RFC7001] Kucherawy, M., "Message Header Field for Indicating
2821 Message Authentication Status", RFC 7001, September 2013.
2822
2823 [US-ASCII]
2824 American National Standards Institute (formerly United
2825 States of America Standards Institute), "USA Code for
2826 Information Interchange, X3.4", 1968.
2827
2828 ANSI X3.4-1968 has been replaced by newer versions with
2829 slight modifications, but the 1968 version remains
2830 definitive for the Internet.
2831
283215.2. Informative References
2833
2834 [BATV] Levine, J., Crocker, D., Silberman, S., and T. Finch,
2835 "Bounce Address Tag Validation (BATV)", Work in Progress,
2836 May 2008.
2837
2838 [DMP] Fecyk, G., "Designated Mailers Protocol", Work in
2839 Progress, May 2004.
2840
2841 [Green] Green, D., "Domain-Authorized SMTP Mail", June 2002,
2842 <http://www.mhonarc.org/archive/html/ietf-asrg/2003-03/
2843 msg01525.html>.
2844
2845 [RFC1034] Mockapetris, P., "Domain names - concepts and facilities",
2846 STD 13, RFC 1034, November 1987.
2847
2848 [RFC1983] Malkin, G., "Internet Users' Glossary", RFC 1983,
2849 August 1996.
2850
2851 [RFC2308] Andrews, M., "Negative Caching of DNS Queries (DNS
2852 NCACHE)", RFC 2308, March 1998.
2853
2854
2855
2856
2857
2858Kitterman Standards Track [Page 51]
2859
2860RFC 7208 Sender Policy Framework (SPF) April 2014
2861
2862
2863 [RFC2671] Vixie, P., "Extension Mechanisms for DNS (EDNS0)",
2864 RFC 2671, August 1999.
2865
2866 [RFC2782] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for
2867 specifying the location of services (DNS SRV)", RFC 2782,
2868 February 2000.
2869
2870 [RFC3464] Moore, K. and G. Vaudreuil, "An Extensible Message Format
2871 for Delivery Status Notifications", RFC 3464,
2872 January 2003.
2873
2874 [RFC3696] Klensin, J., "Application Techniques for Checking and
2875 Transformation of Names", RFC 3696, February 2004.
2876
2877 [RFC3833] Atkins, D. and R. Austein, "Threat Analysis of the Domain
2878 Name System (DNS)", RFC 3833, August 2004.
2879
2880 [RFC3834] Moore, K., "Recommendations for Automatic Responses to
2881 Electronic Mail", RFC 3834, August 2004.
2882
2883 [RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., and S.
2884 Rose, "DNS Security Introduction and Requirements",
2885 RFC 4033, March 2005.
2886
2887 [RFC4408] Wong, M. and W. Schlitt, "Sender Policy Framework (SPF)
2888 for Authorizing Use of Domains in E-Mail, Version 1",
2889 RFC 4408, April 2006.
2890
2891 [RFC4632] Fuller, V. and T. Li, "Classless Inter-domain Routing
2892 (CIDR): The Internet Address Assignment and Aggregation
2893 Plan", BCP 122, RFC 4632, August 2006.
2894
2895 [RFC4880] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R.
2896 Thayer, "OpenPGP Message Format", RFC 4880, November 2007.
2897
2898 [RFC4954] Siemborski, R. and A. Melnikov, "SMTP Service Extension
2899 for Authentication", RFC 4954, July 2007.
2900
2901 [RFC5507] IAB, Faltstrom, P., Austein, R., and P. Koch, "Design
2902 Choices When Expanding the DNS", RFC 5507, April 2009.
2903
2904 [RFC5751] Ramsdell, B. and S. Turner, "Secure/Multipurpose Internet
2905 Mail Extensions (S/MIME) Version 3.2 Message
2906 Specification", RFC 5751, January 2010.
2907
2908 [RFC5782] Levine, J., "DNS Blacklists and Whitelists", RFC 5782,
2909 February 2010.
2910
2911
2912
2913
2914Kitterman Standards Track [Page 52]
2915
2916RFC 7208 Sender Policy Framework (SPF) April 2014
2917
2918
2919 [RFC6409] Gellens, R. and J. Klensin, "Message Submission for Mail",
2920 STD 72, RFC 6409, November 2011.
2921
2922 [RFC6647] Kucherawy, M. and D. Crocker, "Email Greylisting: An
2923 Applicability Statement for SMTP", RFC 6647, June 2012.
2924
2925 [RFC6648] Saint-Andre, P., Crocker, D., and M. Nottingham,
2926 "Deprecating the "X-" Prefix and Similar Constructs in
2927 Application Protocols", BCP 178, RFC 6648, June 2012.
2928
2929 [RFC6652] Kitterman, S., "Sender Policy Framework (SPF)
2930 Authentication Failure Reporting Using the Abuse Reporting
2931 Format", RFC 6652, June 2012.
2932
2933 [RFC6686] Kucherawy, M., "Resolution of the Sender Policy Framework
2934 (SPF) and Sender ID Experiments", RFC 6686, July 2012.
2935
2936 [RFC6891] Damas, J., Graff, M., and P. Vixie, "Extension Mechanisms
2937 for DNS (EDNS(0))", STD 75, RFC 6891, April 2013.
2938
2939 [RMX] Danisch, H., "The RMX DNS RR and method for lightweight
2940 SMTP sender authorization", Work in Progress, May 2004.
2941
2942 [Vixie] Vixie, P., "Repudiating MAIL FROM", 2002,
2943 <http://marc.info/?l=namedroppers&m=102298170127004&w=4>.
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970Kitterman Standards Track [Page 53]
2971
2972RFC 7208 Sender Policy Framework (SPF) April 2014
2973
2974
2975Appendix A. Extended Examples ../spf/spf_test.go:202
2976
2977 These examples are based on the following DNS setup:
2978
2979 ; A domain with two mail servers, two hosts, and two servers
2980 ; at the domain name
2981 $ORIGIN example.com.
2982 @ MX 10 mail-a
2983 MX 20 mail-b
2984 A 192.0.2.10
2985 A 192.0.2.11
2986 amy A 192.0.2.65
2987 bob A 192.0.2.66
2988 mail-a A 192.0.2.129
2989 mail-b A 192.0.2.130
2990 www CNAME example.com.
2991
2992 ; A related domain
2993 $ORIGIN example.org.
2994 @ MX 10 mail-c
2995 mail-c A 192.0.2.140
2996
2997 ; The reverse IP for those addresses
2998 $ORIGIN 2.0.192.in-addr.arpa.
2999 10 PTR example.com.
3000 11 PTR example.com.
3001 65 PTR amy.example.com.
3002 66 PTR bob.example.com.
3003 129 PTR mail-a.example.com.
3004 130 PTR mail-b.example.com.
3005 140 PTR mail-c.example.org.
3006
3007 ; A rogue reverse IP domain that claims to be
3008 ; something it's not
3009 $ORIGIN 0.0.10.in-addr.arpa.
3010 4 PTR bob.example.com.
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026Kitterman Standards Track [Page 54]
3027
3028RFC 7208 Sender Policy Framework (SPF) April 2014
3029
3030
3031A.1. Simple Examples ../spf/spf_test.go:292
3032
3033 These examples show various possible published records for
3034 example.com and which values of <ip> would cause check_host() to
3035 return "pass". Note that <domain> is "example.com".
3036
3037 v=spf1 +all
3038
3039 -- any <ip> passes
3040
3041 v=spf1 a -all
3042
3043 -- hosts 192.0.2.10 and 192.0.2.11 pass
3044
3045 v=spf1 a:example.org -all
3046
3047 -- no sending hosts pass since example.org has no A records
3048
3049 v=spf1 mx -all
3050
3051 -- sending hosts 192.0.2.129 and 192.0.2.130 pass
3052
3053 v=spf1 mx:example.org -all
3054
3055 -- sending host 192.0.2.140 passes
3056
3057 v=spf1 mx mx:example.org -all
3058
3059 -- sending hosts 192.0.2.129, 192.0.2.130, and 192.0.2.140 pass
3060
3061 v=spf1 mx/30 mx:example.org/30 -all
3062
3063 -- any sending host in 192.0.2.128/30 or 192.0.2.140/30 passes
3064
3065 v=spf1 ptr -all
3066
3067 -- sending host 192.0.2.65 passes (reverse DNS is valid and is
3068 in example.com)
3069
3070 -- sending host 192.0.2.140 fails (reverse DNS is valid, but not
3071 in example.com)
3072
3073 -- sending host 10.0.0.4 fails (reverse IP is not valid)
3074
3075
3076
3077
3078
3079
3080
3081
3082Kitterman Standards Track [Page 55]
3083
3084RFC 7208 Sender Policy Framework (SPF) April 2014
3085
3086
3087 v=spf1 ip4:192.0.2.128/28 -all
3088
3089 -- sending host 192.0.2.65 fails
3090
3091 -- sending host 192.0.2.129 passes
3092
3093A.2. Multiple Domain Example ../spf/spf_test.go:331
3094
3095 These examples show the effect of related records:
3096
3097 example.org: "v=spf1 include:example.com include:example.net -all"
3098
3099 This record would be used if mail from example.org actually came
3100 through servers at example.com and example.net. Example.org's
3101 designated servers are the union of example.com's and example.net's
3102 designated servers.
3103
3104 la.example.org: "v=spf1 redirect=example.org"
3105
3106 ny.example.org: "v=spf1 redirect=example.org"
3107
3108 sf.example.org: "v=spf1 redirect=example.org"
3109
3110 These records allow a set of domains that all use the same mail
3111 system to make use of that mail system's record. In this way, only
3112 the mail system's record needs to be updated when the mail setup
3113 changes. These domains' records never have to change.
3114
3115A.3. DNS Blacklist (DNSBL) Style Example ../spf/spf_test.go:215 ../spf/spf_test.go:235 ../spf/spf_test.go:306
3116
3117 Imagine that, in addition to the domain records listed above, there
3118 are these (see [RFC5782]):
3119
3120 $ORIGIN _spf.example.com.
3121 mary.mobile-users A 127.0.0.2
3122 fred.mobile-users A 127.0.0.2
3123 15.15.168.192.joel.remote-users A 127.0.0.2
3124 16.15.168.192.joel.remote-users A 127.0.0.2
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138Kitterman Standards Track [Page 56]
3139
3140RFC 7208 Sender Policy Framework (SPF) April 2014
3141
3142
3143 The following records describe users at example.com who mail from
3144 arbitrary servers, or who mail from personal servers.
3145
3146 example.com:
3147
3148 v=spf1 mx
3149 include:mobile-users._spf.%{d}
3150 include:remote-users._spf.%{d}
3151 -all
3152
3153 mobile-users._spf.example.com:
3154
3155 v=spf1 exists:%{l1r+}.%{d}
3156
3157 remote-users._spf.example.com:
3158
3159 v=spf1 exists:%{ir}.%{l1r+}.%{d}
3160
3161A.4. Multiple Requirements Example
3162
3163 Say that your sender policy requires both that the IP address is
3164 within a certain range and that the reverse DNS for the IP matches.
3165 This can be done several ways, including the following:
3166
3167 example.com. SPF ( "v=spf1 "
3168 "-include:ip4._spf.%{d} "
3169 "-include:ptr._spf.%{d} "
3170 "+all" )
3171 ip4._spf.example.com. SPF "v=spf1 -ip4:192.0.2.0/24 +all" ../spf/spf_test.go:219 ../spf/spf_test.go:318
3172 ptr._spf.example.com. SPF "v=spf1 -ptr +all" 7208-eid6216:1 ../spf/spf_test.go:221
3173
3174 This example shows how the "-include" mechanism can be useful, how an
3175 SPF record that ends in "+all" can be very restrictive, and the use
3176 of De Morgan's Law.
3177
3178Appendix B. Changes in Implementation Requirements from RFC 4408
3179
3180 The modifications to implementation requirements from [RFC4408] are
3181 all either (a) corrections to errors in [RFC4408] or (b) additional
3182 documentation based on consensus of operational experience acquired
3183 since the publication of [RFC4408].
3184
3185 o Use of DNS RR type SPF (99) has been removed from the protocol;
3186 see [RFC6686] for background.
3187
3188 o A new DNS-related processing limit based on "void lookups" has
3189 been added (Section 4.6.4).
3190
3191
3192
3193
3194Kitterman Standards Track [Page 57]
3195
3196RFC 7208 Sender Policy Framework (SPF) April 2014
3197
3198
3199 o Use of the ptr mechanism and the %p macro has been strongly
3200 discouraged (Sections 5.5 and 7.2). The ptr mechanism and the %p
3201 macro remain part of the protocol because they were found to be in
3202 use, but records ought to be updated to avoid them.
3203
3204 o Use of the "Authentication-Results" header field [RFC7001] as a
3205 possible alternative to use of the "Received-SPF" header field is
3206 discussed (Section 9.2).
3207
3208 o There have been a number of minor corrections to the ABNF to make
3209 it more clear and correct (Section 12). SPF library implementers
3210 should give the revised ABNF a careful review to determine if
3211 implementation changes are needed.
3212
3213 o Use of X- fields in the ABNF has been removed; see [RFC6648] for
3214 background.
3215
3216 o Ambiguity about how to deal with invalid <domain-spec> after macro
3217 expansion has been documented. Depending on one specific behavior
3218 has to be avoided (Section 4.8).
3219
3220 o General operational information has been updated and expanded
3221 based on eight years of post-[RFC4408] operations experience. See
3222 Section 10 and Appendices D through G below.
3223
3224 o Security considerations have been reviewed and updated
3225 (Section 11).
3226
3227Appendix C. Further Testing Advice
3228
3229 Another approach that can be helpful is to publish records that
3230 include a "tracking exists:" mechanism. By looking at the name
3231 server logs, a rough list can then be generated. For example:
3232
3233 v=spf1 exists:_h.%{h}._l.%{l}._o.%{o}._i.%{i}._spf.%{d} ?all
3234
3235 This associated macro expansion would cause the sending HELO domain,
3236 local-part of the sending email address, domain part of the sending
3237 email address, and the IP address from which the connection was
3238 received to be embedded in an SPF query and logged in the sender's
3239 DNS logs.
3240
3241 This approach, which has been used since very early in the SPF
3242 project, allows senders to unilaterally collect data to evaluate the
3243 correctness of their SPF records. Unlike newer feedback mechanisms,
3244 it does not require any special cooperation from SPF verifiers. A
3245 similar example, one of the earliest SPF records published, can still
3246 be found as of this writing at altavista.net.
3247
3248
3249
3250Kitterman Standards Track [Page 58]
3251
3252RFC 7208 Sender Policy Framework (SPF) April 2014
3253
3254
3255Appendix D. SPF/Mediator Interactions
3256
3257 There are three places that techniques can be used to ameliorate
3258 unintended SPF failures with mediators.
3259
3260D.1. Originating ADMDs
3261
3262 The beginning, when email is first sent:
3263
3264 o "Neutral" results could be given for IP addresses that might be
3265 forwarders, instead of "fail" results based on a list of known
3266 reliable forwarders. For example:
3267
3268 "v=spf1 mx ?exists:%{ir}.whitelist.example.org -all"
3269
3270 This would cause a lookup on a DNS White List (DNSWL) and cause a
3271 result of "fail" only for email not coming from either the
3272 domain's mx host(s) (SPF pass) or whitelisted sources (SPF
3273 neutral). This, in effect, outsources an element of sender policy
3274 to the maintainer of the whitelist.
3275
3276 o The "MAIL FROM" identity could have additional information in the
3277 local-part that cryptographically identifies the mail as coming
3278 from an authorized source. In this case, an SPF record such as
3279 the following could be used:
3280
3281 "v=spf1 mx exists:%{l}._spf_verify.%{d} -all"
3282
3283 Then, a specialized DNS server can be set up to serve the
3284 _spf_verify subdomain that validates the local-part. Although
3285 this requires an extra DNS lookup, this happens only when the
3286 email would otherwise be rejected as not coming from a known good
3287 source.
3288
3289 Note that due to the 63-character limit for domain labels, this
3290 approach only works reliably if the local-part signature scheme is
3291 guaranteed to either only produce local-parts with a maximum of
3292 63 characters or gracefully handle truncated local-parts. The
3293 method used to secure the local-part is a local implementation
3294 issue; it need not be standard. An example of one way to do it
3295 can be found in [BATV].
3296
3297 o Similarly, a specialized DNS server could be set up that will
3298 rate-limit the email coming from unexpected IP addresses.
3299
3300 "v=spf1 mx exists:%{ir}._spf_rate.%{d} -all"
3301
3302
3303
3304
3305
3306Kitterman Standards Track [Page 59]
3307
3308RFC 7208 Sender Policy Framework (SPF) April 2014
3309
3310
3311 o SPF allows the creation of per-user policies for special cases.
3312 For example, the following SPF record and appropriate wildcard DNS
3313 records can be used:
3314
3315 "v=spf1 mx redirect=%{l1r+}._at_.%{o}._spf.%{d}"
3316
3317D.2. Mediators
3318
3319 The middle, when email is forwarded:
3320
3321 o Mediators can solve the problem by rewriting the "MAIL FROM" to be
3322 in their own domain. This means mail rejected from the external
3323 mailbox will have to be forwarded back to the original sender by
3324 the forwarding service. Various schemes to do this exist, though
3325 they vary widely in complexity and resource requirements on the
3326 part of the mediator.
3327
3328 o Several popular MTAs can be forced from "alias" semantics to
3329 "mailing list" semantics by configuring an additional alias with
3330 "owner-" prepended to the original alias name (e.g., an alias of
3331 "friends: george@example.com, fred@example.org" would need another
3332 alias of the form "owner-friends: localowner").
3333
3334 o Mediators could reject mail that would "fail" SPF if forwarded
3335 using an SMTP reply code of 551, User not local (see Section 3.4
3336 of [RFC5321]) to communicate the correct target address to resend
3337 the mail to.
3338
3339D.3. Receiving ADMDs
3340
3341 The end, when email is received:
3342
3343 o If the owner of the external mailbox wishes to trust the mediator,
3344 he can direct the external mailbox's MTA to skip SPF tests when
3345 the client host belongs to the mediator.
3346
3347 o Tests against other identities, such as the "HELO" identity, can
3348 be used to override a failed test against the "MAIL FROM"
3349 identity.
3350
3351 o For larger domains, it might not be possible to have a complete or
3352 accurate list of forwarding services used by the owners of the
3353 domain's mailboxes. In such cases, whitelists of generally
3354 recognized forwarding services could be employed.
3355
3356
3357
3358
3359
3360
3361
3362Kitterman Standards Track [Page 60]
3363
3364RFC 7208 Sender Policy Framework (SPF) April 2014
3365
3366
3367Appendix E. Mail Services
3368
3369 MSPs (Mail Service Providers -- Section 2.3 of [RFC5598]) that offer
3370 mail services to third-party domains, such as the sending of bulk
3371 mail, might want to adjust their configurations in light of the
3372 authorization check described in this document. If the domain part
3373 of the "MAIL FROM" identity used for such email uses one of the MSP's
3374 domains, then the provider needs only to ensure that its sending host
3375 is authorized by its own SPF record, if any.
3376
3377 If the "MAIL FROM" identity does not use the MSP's domain, then extra
3378 care has to be taken. The SPF record format has several options for
3379 the third-party domain to authorize the service provider's MTAs to
3380 send mail on its behalf. For MSPs, such as ISPs, that have a wide
3381 variety of customers using the same MTA, steps are required to
3382 mitigate the risk of cross-customer forgery (see Section 11.4).
3383
3384Appendix F. MTA Relays
3385
3386 Relays are described in [RFC5598], Section 2.2.2. The authorization
3387 check generally precludes the use of arbitrary MTA relays between the
3388 sender and receiver of an email message.
3389
3390 Within an organization, MTA relays can be effectively deployed.
3391 However, for the purposes of this document, such relays are
3392 effectively transparent. The SPF authorization check is a check
3393 between border MTAs of different ADMDs.
3394
3395 For mail senders, this means published SPF records have to authorize
3396 any MTAs that actually send across the Internet. Usually, these are
3397 just the border MTAs as internal MTAs simply forward mail to these
3398 MTAs for relaying.
3399
3400 The receiving ADMD will generally want to perform the authorization
3401 check at the boundary MTAs, including all secondary MXs. Internal
3402 MTAs (including MTAs that might serve as both boundary MTAs and
3403 internal relays from secondary MXs when they are processing the
3404 relayed mail stream) then do not perform the authorization test. To
3405 perform the authorization test other than at the boundary, the host
3406 that first transferred the message to the receiving ADMD has to be
3407 determined, which can be difficult to extract from the message header
3408 because (a) header fields can be forged or malformed, and (b) there's
3409 no standard way to encode that information such that it can be
3410 reliably extracted. Testing other than at the boundary is likely to
3411 produce unreliable results. This is described further in Appendix D
3412 of [RFC7001].
3413
3414
3415
3416
3417
3418Kitterman Standards Track [Page 61]
3419
3420RFC 7208 Sender Policy Framework (SPF) April 2014
3421
3422
3423Appendix G. Local Policy Considerations
3424
3425 SPF results can be used in combination with other methods to
3426 determine the final local disposition (either positive or negative)
3427 of a message. It can also be considered dispositive on its own.
3428
3429G.1. Policy for SPF Pass
3430
3431 SPF "pass" results can be used in combination with "whitelists" of
3432 known "good" domains to bypass some or all additional pre-delivery
3433 email checks. Exactly which checks and how to determine appropriate
3434 whitelist entries have to be based on local conditions and
3435 requirements.
3436
3437G.2. Policy for SPF Fail
3438
3439 SPF "fail" results can be used to reject messages during the SMTP
3440 transaction based on either "MAIL FROM" or "HELO" identity results.
3441 This reduces resource requirements for various content-filtering
3442 methods and conserves bandwidth since rejection can be done before
3443 the SMTP content is transferred. It also gives immediate feedback to
3444 the sender, who might then be able to resolve the issue. Due to some
3445 of the issues described in this section (Appendix G), SPF-based
3446 rejection does present some risk of rejecting legitimate email when
3447 rejecting email based on "MAIL FROM" results.
3448
3449 SPF "fail" results can alternately be used as one input into a larger
3450 set of evaluations that might, based on a combination of SPF "fail"
3451 results with other evaluation techniques, result in the email being
3452 marked negatively in some way (this might be via delivery to a
3453 special spam folder, modifying subject lines, or other locally
3454 determined means). Developing the details of such an approach has to
3455 be based on local conditions and requirements. Using SPF results in
3456 this way does not have the advantages of resource conservation and
3457 immediate feedback to the sender associated with SMTP rejection, but
3458 could produce fewer undesirable rejections in a well-designed system.
3459 Such an approach might result in email that was not authorized by the
3460 sending ADMD being unknowingly delivered to end users.
3461
3462 Either general approach can be used, as they both leave a clear
3463 disposition of emails; either they are delivered in some manner or
3464 the sender is notified of the failure. Other dispositions such as
3465 "dropping" or deleting email after acceptance are inappropriate
3466 because they leave uncertainty and reduce the overall reliability and
3467 utility of email across the Internet.
3468
3469
3470
3471
3472
3473
3474Kitterman Standards Track [Page 62]
3475
3476RFC 7208 Sender Policy Framework (SPF) April 2014
3477
3478
3479G.3. Policy for SPF Permerror
3480
3481 The "permerror" result (see Section 2.6.7) indicates that the SPF
3482 processing module at the receiver determined that the retrieved SPF
3483 policy record could not be interpreted. This gives no true
3484 indication about the authorized use of the data found in the
3485 envelope.
3486
3487 As with all results, implementers have a choice to make regarding
3488 what to do with a message that yields this result. SMTP allows only
3489 a few basic options.
3490
3491 Rejection of the message is an option, in that it is the one thing a
3492 receiver can do to draw attention to the difficulty encountered while
3493 protecting itself from messages that do not have a definite SPF
3494 result of some kind. However, if the SPF implementation is defective
3495 and returns spurious "permerror" results, only the sender is actively
3496 notified of the defect (in the form of rejected mail), and not the
3497 receiver making use of SPF.
3498
3499 The less intrusive handling choice is to deliver the message, perhaps
3500 with some kind of annotation of the difficulty encountered and/or
3501 logging of a similar nature. However, this will not be desirable to
3502 SPF verifier operators that wish to implement SPF checking as
3503 strictly as possible, nor is this sort of passive reporting of
3504 problems typically effective.
3505
3506 There is of course the option of placing this choice in the hands of
3507 the SPF verifier operator rather than the implementer since this kind
3508 of choice is often a matter of local policy rather than a condition
3509 with a universal solution, but this adds one more piece of complexity
3510 to an already non-trivial environment.
3511
3512 Both implementers and SPF verifier operators need to be cautious of
3513 all choices and outcomes when handling SPF results.
3514
3515G.4. Policy for SPF Temperror
3516
3517 The "temperror" result (see Section 2.6.6) indicates that the SPF
3518 processing module at the receiver could not retrieve an SPF policy
3519 record due to a (probably) transient condition. This gives no true
3520 indication about the authorized use of the data found in the
3521 envelope.
3522
3523 As with all results, implementers have a choice to make regarding
3524 what to do with a message that yields this result. SMTP allows only
3525 a few basic options.
3526
3527
3528
3529
3530Kitterman Standards Track [Page 63]
3531
3532RFC 7208 Sender Policy Framework (SPF) April 2014
3533
3534
3535 Deferring the message is an option, in that it is the one thing a
3536 receiver can do to draw attention to the difficulty encountered while
3537 protecting itself from messages that do not have a definite SPF
3538 result of some kind. However, if the SPF implementation is defective
3539 and returns spurious "temperror" results, only the sender is actively
3540 notified of the defect (in the form of mail rejected after it times
3541 out of the sending queue), and not the receiver making use of SPF.
3542
3543 Because of long queue lifetimes, it is possible that mail will be
3544 repeatedly deferred for several days, and so any awareness that the
3545 sender may have regarding a problem could be quite delayed. If
3546 "temperrors" persist for multiple delivery attempts, it might be
3547 preferable to treat the error as permanent and reduce the amount of
3548 time the message is in transit.
3549
3550 The less intrusive handling choice is to deliver the message, perhaps
3551 with some kind of annotation of the difficulty encountered and/or
3552 logging of a similar nature. However, this will not be desirable to
3553 SPF verifier operators that wish to implement SPF checking as
3554 strictly as possible, nor is this sort of passive reporting of
3555 problems typically effective.
3556
3557 There is of course the option of placing this choice in the hands of
3558 the SPF verifier operator rather than the implementer since this kind
3559 of choice is often a matter of local policy rather than a condition
3560 with a universal solution, but this adds one more piece of complexity
3561 to an already non-trivial environment.
3562
3563 Both implementers and SPF verifier operators need to be cautious of
3564 all choices and outcomes when handling SPF results.
3565
3566Author's Address
3567
3568 Scott Kitterman
3569 Kitterman Technical Services
3570 3611 Scheel Dr.
3571 Ellicott City, MD 21042
3572 United States of America
3573
3574 EMail: scott@kitterman.com
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586Kitterman Standards Track [Page 64]
3587
3588