idnits 2.17.1 draft-ietf-spfbis-4408bis-04.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- == There are 1 instance of lines with non-RFC2606-compliant FQDNs in the document. == There are 7 instances of lines with non-RFC6890-compliant IPv4 addresses in the document. If these are example addresses, they should be changed. == There are 1 instance of lines with private range IPv4 addresses in the document. If these are generic example addresses, they should be changed to use any of the ranges defined in RFC 6890 (or successor): 192.0.2.x, 198.51.100.x or 203.0.113.x. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 1336 has weird spacing: '...pe-from the e...' == The document seems to contain a disclaimer for pre-RFC5378 work, but was first submitted on or after 10 November 2008. The disclaimer is usually necessary only for documents that revise or obsolete older RFCs, and that take significant amounts of text from those RFCs. If you can contact all authors of the source material and they are willing to grant the BCP78 rights to the IETF Trust, you can and should remove the disclaimer. Otherwise, the disclaimer is needed and you can ignore this comment. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (August 16, 2012) is 4270 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'CFWS' is mentioned on line 2372, but not defined ** Obsolete normative reference: RFC 5451 (Obsoleted by RFC 7001) ** Downref: Normative reference to an Informational RFC: RFC 5598 -- Possible downref: Non-RFC (?) normative reference: ref. 'US-ASCII' -- Obsolete informational reference (is this intentional?): RFC 4408 (Obsoleted by RFC 7208) -- Obsolete informational reference (is this intentional?): RFC 5751 (Obsoleted by RFC 8551) Summary: 2 errors (**), 0 flaws (~~), 7 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group S. Kitterman 3 Internet-Draft Kitterman Technical Services 4 Obsoletes: 4408 (if approved) August 16, 2012 5 Intended status: Standards Track 6 Expires: February 17, 2013 8 Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, 9 Version 1 10 draft-ietf-spfbis-4408bis-04.txt 12 Abstract 14 Email on the Internet can be forged in a number of ways. In 15 particular, existing protocols place no restriction on what a sending 16 host can use as the author's address of a message or the domain given 17 on the SMTP HELO/EHLO commands. This document describes version 1 of 18 the Sender Policy Framework (SPF) protocol, whereby a domain can 19 explicitly authorize the hosts that are allowed to use its domain 20 name, and a receiving host can check such authorization. 22 This document obsoletes RFC4408. 24 Status of this Memo 26 This Internet-Draft is submitted in full conformance with the 27 provisions of BCP 78 and BCP 79. 29 Internet-Drafts are working documents of the Internet Engineering 30 Task Force (IETF). Note that other groups may also distribute 31 working documents as Internet-Drafts. The list of current Internet- 32 Drafts is at http://datatracker.ietf.org/drafts/current/. 34 Internet-Drafts are draft documents valid for a maximum of six months 35 and may be updated, replaced, or obsoleted by other documents at any 36 time. It is inappropriate to use Internet-Drafts as reference 37 material or to cite them other than as "work in progress." 39 This Internet-Draft will expire on February 17, 2013. 41 Copyright Notice 43 Copyright (c) 2012 IETF Trust and the persons identified as the 44 document authors. All rights reserved. 46 This document is subject to BCP 78 and the IETF Trust's Legal 47 Provisions Relating to IETF Documents 48 (http://trustee.ietf.org/license-info) in effect on the date of 49 publication of this document. Please review these documents 50 carefully, as they describe your rights and restrictions with respect 51 to this document. Code Components extracted from this document must 52 include Simplified BSD License text as described in Section 4.e of 53 the Trust Legal Provisions and are provided without warranty as 54 described in the Simplified BSD License. 56 This document may contain material from IETF Documents or IETF 57 Contributions published or made publicly available before November 58 10, 2008. The person(s) controlling the copyright in some of this 59 material may not have granted the IETF Trust the right to allow 60 modifications of such material outside the IETF Standards Process. 61 Without obtaining an adequate license from the person(s) controlling 62 the copyright in such materials, this document may not be modified 63 outside the IETF Standards Process, and derivative works of it may 64 not be created outside the IETF Standards Process, except to format 65 it for publication as an RFC or to translate it into languages other 66 than English. 68 Table of Contents 70 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 6 71 1.1. Protocol Status . . . . . . . . . . . . . . . . . . . . . 6 72 1.2. Experimental History . . . . . . . . . . . . . . . . . . . 7 73 1.3. Terminology . . . . . . . . . . . . . . . . . . . . . . . 7 74 1.3.1. Keywords . . . . . . . . . . . . . . . . . . . . . . . 7 75 1.3.2. Imported Definitions . . . . . . . . . . . . . . . . . 7 76 1.3.3. Mail From Definition . . . . . . . . . . . . . . . . . 7 77 1.3.4. HELO Definition . . . . . . . . . . . . . . . . . . . 8 78 1.3.5. Deprecated . . . . . . . . . . . . . . . . . . . . . . 8 79 2. Operation . . . . . . . . . . . . . . . . . . . . . . . . . . 9 80 2.1. The RFC5321.HELO/.EHLO Identity . . . . . . . . . . . . . 9 81 2.2. The RFC5321.MailFrom Identity . . . . . . . . . . . . . . 9 82 2.3. Publishing Authorization . . . . . . . . . . . . . . . . . 9 83 2.4. Checking Authorization . . . . . . . . . . . . . . . . . . 10 84 2.5. Interpreting the Result . . . . . . . . . . . . . . . . . 11 85 2.5.1. None . . . . . . . . . . . . . . . . . . . . . . . . . 12 86 2.5.2. Neutral . . . . . . . . . . . . . . . . . . . . . . . 12 87 2.5.3. Pass . . . . . . . . . . . . . . . . . . . . . . . . . 12 88 2.5.4. Fail . . . . . . . . . . . . . . . . . . . . . . . . . 12 89 2.5.5. Softfail . . . . . . . . . . . . . . . . . . . . . . . 13 90 2.5.6. TempError . . . . . . . . . . . . . . . . . . . . . . 13 91 2.5.7. PermError . . . . . . . . . . . . . . . . . . . . . . 13 92 3. SPF Records . . . . . . . . . . . . . . . . . . . . . . . . . 14 93 3.1. DNS Resource Records . . . . . . . . . . . . . . . . . . . 14 94 3.2. Multiple DNS Records . . . . . . . . . . . . . . . . . . . 15 95 3.3. Multiple Strings in a Single DNS record . . . . . . . . . 15 96 3.4. Record Size . . . . . . . . . . . . . . . . . . . . . . . 15 97 3.5. Wildcard Records . . . . . . . . . . . . . . . . . . . . . 15 98 4. The check_host() Function . . . . . . . . . . . . . . . . . . 17 99 4.1. Arguments . . . . . . . . . . . . . . . . . . . . . . . . 17 100 4.2. Results . . . . . . . . . . . . . . . . . . . . . . . . . 17 101 4.3. Initial Processing . . . . . . . . . . . . . . . . . . . . 17 102 4.4. Record Lookup . . . . . . . . . . . . . . . . . . . . . . 18 103 4.5. Selecting Records . . . . . . . . . . . . . . . . . . . . 18 104 4.6. Record Evaluation . . . . . . . . . . . . . . . . . . . . 19 105 4.6.1. Term Evaluation . . . . . . . . . . . . . . . . . . . 19 106 4.6.2. Mechanisms . . . . . . . . . . . . . . . . . . . . . . 19 107 4.6.3. Modifiers . . . . . . . . . . . . . . . . . . . . . . 20 108 4.6.4. DNS Lookup Limits . . . . . . . . . . . . . . . . . . 20 109 4.7. Default Result . . . . . . . . . . . . . . . . . . . . . . 21 110 4.8. Domain Specification . . . . . . . . . . . . . . . . . . . 21 111 5. Mechanism Definitions . . . . . . . . . . . . . . . . . . . . 22 112 5.1. "all" . . . . . . . . . . . . . . . . . . . . . . . . . . 23 113 5.2. "include" . . . . . . . . . . . . . . . . . . . . . . . . 23 114 5.3. "a" . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 115 5.4. "mx" . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 116 5.5. "ptr" (deprecated) . . . . . . . . . . . . . . . . . . . . 25 117 5.6. "ip4" and "ip6" . . . . . . . . . . . . . . . . . . . . . 27 118 5.7. "exists" . . . . . . . . . . . . . . . . . . . . . . . . . 27 119 6. Modifier Definitions . . . . . . . . . . . . . . . . . . . . . 29 120 6.1. redirect: Redirected Query . . . . . . . . . . . . . . . . 29 121 6.2. exp: Explanation . . . . . . . . . . . . . . . . . . . . . 30 122 7. Recording The Result . . . . . . . . . . . . . . . . . . . . . 32 123 7.1. The Received-SPF Header Field . . . . . . . . . . . . . . 32 124 7.2. SPF Results in the Authentication-Results Header Field . . 34 125 8. Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 126 8.1. Macro Definitions . . . . . . . . . . . . . . . . . . . . 36 127 8.2. Expansion Examples . . . . . . . . . . . . . . . . . . . . 39 128 9. Implications . . . . . . . . . . . . . . . . . . . . . . . . . 41 129 9.1. Sending Domains . . . . . . . . . . . . . . . . . . . . . 41 130 9.1.1. DNS Resource Considerations . . . . . . . . . . . . . 41 131 9.1.2. Administrator's Considerations . . . . . . . . . . . . 42 132 9.1.3. Bounces . . . . . . . . . . . . . . . . . . . . . . . 43 133 9.2. Mediators . . . . . . . . . . . . . . . . . . . . . . . . 43 134 9.2.1. Mailing Lists . . . . . . . . . . . . . . . . . . . . 43 135 9.2.2. Forwarding Services and Aliases . . . . . . . . . . . 43 136 9.2.3. Mail Services . . . . . . . . . . . . . . . . . . . . 45 137 9.2.4. MTA Relays . . . . . . . . . . . . . . . . . . . . . . 46 138 9.3. Receivers . . . . . . . . . . . . . . . . . . . . . . . . 46 139 9.3.1. Policy For SPF Pass . . . . . . . . . . . . . . . . . 46 140 9.3.2. Policy For SPF Fail . . . . . . . . . . . . . . . . . 47 141 9.3.3. Policy For SPF Permerror . . . . . . . . . . . . . . . 47 142 10. Security Considerations . . . . . . . . . . . . . . . . . . . 49 143 10.1. Processing Limits . . . . . . . . . . . . . . . . . . . . 49 144 10.2. SPF-Authorized Email May Contain Other False Identities . 49 145 10.3. Spoofed DNS and IP Data . . . . . . . . . . . . . . . . . 50 146 10.4. Cross-User Forgery . . . . . . . . . . . . . . . . . . . . 50 147 10.5. Untrusted Information Sources . . . . . . . . . . . . . . 50 148 10.6. Privacy Exposure . . . . . . . . . . . . . . . . . . . . . 51 149 11. Contributors and Acknowledgements . . . . . . . . . . . . . . 52 150 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 53 151 12.1. The SPF DNS Record Type . . . . . . . . . . . . . . . . . 53 152 12.2. The Received-SPF Mail Header Field . . . . . . . . . . . . 53 153 12.3. SPF Modifier Registration . . . . . . . . . . . . . . . . 53 154 13. References . . . . . . . . . . . . . . . . . . . . . . . . . . 54 155 13.1. Normative References . . . . . . . . . . . . . . . . . . . 54 156 13.2. Informative References . . . . . . . . . . . . . . . . . . 55 157 Appendix A. Collected ABNF . . . . . . . . . . . . . . . . . . . 57 158 Appendix B. Extended Examples . . . . . . . . . . . . . . . . . . 60 159 B.1. Simple Examples . . . . . . . . . . . . . . . . . . . . . 60 160 B.2. Multiple Domain Example . . . . . . . . . . . . . . . . . 61 161 B.3. DNSBL Style Example . . . . . . . . . . . . . . . . . . . 62 162 B.4. Multiple Requirements Example . . . . . . . . . . . . . . 62 163 Appendix C. Change History . . . . . . . . . . . . . . . . . . . 63 164 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 66 166 1. Introduction 168 The current email infrastructure has the property that any host 169 injecting mail into the system can use any DNS domain name it wants 170 in each of the various identifiers specified by [RFC5321] and 171 [RFC5322], plus the "reverse pointer" which is the purported hostname 172 of the SMTP client as far as the DNS is concerned [RFC1035]. 173 Although this feature is desirable in some circumstances, it is a 174 major obstacle to reducing Unsolicited Bulk email (UBE, aka spam). 175 Furthermore, many domain owning ADMDs (ADministrative Management 176 Domains, see [RFC5598]) are understandably concerned about the ease 177 with which other entities can make use of their domain names, often 178 with malicious intent. 180 This document defines a protocol by which ADMDs can authorize hosts 181 to use their domain names in the RFC5321.MailFrom or RFC5321.HELO/ 182 .EHLO identities. Compliant ADMDs publish Sender Policy Framework 183 (SPF) records in DNS specifying which hosts are permitted to use 184 their names, and compliant mail receivers use the published SPF 185 records to test the authorization of sending Mail Transfer Agents 186 (MTAs) using a given RFC5321.HELO/.EHLO or RFC5321.MailFrom identity 187 during a mail transaction. 189 An additional benefit to mail receivers is that after the use of an 190 identity is verified, local policy decisions about the mail can be 191 made based on the sender's domain, rather than the host's IP address. 192 This is advantageous because reputation of domain names is likely to 193 be more accurate than reputation of host IP addresses. Furthermore, 194 if a claimed identity fails verification, local policy can take 195 stronger action against such email, such as rejecting it. 197 1.1. Protocol Status 199 SPF has been in development since the summer of 2003 and has seen 200 deployment beyond the developers beginning in December 2003. The 201 design of SPF slowly evolved until the spring of 2004 and has since 202 stabilized. There have been quite a number of forms of SPF, some 203 written up as documents, some submitted as Internet Drafts, and many 204 discussed and debated in development forums. The protocol was 205 originally defined in [RFC4408], which this document replaces. 207 The goal of this work is to clearly document the protocol defined by 208 earlier draft specifications of SPF as used in existing 209 implementations. This conception of SPF is sometimes called "SPF 210 Classic". It is understood that particular implementations and 211 deployments will differ from, and build upon, this work. It is hoped 212 that we have nonetheless captured the common understanding of SPF 213 version 1. 215 1.2. Experimental History 217 This document updates and replaces RFC 4408 that was part of a group 218 of simultaneously published Experimental RFCs (RFC 4405, RFC 4406, 219 RFC 4407, and RFC 4408) in 2006. At that time the IESG requested the 220 community observe the success or failure of the two approaches 221 documented in these RFCs during the two years following publication, 222 in order that a community consensus could be reached in the future. 224 SPF is widely deployed by large and small email providers alike. 225 There are multiple, interoperable implementations. 227 For SPF (as documented in RFC 4408) a careful effort was made to 228 collect and document lessons learned and errata during the two year 229 period. The errata list has been stable (no new submissions) and 230 only minor protocol lessons learned were identified. Resolution of 231 the IESG's experiment is documented in [RFC6686]. 233 1.3. Terminology 235 1.3.1. Keywords 237 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 238 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 239 "OPTIONAL" in this document are to be interpreted as described in 240 [RFC2119]. 242 1.3.2. Imported Definitions 244 The ABNF tokens "ALPHA", "DIGIT", and "SP" are defined in [RFC5234]. 246 The token "local-part" is defined in [RFC5321]. 248 "dot-atom", "quoted-string", "comment", "CFWS", "FWS", and "CRLF" are 249 defined in [RFC5322]. 251 1.3.3. Mail From Definition 253 This document is concerned with the portion of a mail message 254 commonly called "envelope sender", "return path", "reverse path", 255 "bounce address", "5321 FROM", or "MAIL FROM". Since these terms are 256 either not well defined or often used casually, this document uses 257 RFC5321.MailFrom as defined in [RFC5598]. Note that other terms that 258 might superficially look like the common terms, such as "reverse- 259 path", are used only with the defined meanings from normative 260 documents. 262 1.3.4. HELO Definition 264 This document also makes use of the HELO/EHLO identity. The "HELO" 265 identity derives from either the SMTP HELO or EHLO command (see 266 [RFC5321]). Since HELO and EHLO can, in many cases, be used 267 interchangeably, they are identified as RFC5321.HELO/.EHLO in 268 [RFC5598]. These commands supply the identity of the SMTP client 269 (sending host) for the SMTP session. 271 1.3.5. Deprecated 273 There are [RFC4408] features that are marked "deprecated". In the 274 context of this document, deprecated means that senders SHOULD NOT 275 publish SPF records that make use of such features because they might 276 be removed entirely in future updates to the protocol. Such features 277 do, however, remain part of the SPF protocol and receiving systems 278 MUST support them unless this document explicitly says otherwise. 280 2. Operation 282 2.1. The RFC5321.HELO/.EHLO Identity 284 It is RECOMMENDED that SPF clients not only check the 285 RFC5321.MailFrom identity, but also separately check the 286 RFC5321.HELO/.EHLO identity by applying the check_host() function 287 (Section 4) to the RFC5321.HELO/.EHLO identity as the . 288 Checking RFC5321.HELO/.EHLO promotes consistency of results and can 289 reduce DNS resource usage. Additionally, since SPF records published 290 for RFC5321.HELO/.EHLO identities refer to a single host, when 291 available, they are a very reliable source of host authorization 292 status. 294 Note that requirements for the domain presented in the EHLO or HELO 295 command are not always clear to the sending party, and SPF clients 296 MUST be prepared for the RFC5321.HELO/.EHLO identity to be malformed 297 or an IP address literal. 299 2.2. The RFC5321.MailFrom Identity 301 [RFC5321] allows the reverse-path to be null (see Section 4.5.5 in 302 [RFC5321]). In this case, there is no explicit sender mailbox, and 303 such a message can be assumed to be a notification message from the 304 mail system itself. When the reverse-path is null, this document 305 defines the RFC5321.MailFrom identity to be the mailbox composed of 306 the local-part "postmaster" and the RFC5321.HELO/.EHLO identity 307 (which might or might not have been checked separately before). 309 SPF clients MUST check the "RFC5321.MailFrom identity if a completed 310 RFC5321.HELO/.EHLO check has not reached a definitive policy result 311 by applying the check_host() function to the RFC5321.MailFrom 312 identity as the . 314 2.3. Publishing Authorization 316 An SPF-compliant domain MUST publish a valid SPF record as described 317 in Section 3. This record authorizes the use of the domain name in 318 the RFC5321.HELO/.EHLO and RFC5321.MailFrom identities by the MTAs it 319 specifies. 321 SPF results can be used to make both positive (source is authorized) 322 and negative (source is not authorized) determinations. If domain 323 owners choose to publish SPF records and want to support receivers 324 making negative authorization determinations, then they MUST publish 325 records that end in "-all", or redirect to other records that do, 326 otherwise, no definitive determination of authorization can be made. 327 Potential issues and mitigations associated with negative 328 determinations are discussed in Section 9. 330 Domain holders can publish SPF records that explicitly authorize no 331 hosts if mail is not expected to originate using that domain. 333 When changing SPF records, care must be taken to ensure that there is 334 a transition period so that the old policy remains valid until all 335 legitimate email can reasonably expect to have been checked. This 336 can be as much as 30 days. 338 2.4. Checking Authorization 340 A mail receiver can perform a set of SPF checks for each mail message 341 it receives. An SPF check tests the authorization of a client host 342 to emit mail with a given identity. Typically, such checks are done 343 by a receiving MTA, but can be performed elsewhere in the mail 344 processing chain so long as the required information is available and 345 reliable. At least the RFC5321.MailFrom identity MUST be checked, 346 but it is RECOMMENDED that the RFC5321.HELO/.EHLO identity also be 347 checked beforehand. 349 Without explicit approval of the domain owner, checking other 350 identities against SPF version 1 records is NOT RECOMMENDED because 351 there are cases that are known to give incorrect results. For 352 example, almost all mailing lists rewrite the RFC5321.MailFrom 353 identity (see Section 9.2.1), but some do not change any other 354 identities in the message. The scenario described in Section 9.2.2, 355 sub-section 1.2, is another example. Documents that define other 356 identities will have to define the method for explicit approval. 358 It is possible that mail receivers will use the SPF check as part of 359 a larger set of tests on incoming mail. The results of other tests 360 might influence whether or not a particular SPF check is performed. 361 For example, finding the sending host's IP address on a local white 362 list might cause all other tests to be skipped and all mail from that 363 host to be accepted. 365 When a mail receiver decides to perform an SPF check, it MUST use a 366 correctly-implemented check_host() function (Section 4) evaluated 367 with the correct parameters. Although the test as a whole is 368 optional, once it has been decided to perform a test it must be 369 performed as specified so that the correct semantics are preserved 370 between publisher and receiver. 372 To make the test, the mail receiver MUST evaluate the check_host() 373 function with the arguments set as follows: 375 - the IP address of the SMTP client that is emitting the 376 mail, either IPv4 or IPv6. 378 - the domain portion of the RFC5321.MailFrom or 379 RFC5321.HELO/.EHLO identity. 381 - the RFC5321.MailFrom or RFC5321.HELO/.EHLO identity. 383 Note that the argument might not be a well-formed domain 384 name. For example, if the reverse-path was null, then the EHLO/HELO 385 domain is used, with its associated problems (see Section 2.1). In 386 these cases, check_host() is defined in Section 4.3 to return a 387 "none" result. 389 Although invalid, malformed, or non-existent domains cause SPF checks 390 to return "none" because no SPF record can be found, it has long been 391 the policy of many MTAs to reject email from such domains, especially 392 in the case of invalid RFC5321.MailFrom. Rejecting email will 393 prevent one method of circumventing of SPF records. 395 Implementations MUST take care to correctly extract the from 396 the data given with the SMTP MAIL FROM command as many MTAs will 397 still accept such things as source routes (see [RFC5321], Appendix 398 C), the %-hack (see [RFC1123]), and bang paths (see [RFC1983]). 399 These archaic features have been maliciously used to bypass security 400 systems. 402 2.5. Interpreting the Result 404 This section describes how software that performs the authorization 405 should interpret the results of the check_host() function. The 406 authorization check SHOULD be performed during the processing of the 407 SMTP transaction that sends the mail. This allows errors to be 408 returned directly to the sending MTA by way of SMTP replies. 410 Performing the authorization other than using the return-path and 411 client address at the time of the MAIL command during the SMTP 412 transaction can cause problems, such as the following: (1) It might 413 be difficult to accurately extract the required information from 414 potentially deceptive headers; (2) legitimate email might fail 415 because the sender's policy had since changed. 417 Generating non-delivery notifications to forged identities that have 418 failed the authorization check is a source of backscatter and SHOULD 419 be avoided. [RFC3834] section 2 describes backscatter and the 420 problems it causes. 422 2.5.1. None 424 A result of "none" means either (a) no syntactically valid DNS domain 425 name was extracted from the SMTP session that could be used as the 426 one to be authorized, or (b) no TXT records were retrieved from the 427 DNS that appeared to be intended for use by SPF verifiers. 429 2.5.2. Neutral 431 The domain owner has explicitly stated that they cannot or do not 432 want to assert whether the IP address is authorized or not. A 433 "neutral" result MUST be treated exactly like the "none" result; the 434 distinction exists only for informational purposes. Treating 435 "neutral" more harshly than "none" would discourage domain owners 436 from testing the use of SPF records (see Section 9.1). 438 2.5.3. Pass 440 A "pass" result means that the client is authorized to inject mail 441 with the given identity. The domain can now, in the sense of 442 reputation, be considered responsible for sending the message. 443 Further policy checks can now proceed with confidence in the 444 legitimate use of the identity. 446 2.5.4. Fail 448 A "fail" result is an explicit statement that the client is not 449 authorized to use the domain in the given identity. Disposition of 450 SPF fail messages is a matter of local policy. See Section 9.3 for 451 considerations on developing local policy. 453 If the checking software chooses to reject the mail during the SMTP 454 transaction, then it SHOULD use an SMTP reply code of 550 (see 455 [RFC5321]) and, if supported, the 5.7.1 enhanced status code (see 456 [RFC3463]), in addition to an appropriate reply text. The 457 check_host() function will return either a default explanation string 458 or one from the domain that published the SPF records (see 459 Section 6.2). If the information does not originate with the 460 checking software, it should be made clear that the text is provided 461 by the sender's domain. For example: 463 550-5.7.1 SPF MAIL FROM check failed: 464 550-5.7.1 The domain example.com explains: 465 550 5.7.1 Please see http://www.example.com/mailpolicy.html 467 2.5.5. Softfail 469 A "softfail" result should be treated as somewhere between a "fail" 470 and a "neutral". The domain believes the host is not authorized but 471 is not willing to make a strong policy statement. Receiving software 472 SHOULD NOT reject the message based solely on this result, but MAY 473 subject the message to closer scrutiny than normal. 475 The domain owner wants to discourage the use of this host and thus 476 desires limited feedback when a "softfail" result occurs. For 477 example, the recipient's Mail User Agent (MUA) could highlight the 478 "softfail" status, or the receiving MTA could give the sender a 479 message using greylisting, [RFC6647], with a note the first time the 480 message is received, but accept it on a later attempt based on 481 receiver policy. 483 2.5.6. TempError 485 A "temperror" result means the SPF client encountered a transient 486 (DNS) error while performing the check. Checking software can choose 487 to accept or temporarily reject the message. If the message is 488 rejected during the SMTP transaction for this reason, the software 489 SHOULD use an SMTP reply code of 451 and, if supported, the 4.4.3 490 enhanced status code. These errors can be caused by DNS problems in 491 either the sender's or receiver's DNS. 493 2.5.7. PermError 495 A "permerror" result means the domain's published records could not 496 be correctly interpreted. This signals an error condition that 497 definitely requires manual intervention to be resolved. If the 498 message is rejected during the SMTP transaction for this reason, the 499 software SHOULD use an SMTP reply code of 550 and, if supported, the 500 5.5.2 enhanced status code. Be aware that if the domain owner uses 501 macros (Section 8), it is possible that this result is due to the 502 checked identities having an unexpected format. 504 3. SPF Records 506 An SPF record is a DNS TXT (type 16) Resource Record (RR) that 507 declares which hosts are, and are not, authorized to use a domain 508 name for the RFC5321.HELO/.EHLO and RFC5321.MailFrom identities. 509 Loosely, the record partitions all hosts into permitted and not- 510 permitted sets (though some hosts might fall into neither category). 512 The SPF record is a single string of text. An example record is the 513 following: 515 v=spf1 +mx a:colo.example.com/28 -all 517 This record has a version of "spf1" and three directives: "+mx", 518 "a:colo.example.com/28" (the + is implied), and "-all". 520 Domain owners wishing to be SPF compliant MUST publish SPF records 521 for the hosts that are used in the RFC5321.MailFrom and RFC5321.HELO/ 522 .EHLO identities. The SPF records are placed in the DNS tree at the 523 host name it pertains to, not a subdomain under it, such as is done 524 with SRV records [RFC2782]. 526 The example in Section 3 might be published via these lines in a 527 domain zone file: 529 example.com. TXT "v=spf1 +mx a:colo.example.com/28 -all" 530 smtp-out.example.com. TXT "v=spf1 a -all" 532 Since TXT records have multiple uses, beware of other TXT records 533 published there for other purposes. They might cause problems with 534 size limits (see Section 3.4) and care MUST be taken to ensure only 535 SPF records are used for SPF processing. 537 Domains publishing records SHOULD try to keep the number of "include" 538 mechanisms and chained "redirect" modifiers to a minimum. Domains 539 SHOULD also try to minimize the amount of other DNS information 540 needed to evaluate a record. Section 9.1.1 provides some suggestions 541 on how to achieve this. 543 3.1. DNS Resource Records 545 SPF records MUST be published as type TXT [RFC1035]. The character 546 content of the record is encoded as [US-ASCII]. Use of alternate DNS 547 RR types was supported in SPF's experimental phase, but has been 548 discontinued. See Appendix A of [RFC6686] for further information. 550 3.2. Multiple DNS Records 552 A domain name MUST NOT have multiple records that would cause an 553 authorization check to select more than one record. See Section 4.5 554 for the selection rules. 556 3.3. Multiple Strings in a Single DNS record 558 As defined in [RFC1035] sections 3.3.14 and 3.3, a single text DNS 559 record (either TXT or SPF RR types) can be composed of more than one 560 string. If a published record contains multiple character-strings, 561 then the record MUST be treated as if those strings are concatenated 562 together without adding spaces. For example: 564 IN TXT "v=spf1 .... first" "second string..." 566 MUST be treated as equivalent to 568 IN TXT "v=spf1 .... firstsecond string..." 570 TXT records containing multiple strings are useful in constructing 571 records that would exceed the 255-byte maximum length of a character- 572 string within a single TXT record. 574 3.4. Record Size 576 The published SPF record for a given domain name SHOULD remain small 577 enough that the results of a query for it will fit within 512 octets. 578 This UDP limit is defined in [RFC1035] section 2.3.4. This will keep 579 even older DNS implementations from falling over to TCP. Since the 580 answer size is dependent on many things outside the scope of this 581 document, it is only possible to give this guideline: If the combined 582 length of the DNS name and the text of all the records of a given 583 type is under 450 characters, then DNS answers ought to fit in UDP 584 packets. Note that when computing the sizes for queries of the TXT 585 format, one must take into account any other TXT records published at 586 the domain name. Records that are too long to fit in a single UDP 587 packet could be silently ignored by SPF clients due to firewall and 588 other issues that cause DNS over TCP to be less reliable than DNS 589 over UDP. 591 3.5. Wildcard Records 593 Use of wildcard records for publishing is NOT RECOMMENDED. Care must 594 be taken if wildcard records are used. If a domain publishes 595 wildcard MX records, it might want to publish wildcard declarations, 596 subject to the same requirements and problems. In particular, the 597 declaration MUST be repeated for any host that has any RR records at 598 all, and for subdomains thereof. For example, the example given in 599 [RFC1034], Section 4.3.3, could be extended with the following: 601 X.COM. MX 10 A.X.COM 602 X.COM. TXT "v=spf1 a:A.X.COM -all" 604 *.X.COM. MX 10 A.X.COM 605 *.X.COM. TXT "v=spf1 a:A.X.COM -all" 607 A.X.COM. A 1.2.3.4 608 A.X.COM. MX 10 A.X.COM 609 A.X.COM. TXT "v=spf1 a:A.X.COM -all" 611 *.A.X.COM. MX 10 A.X.COM 612 *.A.X.COM. TXT "v=spf1 a:A.X.COM -all" 614 Notice that SPF records MUST be repeated twice for every name within 615 the domain: once for the name, and once with a wildcard to cover the 616 tree under the name. 618 Use of wildcards is discouraged in general as they cause every name 619 under the domain to exist and queries against arbitrary names will 620 never return RCODE 3 (Name Error) and will interfere with existence 621 tests such as the one described in [RFC5617]. 623 4. The check_host() Function 625 This description is not an API (Application Program Interface) 626 definition, but rather a function description used to illustrate the 627 algorithm. A compliant SPF implementation MUST do something 628 semantically equivalent to this description. 630 The check_host() function fetches SPF records, parses them, and 631 evaluates them to determine whether a particular host is or is not 632 permitted to send mail with a given identity. Mail receivers that 633 perform this check MUST correctly evaluate the check_host() function 634 as described here. 636 Implementations MAY use a different algorithm than the canonical 637 algorithm defined here, so long as the results are the same in all 638 cases. 640 4.1. Arguments 642 The check_host() function takes these arguments: 644 - the IP address of the SMTP client that is emitting the 645 mail, either IPv4 or IPv6. 647 - the domain that provides the sought-after authorization 648 information; initially, the domain portion of the "MAIL 649 FROM" or RFC5321.HELO/.EHLO identity. 651 - the RFC5321.MailFrom or RFC5321.HELO/.EHLO identity. 653 The domain portion of will usually be the same as the 654 argument when check_host() is initially evaluated. However, 655 this will generally not be true for recursive evaluations (see 656 Section 5.2 below). 658 Actual implementations of the check_host() function might need 659 additional arguments. 661 4.2. Results 663 The function check_host() can return one of several results described 664 in Section 2.5. Based on the result, the action to be taken is 665 determined by the local policies of the receiver. 667 4.3. Initial Processing 669 If the is malformed (e.g. label longer than 63 characters, 670 zero-length label not at the end, etc.) or is not a fully qualified 671 domain name, or if the DNS lookup returns "domain does not exist" 672 (RCODE 3), check_host() immediately returns the result "none". 673 Properly formed domains are fully qualified email domains as 674 described in [RFC5321] Section 2.3.5. Internationalized domain names 675 MUST be encoded as A-labels, as described in Section 2.3 of 676 [RFC5890]. 678 If the has no local-part, substitute the string "postmaster" 679 for the local-part. 681 4.4. Record Lookup 683 In accordance with how the records are published (see Section 3 684 above), a DNS query needs to be made for the name, querying 685 for type TXT only. 687 If all DNS lookups that are made return a server failure (RCODE 2), 688 or other error (RCODE other than 0 or 3), or time out, then 689 check_host() terminates immediately with the result "temperror". 690 Alternatively, for a server failure (RCODE 2) result, check_host() 691 MAY track failures and treat multiple failures within 24 hours for 692 the same domain as "permerror". 694 This alternative is intended to shorten the queue time of messages 695 that cannot be accepted, by returning a permanent negative completion 696 reply code to the client, instead of a transient one. [RFC2308] 697 suggests on an algorithm for doing such tracking and handling of 698 server failure codes. 700 4.5. Selecting Records 702 Records begin with a version section: 704 record = version terms *SP 705 version = "v=spf1" 707 Starting with the set of records that were returned by the lookup, 708 discard records that do not begin with a version section of exactly 709 "v=spf1". Note that the version section is terminated either by an 710 SP character or the end of the record. A record with a version 711 section of "v=spf10" does not match and must be discarded. 713 If the resultant record set includes no records, check_host() 714 produces the "none" result. If the resultant record set includes 715 more than one record, check_host() produces the "permerror" result. 717 4.6. Record Evaluation 719 After one SPF record has been selected, the check_host() function 720 parses and interprets it to find a result for the current test. If 721 there are any syntax errors, check_host() returns immediately with 722 the result "permerror". 724 Implementations MAY choose to parse the entire record first and 725 return "permerror" if the record is not syntactically well formed. 726 However, in all cases, any syntax errors anywhere in the record MUST 727 be detected. 729 4.6.1. Term Evaluation 731 There are two types of terms: mechanisms and modifiers. A record 732 contains an ordered list of these as specified in the following 733 Augmented Backus-Naur Form (ABNF). 735 terms = *( 1*SP ( directive / modifier ) ) 737 directive = [ qualifier ] mechanism 738 qualifier = "+" / "-" / "?" / "~" 739 mechanism = ( all / include 740 / A / MX / PTR / IP4 / IP6 / exists ) 741 modifier = redirect / explanation / unknown-modifier 742 unknown-modifier = name "=" macro-string 743 ; where name is not any known modifier 745 name = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." ) 747 Most mechanisms allow a ":" or "/" character after the name. 749 Modifiers always contain an equals ('=') character immediately after 750 the name, and before any ":" or "/" characters that might be part of 751 the macro-string. 753 Terms that do not contain any of "=", ":", or "/" are mechanisms, as 754 defined in Section 5. 756 As per the definition of the ABNF notation in [RFC5234], mechanism 757 and modifier names are case-insensitive. 759 4.6.2. Mechanisms 761 Each mechanism is considered in turn from left to right. If there 762 are no more mechanisms, the result is specified in Section 4.7. 764 When a mechanism is evaluated, one of three things can happen: it can 765 match, not match, or throw an exception. 767 If it matches, processing ends and the qualifier value is returned as 768 the result of that record. If it does not match, processing 769 continues with the next mechanism. If it throws an exception, 770 mechanism processing ends and the exception value is returned. 772 The possible qualifiers, and the results they cause check_host() to 773 return are as follows: 775 "+" pass 776 "-" fail 777 "~" softfail 778 "?" neutral 780 The qualifier is optional and defaults to "+". 782 When a mechanism matches and the qualifier is "-", then a "fail" 783 result is returned and the explanation string is computed as 784 described in Section 6.2. 786 The specific mechanisms are described in Section 5. 788 4.6.3. Modifiers 790 Modifiers are not mechanisms. They do not return match or not-match. 791 Instead, they provide additional information. Although modifiers do 792 not directly affect the evaluation of the record, the "redirect" 793 modifier has an effect after all the mechanisms have been evaluated. 795 4.6.4. DNS Lookup Limits 797 SPF implementations MUST limit the number of mechanisms and modifiers 798 ("terms") that DNS lookups to at most 10 during SPF evaluation. 799 Specifically, the "include", "a", "mx", "ptr", and "exists" 800 mechanisms as well as the "redirect" modifier count against this 801 limit. The "all", "ip4", and "ip6" mechanisms do not count against 802 this limit. If this number is exceeded during a check, a permerror 803 MUST be returned. The "exp" modifier does not count against this 804 limit because the DNS lookup to fetch the explanation string occurs 805 after the SPF record evaluation has been completed. 807 When evaluating the "mx" and "ptr" mechanisms, or the %{p} macro, 808 there MUST be a limit of no more than 10 MX or PTR RRs looked up and 809 checked. If more than 10 "mx" or "ptr" records are returned for this 810 further lookup, a permerror MUST be returned. This limit is per 811 mechanism or macro in the record and in addition to the lookup limits 812 above. 814 4.7. Default Result 816 If none of the mechanisms match and there is no "redirect" modifier, 817 then the check_host() returns a result of "neutral", just as if 818 "?all" were specified as the last directive. If there is a 819 "redirect" modifier, check_host() proceeds as defined in Section 6.1. 821 Note that records SHOULD always use either a "redirect" modifier or 822 an "all" mechanism to explicitly terminate processing. Although the 823 latter has default (specifically "?all"), it aids debugging efforts 824 if it is explicitly included. 826 For example: 828 v=spf1 +mx -all 829 or 830 v=spf1 +mx redirect=_spf.example.com 832 4.8. Domain Specification 834 Several of these mechanisms and modifiers have a domain-spec section. 835 The domain-spec string is subject to macro expansion (see Section 8). 836 The resulting string is the common presentation form of a fully- 837 qualified DNS name: a series of labels separated by periods. This 838 domain is called the in the rest of this document. 840 Note: The result of the macro expansion is not subject to any further 841 escaping. Hence, this facility cannot produce all characters that 842 are legal in a DNS label (e.g., the control characters). However, 843 this facility is powerful enough to express legal host names and 844 common utility labels (such as "_spf") that are used in DNS. 846 For several mechanisms, the is optional. If it is not 847 provided, the is used as the . Domain and 848 domain-spec are syntactically identical after macro expansion. 849 Domain is an input value for check_host() while domain-spec is 850 computed by check_host(). 852 5. Mechanism Definitions 854 This section defines two types of mechanisms. 856 Basic mechanisms contribute to the language framework. They do not 857 specify a particular type of authorization scheme. 859 all 860 include 862 Designated sender mechanisms are used to designate a set of 863 addresses as being permitted or not permitted to use the for 864 sending mail. 866 a 867 mx 868 ptr (deprecated) 869 ip4 870 ip6 871 exists 873 The following conventions apply to all mechanisms that perform a 874 comparison between and an IP address at any point: 876 If no CIDR prefix length is given in the directive, then and the 877 IP address are compared for equality. (Here, CIDR is Classless 878 Inter-Domain Routing, described in [RFC4632].) 880 If a CIDR prefix length is specified, then only the specified number 881 of high-order bits of and the IP address are compared for 882 equality. 884 When any mechanism fetches host addresses to compare with , when 885 is an IPv4 address, A records are fetched; when is an IPv6 886 address, AAAA records are fetched. Even if the SMTP connection uses 887 IPv6, an IPv4-mapped IPv6 IP address (see [RFC4291], Section 2.5.5) 888 MUST still be considered an IPv4 address and MUST be evaluated using 889 IPv4 mechanisms (i.e. "ip4" and "a"). 891 Several mechanisms rely on information fetched from the DNS. For 892 these DNS queries, except where noted, if the DNS server returns an 893 error (RCODE other than 0 or 3) or the query times out, the mechanism 894 throws the exception "temperror". If the server returns "domain does 895 not exist" (RCODE 3), then evaluation of the mechanism continues as 896 if the server returned no error (RCODE 0) and zero answer records. 898 5.1. "all" 900 all = "all" 902 The "all" mechanism is a test that always matches. It is used as the 903 rightmost mechanism in a record to provide an explicit default. 905 For example: 907 v=spf1 a mx -all 909 Mechanisms after "all" will never be tested. Mechanisms listed after 910 "all" MUST be ignored. Any "redirect" modifier (Section 6.1) has 911 MUST be ignored when there is an "all" mechanism in the record. 913 5.2. "include" 915 include = "include" ":" domain-spec 917 The "include" mechanism triggers a recursive evaluation of 918 check_host(). 920 1. The domain-spec is expanded as per Section 8. 922 2. Check_host() is evaluated with the resulting string as the 923 . The and arguments remain the same as in 924 the current evaluation of check_host(). 926 3. The recursive evaluation returns either match, not match, or an 927 error. If it matches, then the appropriate result for the 928 include: mechanism is used (e.g. include or +include gives a 929 "pass" result and -include gives "fail). 931 4. If there is no match, the parent check_host() resumes processing 932 as per the table below, with the previous value of 933 restored. 935 In hindsight, the name "include" was poorly chosen. Only the 936 evaluated result of the referenced SPF record is used, rather than 937 acting as if the referenced SPF record was literally included in the 938 first. For example, evaluating a "-all" directive in the referenced 939 record does not terminate the overall processing and does not 940 necessarily result in an overall "fail". (Better names for this 941 mechanism would have been "if-match", "on-match", etc.) 943 The "include" mechanism makes it possible for one domain to designate 944 multiple administratively-independent domains. For example, a vanity 945 domain "example.net" might send mail using the servers of 946 administratively-independent domains example.com and example.org. 948 Example.net could say 950 IN TXT "v=spf1 include:example.com include:example.org -all" 952 This would direct check_host() to, in effect, check the records of 953 example.com and example.org for a "pass" result. Only if the host 954 were not permitted for either of those domains would the result be 955 "fail". 957 Whether this mechanism matches, does not match, or throws an 958 exception depends on the result of the recursive evaluation of 959 check_host(): 961 +---------------------------------+---------------------------------+ 962 | A recursive check_host() result | Causes the "include" mechanism | 963 | of: | to: | 964 +---------------------------------+---------------------------------+ 965 | pass | match | 966 | | | 967 | fail | not match | 968 | | | 969 | softfail | not match | 970 | | | 971 | neutral | not match | 972 | | | 973 | temperror | throw temperror | 974 | | | 975 | permerror | throw permerror | 976 | | | 977 | none | throw permerror | 978 +---------------------------------+---------------------------------+ 980 The "include" mechanism is intended for crossing administrative 981 boundaries. For example, if example.com and example.org were managed 982 by the same entity, and if the permitted set of hosts for both 983 domains was 984 "mx:example.com", it would be possible for example.org to specify 985 "include:example.com", but it would be preferable to specify 986 "redirect=example.com" or even "mx:example.com". 988 With the "include" mechanism an administratively external set of 989 hosts can be authorized, but determination of sender policy is still 990 a function of the original domain's SPF record (as determined by the 991 "all" mechanism in that record). The redirect modifier is more 992 suitable for consolidating both authorizations and policy into a 993 common set to be shared within an ADMD. Redirect is much more like a 994 common code element to be shared among records in a single ADMD. It 995 is possible to control both authorized hosts and policy for an 996 arbitrary number of domains from a single record. 998 5.3. "a" 1000 This mechanism matches if is one of the 's IP 1001 addresses. 1003 a = "a" [ ":" domain-spec ] [ dual-cidr-length ] 1005 An address lookup is done on the . The is compared 1006 to the returned address(es). If any address matches, the mechanism 1007 matches. 1009 5.4. "mx" 1011 This mechanism matches if is one of the MX hosts for a domain 1012 name. 1014 mx = "mx" [ ":" domain-spec ] [ dual-cidr-length ] 1016 check_host() first performs an MX lookup on the . Then 1017 it performs an address lookup on each MX name returned. The is 1018 compared to each returned IP address. To prevent Denial of Service 1019 (DoS) attacks, more than 10 MX names MUST NOT be looked up during the 1020 evaluation of an "mx" mechanism (see Section 10). If any address 1021 matches, the mechanism matches. 1023 Note regarding implicit MXs: If the has no MX records, 1024 check_host() MUST NOT pretend the target is its single MX, and MUST 1025 NOT default to an A or AAAA lookup on the directly. 1026 This behavior diverges from the legacy "implicit MX" rule, (See 1027 [RFC5321], Section 5. If such behavior is desired, the publisher 1028 should specify an "a" directive). 1030 5.5. "ptr" (deprecated) 1032 This mechanism tests whether the DNS reverse-mapping for exists 1033 and correctly points to a domain name within a particular domain. 1034 This mechanism is deprecated and SHOULD NOT be used. 1036 ptr = "ptr" [ ":" domain-spec ] 1038 The 's name is looked up using this procedure: 1040 1. Perform a DNS reverse-mapping for 1041 2. Look up the corresponding PTR record in "in-addr.arpa." if the 1042 address is an IPv4 one and in "ip6.arpa." if it is an IPv6 1043 address. 1045 3. For each record returned, validate the domain name by looking up 1046 its IP address. To prevent DoS attacks, more than 10 PTR names 1047 MUST NOT be looked up during the evaluation of a "ptr" mechanism 1048 (see Section 4.6.4). 1050 4. If is among the returned IP addresses, then that domain name 1051 is validated. 1053 Check all validated domain names to see if they either match the 1054 domain or are a subdomain of the domain. 1055 If any do, this mechanism matches. If no validated domain name can 1056 be found, or if none of the validated domain names match or are a 1057 subdomain of the , this mechanism fails to match. If a 1058 DNS error occurs while doing the PTR RR lookup, then this mechanism 1059 fails to match. If a DNS error occurs while doing an A RR lookup, 1060 then that domain name is skipped and the search continues. 1062 Pseudocode: 1064 sending-domain_names := ptr_lookup(sending-host_IP); 1065 if more than 10 sending-domain_names are found, use at most 10. 1066 for each name in (sending-domain_names) { 1067 IP_addresses := a_lookup(name); 1068 if the sending-domain_IP is one of the IP_addresses { 1069 validated-sending-domain_names += name; 1070 } 1071 } 1073 for each name in (validated-sending-domain_names) { 1074 if name ends in , return match. 1075 if name is , return match. 1076 } 1077 return no-match. 1079 This mechanism matches if the is either a subdomain of 1080 a validated domain name or if the and a validated 1081 domain name are the same. For example: "mail.example.com" is within 1082 the domain "example.com", but "mail.bad-example.com" is not. 1084 Note: This mechanism has been deprecated because it is slow, it is 1085 not as reliable as other mechanisms in cases of DNS errors, and it 1086 places a large burden on the .arpa name servers. If used, proper PTR 1087 records must be in place for the domain's hosts and the "ptr" 1088 mechanism should be one of the last mechanisms checked. After many 1089 yearrs of SPF deployment experience it has been concluded it is 1090 unnecessary and more reliable alternatives used instead. It is, 1091 however, still in use and part of the SPF protocol, so compliant 1092 check_host() implementations MUST support it. 1094 5.6. "ip4" and "ip6" 1096 These mechanisms test whether is contained within a given IP 1097 network. 1099 ip4 = "ip4" ":" ip4-network [ ip4-cidr-length ] 1100 ip6 = "ip6" ":" ip6-network [ ip6-cidr-length ] 1102 ip4-cidr-length = "/" 1*DIGIT 1103 ip6-cidr-length = "/" 1*DIGIT 1104 dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ] 1106 ip4-network = qnum "." qnum "." qnum "." qnum 1107 qnum = DIGIT ; 0-9 1108 / %x31-39 DIGIT ; 10-99 1109 / "1" 2DIGIT ; 100-199 1110 / "2" %x30-34 DIGIT ; 200-249 1111 / "25" %x30-35 ; 250-255 1112 ; as per conventional dotted quad notation. e.g., 192.0.2.0 1113 ip6-network = 1114 ; e.g., 2001:DB8::CD30 1116 The is compared to the given network. If CIDR prefix length 1117 high-order bits match, the mechanism matches. 1119 If ip4-cidr-length is omitted, it is taken to be "/32". If 1120 ip6-cidr-length is omitted, it is taken to be "/128". It is not 1121 permitted to omit parts of the IP address instead of using CIDR 1122 notations. That is, use 192.0.2.0/24 instead of 192.0.2. 1124 5.7. "exists" 1126 This mechanism is used to construct an arbitrary domain name that is 1127 used for a DNS A record query. It allows for complicated schemes 1128 involving arbitrary parts of the mail envelope to determine what is 1129 permitted. 1131 exists = "exists" ":" domain-spec 1133 The domain-spec is expanded as per Section 8. The resulting domain 1134 name is used for a DNS A RR lookup. If any A record is returned, 1135 this mechanism matches. The lookup type is A even when the 1136 connection type is IPv6. 1138 Domains can use this mechanism to specify arbitrarily complex 1139 queries. For example, suppose example.com publishes the record: 1141 v=spf1 exists:%{ir}.%{l1r+-}._spf.%{d} -all 1143 The might expand to 1144 "1.2.0.192.someuser._spf.example.com". This makes fine-grained 1145 decisions possible at the level of the user and client IP address. 1147 This mechanism enables queries that mimic the style of tests that 1148 existing DNS white/black lists (DNSxLs) use, as described in 1149 [RFC5782]. The query will either return NXDOMAIN (no match), any 1150 valid answer (match), or an error. 1152 6. Modifier Definitions 1154 Modifiers are name/value pairs that provide additional information. 1155 Modifiers always have an "=" separating the name and the value. 1157 The modifiers defined in this document ("redirect" and "exp") MAY 1158 appear anywhere in the record, but SHOULD appear at the end, after 1159 all mechanisms. Ordering of these two modifiers does not matter. 1160 These two modifiers MUST NOT appear in a record more than once each. 1161 If they do, then check_host() exits with a result of "permerror". 1163 Unrecognized modifiers MUST be ignored no matter where in a record, 1164 or how often. This allows implementations of this document to 1165 gracefully handle records with modifiers that are defined in other 1166 specifications. 1168 6.1. redirect: Redirected Query 1170 The redirect modifier intended for consolidating both authorizations 1171 and policy into a common set to be shared within a single ADMD. 1172 Redirect is like a common code element to be shared among records in 1173 a single ADMD. It is possible to control both authorized hosts and 1174 policy for an arbitrary number of domains from a single record. 1176 redirect = "redirect" "=" domain-spec 1178 If all mechanisms fail to match, and a "redirect" modifier is 1179 present, then processing proceeds as follows: 1181 The domain-spec portion of the redirect section is expanded as per 1182 the macro rules in Section 8. Then check_host() is evaluated with 1183 the resulting string as the . The and 1184 arguments remain the same as in the current evaluation of 1185 check_host(). 1187 The result of this new evaluation of check_host() is then considered 1188 the result of the current evaluation with the exception that if no 1189 SPF record is found, or if the target-name is malformed, the result 1190 is a "permerror" rather than "none". 1192 Note that the newly-queried domain can itself specify redirect 1193 processing. 1195 This facility is intended for use by organizations that wish to apply 1196 the same record to multiple domains. For example: 1198 la.example.com. TXT "v=spf1 redirect=_spf.example.com" 1199 ny.example.com. TXT "v=spf1 redirect=_spf.example.com" 1200 sf.example.com. TXT "v=spf1 redirect=_spf.example.com" 1201 _spf.example.com. TXT "v=spf1 mx:example.com -all" 1203 In this example, mail from any of the three domains is described by 1204 the same record. This can be an administrative advantage. 1206 Note: In general, the domain "A" cannot reliably use a redirect to 1207 another domain "B" not under the same administrative control. Since 1208 the stays the same, there is no guarantee that the record at 1209 domain "B" will correctly work for mailboxes in domain "A", 1210 especially if domain "B" uses mechanisms involving local-parts. An 1211 "include" directive is generally be more appropriate. 1213 For clarity, it is RECOMMENDED that any "redirect" modifier appear as 1214 the very last term in a record. 1216 6.2. exp: Explanation 1218 explanation = "exp" "=" domain-spec 1220 If check_host() results in a "fail" due to a mechanism match (such as 1221 "-all"), and the "exp" modifier is present, then the explanation 1222 string returned is computed as described below. If no "exp" modifier 1223 is present, then either a default explanation string or an empty 1224 explanation string MUST be returned. 1226 The domain-spec is macro expanded (see Section 8) and becomes the 1227 . The DNS TXT record for the is fetched. 1229 If there are any DNS processing errors (any RCODE other than 0), or 1230 if no records are returned, or if more than one record is returned, 1231 or if there are syntax errors in the explanation string, then proceed 1232 as if no exp modifier was given. 1234 The fetched TXT record's strings are concatenated with no spaces, and 1235 then treated as an explain-string, which is macro-expanded. This 1236 final result is the explanation string. Implementations MAY limit 1237 the length of the resulting explanation string to allow for other 1238 protocol constraints and/or reasonable processing limits. Since the 1239 explanation string is intended for an SMTP response and [RFC5321] 1240 Section 2.4 says that responses are in [US-ASCII], the explanation 1241 string MUST be limited to US-ASCII. 1243 Software evaluating check_host() can use this string to communicate 1244 information from the publishing domain in the form of a short message 1245 or URL. Software SHOULD make it clear that the explanation string 1246 comes from a third party. For example, it can prepend the macro 1247 string "%{o} explains: " to the explanation, such as shown in 1248 Section 2.5.4. 1250 Suppose example.com has this record: 1252 v=spf1 mx -all exp=explain._spf.%{d} 1254 Here are some examples of possible explanation TXT records at 1255 explain._spf.example.com: 1257 "Mail from example.com should only be sent by its own servers." 1258 -- a simple, constant message 1260 "%{i} is not one of %{d}'s designated mail servers." 1261 -- a message with a little more information, including the IP 1262 address that failed the check 1264 "See http://%{d}/why.html?s=%{S}&i=%{I}" 1265 -- a complicated example that constructs a URL with the 1266 arguments to check_host() so that a web page can be 1267 generated with detailed, custom instructions 1269 Note: During recursion into an "include" mechanism, an exp= modifier 1270 from the MUST NOT be used. In contrast, when executing 1271 a "redirect" modifier, an exp= modifier from the original domain MUST 1272 NOT be used. 1274 7. Recording The Result 1276 It is RECOMMENDED that SMTP receivers record the result of SPF 1277 processing in the message header. There are two methods for doing 1278 this: the Received-SPF Header Field defined here and the more generic 1279 Authentication-Results Header Field defined in [RFC5451]. Because 1280 these fields are generally used within a receiving ADMD, it is a 1281 local policy choice which to include. In general, the more broadly 1282 applicable Authentication-Results Header Field ought to be used, but 1283 it SHOULD provide the same information as if a Received-SPF Header 1284 Field were used. 1286 If an SMTP receiver chooses to do so, it SHOULD use one of these 1287 header fields for each identity that was checked. This information 1288 is intended for the recipient. (Information intended for the sender 1289 is described in Section 6.2, Explanation.) 1291 7.1. The Received-SPF Header Field 1293 The Received-SPF header field is a trace field (see [RFC5322] Section 1294 3.6.7) and SHOULD be prepended to the existing header, above the 1295 Received: field that is generated by the SMTP receiver. It MUST 1296 appear above all other Received-SPF fields in the message. The 1297 header field has the following format: 1299 header-field = "Received-SPF:" [CFWS] result FWS [comment FWS] 1300 [ key-value-list ] CRLF 1302 result = "pass" / "fail" / "softfail" / "neutral" / 1303 "none" / "temperror" / "permerror" 1305 key-value-list = key-value-pair *( ";" [CFWS] key-value-pair ) 1306 [";"] 1308 key-value-pair = key [CFWS] "=" ( dot-atom / quoted-string ) 1310 key = "client-ip" / "envelope-from" / "helo" / 1311 "problem" / "receiver" / "identity" / 1312 mechanism / name 1314 identity = "mailfrom" ; for the RFC5321.MailFrom identity 1315 / "helo" ; for the RFC5321.HELO/.EHLO identity 1316 / name ; other identities 1318 dot-atom = 1319 quoted-string = 1320 comment = 1321 CFWS = 1322 FWS = 1323 CRLF = 1325 The header field SHOULD include a "(...)" style comment after the 1326 result, conveying supporting information for the result, such as 1327 , , and . 1329 The following key-value pairs are designed for later machine parsing. 1330 SPF clients SHOULD give enough information so that the SPF results 1331 can be verified. That is, at least "client-ip", "helo", and, if the 1332 RFC5321.MailFrom identity was checked, "envelope-from". 1334 client-ip the IP address of the SMTP client 1336 envelope-from the envelope sender mailbox 1338 helo the host name given in the HELO or EHLO command 1340 mechanism the mechanism that matched (if no mechanisms matched, 1341 substitute the word "default") 1343 problem if an error was returned, details about the error 1344 receiver the host name of the SPF client 1346 identity the identity that was checked; see the ABNF 1347 rule 1349 Other keys MAY be defined by SPF clients. 1351 SPF clients MUST make sure that the Received-SPF header field does 1352 not contain invalid characters, is not excessively long (See 1353 [RFC5322] Section 2.1.1), and does not contain malicious data that 1354 has been provided by the sender. 1356 Examples of various header field styles that could be generated are 1357 the following: 1359 Received-SPF: pass (mybox.example.org: domain of 1360 myname@example.com designates 192.0.2.1 as permitted sender) 1361 receiver=mybox.example.org; client-ip=192.0.2.1; 1362 envelope-from="myname@example.com"; helo=foo.example.com; 1364 Received-SPF: fail (mybox.example.org: domain of 1365 myname@example.com does not designate 1366 192.0.2.1 as permitted sender) 1367 identity=mailfrom; client-ip=192.0.2.1; 1368 envelope-from="myname@example.com"; 1370 7.2. SPF Results in the Authentication-Results Header Field 1372 As mentioned in Section 7, the Authentication-Results header field is 1373 designed to communicate lists of tests a border MTA did and their 1374 results. The specified elements of the field provide less 1375 information than SPF-Received: 1377 Authentication-Results: myhost.example.org; spf=pass 1378 smtp.mailfrom=example.net 1380 Received-SPF: pass (myhost.example.org: domain of 1381 myname@example.com designates 192.0.2.1 as permitted sender) 1382 receiver=mybox.example.org; client-ip=192.0.2.1; 1383 envelope-from="myname@example.com"; helo=foo.example.com; 1385 It is, however, possible to add CFWS in an Authentication-Results 1386 Header Field to provide the equivalent information. Receivers SHOULD 1387 include the explanation ("myhost.example.org: domain of 1388 myname@example.com designates 192.0.2.1 as permitted sender" in the 1389 example above), the recipient address ("receiver=mybox.example.org"), 1390 the IP address of the sending SMTP client ("client-ip=192.0.2.1"), 1391 and both the 5321.MailFrom address and/or the 5321.HELO/.EHLO. 1393 Authserv-id SHOULD be the name of the receiving host performing the 1394 check. reason SHOULD include a key-value-list with keys provinding 1395 information normally included in a Received-SPF Header Field that is 1396 not already part of the Authentication-Results Header Field. That 1397 is, at least "client-ip", "helo", and, if the RFC5321.MailFrom 1398 identity was checked, "envelope-from". 1400 authserv-id = 1401 reasonspec = 1403 A suitably enhanced Authentication-Results Header Field might look 1404 like: 1406 Authentication-Results: myhost.example.org; spf=pass 1407 reason="client-ip=192.0.2.1" smtp.helo=foo.example.com 1408 smtp.mailfrom=user@example.net 1410 8. Macros 1412 8.1. Macro Definitions 1414 Many mechanisms and modifiers perform macro expansion on a term. 1416 domain-spec = macro-string domain-end 1417 domain-end = ( "." toplabel [ "." ] ) / macro-expand 1419 toplabel = ( *alphanum ALPHA *alphanum ) / 1420 ( 1*alphanum "-" *( alphanum / "-" ) alphanum ) 1421 ; LDH rule plus additional TLD restrictions 1422 ; (see [RFC3696], Section 2 for background) 1423 alphanum = ALPHA / DIGIT 1425 explain-string = *( macro-string / SP ) 1427 macro-string = *( macro-expand / macro-literal ) 1428 macro-expand = ( "%{" macro-letter transformers *delimiter "}" ) 1429 / "%%" / "%_" / "%-" 1430 macro-literal = %x21-24 / %x26-7E 1431 ; visible characters except "%" 1432 macro-letter = "s" / "l" / "o" / "d" / "i" / "p" / "h" / 1433 "c" / "r" / "t" / "v" 1434 transformers = *DIGIT [ "r" ] 1435 delimiter = "." / "-" / "+" / "," / "/" / "_" / "=" 1437 A literal "%" is expressed by "%%". 1439 "%_" expands to a single " " space. 1440 "%-" expands to a URL-encoded space, viz., "%20". 1442 The following macro letters are expanded in term arguments: 1444 s = 1445 l = local-part of 1446 o = domain of 1447 d = 1448 i = 1449 p = the validated domain name of (deprecated) 1450 v = the string "in-addr" if is ipv4, or "ip6" if is ipv6 1451 h = HELO/EHLO domain 1453 The following macro letters are allowed only in "exp" text: 1455 c = SMTP client IP (easily readable format) 1456 r = domain name of host performing the check 1457 t = current timestamp 1459 A '%' character not followed by a '{', '%', '-', or '_' character is 1460 a syntax error. So 1461 -exists:%(ir).sbl.spamhaus.example.org 1462 is incorrect and will cause check_host() to yield a "permerror". 1463 Instead, say 1464 -exists:%{ir}.sbl.spamhaus.example.org 1466 Optional transformers are the following: 1468 *DIGIT = zero or more digits 1469 'r' = reverse value, splitting on dots by default 1471 If transformers or delimiters are provided, the replacement value for 1472 a macro letter is split into parts. After performing any reversal 1473 operation and/or removal of left-hand parts, the parts are rejoined 1474 using "." and not the original splitting characters. 1476 By default, strings are split on "." (dots). Note that no special 1477 treatment is given to leading, trailing, or consecutive delimiters in 1478 input strings, and so the list of parts might contain empty strings. 1479 Some older implementations of SPF prohibit trailing dots in domain 1480 names, so trailing dots SHOULD NOT be published by domain owners, 1481 although they MUST be accepted by implementations conforming to this 1482 document. Macros MAY specify delimiter characters that are used 1483 instead of ".". 1485 The 'r' transformer indicates a reversal operation: if the client IP 1486 address were 192.0.2.1, the macro %{i} would expand to "192.0.2.1" 1487 and the macro %{ir} would expand to "1.2.0.192". 1489 The DIGIT transformer indicates the number of right-hand parts to 1490 use, after optional reversal. If a DIGIT is specified, the value 1491 MUST be nonzero. If no DIGITs are specified, or if the value 1492 specifies more parts than are available, all the available parts are 1493 used. If the DIGIT was 5, and only 3 parts were available, the macro 1494 interpreter would pretend the DIGIT was 3. Implementations MUST 1495 support at least a value of 128, as that is the maximum number of 1496 labels in a domain name. 1498 The "s" macro expands to the argument. It is an email 1499 address with a local-part, an "@" character, and a domain. The "l" 1500 macro expands to just the local-part. The "o" macro expands to just 1501 the domain part. Note that these values remain the same during 1502 recursive and chained evaluations due to "include" and/or "redirect". 1503 Note also that if the original had no local-part, the local- 1504 part was set to "postmaster" in initial processing (see Section 4.3). 1505 local-parts MUST either be ASCII or encoded as A-labels per Section 1506 2.3 of [RFC5890] to be used in the "s" or "l" macros. 1508 For IPv4 addresses, both the "i" and "c" macros expand to the 1509 standard dotted-quad format. 1511 For IPv6 addresses, the "i" macro expands to a dot-format address; it 1512 is intended for use in %{ir}. The "c" macro MAY expand to any of the 1513 hexadecimal colon-format addresses specified in [RFC4291], Section 1514 2.2. It is intended for humans to read. 1516 The "p" macro expands to the validated domain name of . The 1517 procedure for finding the validated domain name is defined in 1518 Section 5.5. If the is present in the list of validated 1519 domains, it SHOULD be used. Otherwise, if a subdomain of the 1520 is present, it SHOULD be used. Otherwise, any name from the 1521 list MAY be used. If there are no validated domain names or if a DNS 1522 error occurs, the string "unknown" is used. This macro is deprecated 1523 and SHOULD NOT be used. 1525 The "r" macro expands to the name of the receiving MTA. This SHOULD 1526 be a fully qualified domain name, but if one does not exist (as when 1527 the checking is done by a MUA) or if policy restrictions dictate 1528 otherwise, the word "unknown" SHOULD be substituted. The domain name 1529 can be different from the name found in the MX record that the client 1530 MTA used to locate the receiving MTA. 1532 The "t" macro expands to the decimal representation of the 1533 approximate number of seconds since the Epoch (Midnight, January 1, 1534 1970, UTC) at the time of the evaluation. This is the same value as 1535 is returned by the POSIX time() function in most standards-compliant 1536 libraries. 1538 When the result of macro expansion is used in a domain name query, if 1539 the expanded domain name exceeds 253 characters (the maximum length 1540 of a domain name), the left side is truncated to fit, by removing 1541 successive domain labels (and their following dots) until the total 1542 length does not exceed 253 characters. 1544 Uppercased macros expand exactly as their lowercased equivalents, and 1545 are then URL escaped. URL escaping must be performed for characters 1546 not in the "unreserved" set, which is defined in [RFC3986]. 1548 Note: Care must be taken so that macro expansion for legitimate email 1549 does not exceed the 63-character limit on DNS labels. The local-part 1550 of email addresses, in particular, can have more than 63 characters 1551 between dots. 1553 Note: Domains SHOULD avoid using the "s", "l", "o", or "h" macros in 1554 conjunction with any mechanism directive. Although these macros are 1555 powerful and allow per-user records to be published, they severely 1556 limit the ability of implementations to cache results of check_host() 1557 and they reduce the effectiveness of DNS caches. 1559 Implementations SHOULD be aware that if no directive processed during 1560 the evaluation of check_host() contains an "s", "l", "o", or "h" 1561 macro, then the results of the evaluation can be cached on the basis 1562 of and alone for as long as the shortest Time To Live 1563 (TTL) of all the DNS records involved. 1565 The macro ABNF does not in itself limit macro expansion so that it 1566 results in a valid domain-spec. Nonsense such as this is permitted: 1568 %{s.-+,/_=.+,..+.} 1570 Just because the macro ABNF allows it, does not make it valid. The 1571 result of macro expansion MUST still be a valid domain-spec. 1573 8.2. Expansion Examples 1575 The is strong-bad@email.example.com. 1576 The IPv4 SMTP client IP is 192.0.2.3. 1577 The IPv6 SMTP client IP is 2001:DB8::CB01. 1578 The PTR domain name of the client IP is mx.example.org. 1580 macro expansion 1581 ------- ---------------------------- 1582 %{s} strong-bad@email.example.com 1583 %{o} email.example.com 1584 %{d} email.example.com 1585 %{d4} email.example.com 1586 %{d3} email.example.com 1587 %{d2} example.com 1588 %{d1} com 1589 %{dr} com.example.email 1590 %{d2r} example.email 1591 %{l} strong-bad 1592 %{l-} strong.bad 1593 %{lr} strong-bad 1594 %{lr-} bad.strong 1595 %{l1r-} strong 1597 macro-string expansion 1598 -------------------------------------------------------------------- 1599 %{ir}.%{v}._spf.%{d2} 3.2.0.192.in-addr._spf.example.com 1600 %{lr-}.lp._spf.%{d2} bad.strong.lp._spf.example.com 1602 %{lr-}.lp.%{ir}.%{v}._spf.%{d2} 1603 bad.strong.lp.3.2.0.192.in-addr._spf.example.com 1605 %{ir}.%{v}.%{l1r-}.lp._spf.%{d2} 1606 3.2.0.192.in-addr.strong.lp._spf.example.com 1608 %{d2}.trusted-domains.example.net 1609 example.com.trusted-domains.example.net 1611 IPv6: 1612 %{ir}.%{v}._spf.%{d2} 1.0.B.C.0.0.0.0. 1613 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 1615 9. Implications 1617 This section outlines the major implications that adoption of this 1618 document will have on various entities involved in Internet email. 1619 It is intended to make clear to the reader where this document 1620 knowingly affects the operation of such entities. This section is 1621 not a "how-to" manual, or a "best practices" document, and it is not 1622 a comprehensive list of what such entities should do in light of this 1623 document. 1625 This section is non-normative. [RFC5598] describes the Internet 1626 email architecture. This section is organized based on the different 1627 segments of the architecture. 1629 9.1. Sending Domains 1631 Originating ADMDs (ADministrative Management Domains - [RFC5598] 1632 Section 2.2.1 and Section 2.3) that wish to be compliant with this 1633 specification will need to determine the list of relays ([RFC5598] 1634 Section 2.2.2) that they allow to use their domain name in the 1635 RFC5321.HELO/.EHLO and RFC5321.MailFrom identities when relaying to 1636 other ADMDs. It is recognized that forming such a list is not just a 1637 simple technical exercise, but involves policy decisions with both 1638 technical and administrative considerations. 1640 9.1.1. DNS Resource Considerations 1642 Minimizing the DNS resources required for SPF lookups can be done by 1643 choosing directives that require less DNS information and by placing 1644 lower-cost mechanisms earlier in the SPF record. 1646 +----------+--------+-----------------+ 1647 | term | cost | limit | 1648 +----------+--------+-----------------+ 1649 | ip4/ip6 | 0 | - | 1650 | a | 1 | 10 | 1651 | include | 1 | 10 | 1652 | redirect | 1 | 10 | 1653 | exists | 1 | 10 | 1654 | mx | 1 + N* | 10 and N* <= 10 | 1655 | ptr/%{p} | 1 + N* | 10 and N* <= 10 | 1656 +----------+--------+-----------------+ 1657 * N is the number of RRs found during each term evaluation 1659 Section 4.6.4 specifies the limits receivers have to use. It is 1660 essential to publish records that do not exceed these requirements. 1661 It is also required to carefully weight the cost and the 1662 maintainability of licit solutions. 1664 For example, consider a domain set up as follows: 1666 example.com. IN MX 10 mx.example.com. 1667 IN MX 20 mx2.example.com. 1668 mx.example.com. IN A 192.0.2.1 1669 mx2.example.com. IN A 192.0.2.129 1671 Assume the administrative point is to authorize (pass) mx and mx2 1672 while failing every other host. Compare the following solutions: 1674 Best record: 1675 example.com. IN TXT "v=spf1 ip4:192.0.2.1 ip4:192.0.2.129 -all" 1677 Good record: 1678 $ORIGIN example.com. 1679 @ IN TXT "v=spf1 a:authorized_spf.example.com -all" 1680 authorized_spf IN A 192.0.2.1 1681 IN A 192.0.2.129 1683 Expensive record: 1684 example.com. IN TXT "v=spf1 mx:example.com -all" 1686 Wasteful, bad record: 1687 example.com. IN TXT "v=spf1 ip4:192.0.2.0/24 mx -all" 1689 9.1.2. Administrator's Considerations 1691 There might be administrative considerations: using "a" over "ip4" or 1692 "ip6" allows hosts to be renumbered easily. Using "mx" over "a" 1693 allows the set of mail hosts to be changed easily. Unless such 1694 changes are common, it is better to use the less resource intensive 1695 mechanisms like "ip4" and "ip6". 1697 Validating correct deployment is difficult. [RFC6652] describes one 1698 mechanism for soliciting feedback on SPF failures. Another approach 1699 that can be helpful to publish records that include a "tracking 1700 exists:" mechanism. By looking at the name server logs, a rough list 1701 can then be generated. For example: 1703 v=spf1 exists:_h.%{h}._l.%{l}._o.%{o}._i.%{i}._spf.%{d} ?all 1705 Regardless of the method used, understanding the ADMD's outbound mail 1706 architecture is essential to effective deployment. 1708 9.1.3. Bounces 1710 As explained in Section 1.3.3, [RFC5321] allows the reverse-path to 1711 be null, which is typical of some Delivery Status Notification 1712 [RFC3464], commonly called email bounces. In this case the only 1713 entity available for performing an SPF check is the RFC5321.HELO/ 1714 .EHLO identity defined in Section 1.3.4. SPF functionality is 1715 enhanced by administrators ensuring this identity is set correctly 1716 and has an appropriate SPF record. It is common to have the HELO 1717 identity set to hostname instead of domain. Zone file generation for 1718 significant numbers of hosts can be consolidated using the redirect 1719 modifier and scripted for initial deployment. Administrators might 1720 alternatively consider publishing an SPF for *.domain (wildcard 1721 domains) in that case if the involved hostnames do not have already 1722 any other DNS record. 1724 9.2. Mediators 1726 Broadly speaking, there are two types of mediating ADMDs that can 1727 affect SPF deployment of other ADMDs: mailing lists (see [RFC5598] 1728 Section 5.3) and ReSenders ([RFC5598] Section 5.2). 1730 9.2.1. Mailing Lists 1732 Mailing lists must be aware of how they re-inject mail that is sent 1733 to the list. Mailing lists MUST comply with the requirements in 1734 [RFC5321], Section 3.10, and [RFC1123], Section 5.3.6, that say that 1735 the reverse-path MUST be changed to be the mailbox of a person or 1736 other entity who administers the list. Whereas the reasons for 1737 changing the reverse-path are many and long-standing, SPF adds 1738 enforcement to this requirement. 1740 In practice, almost all mailing list software in use already complies 1741 with this requirement. Mailing lists that do not comply might 1742 encounter problems depending on how access to the list is restricted. 1743 Such lists that are entirely internal to a domain (only people in the 1744 domain can send to or receive from the list) are not affected. 1746 9.2.2. Forwarding Services and Aliases 1748 Forwarding services take mail that is received at a mailbox and 1749 direct it to some external mailbox. At the time of this writing, the 1750 near-universal practice of such services is to use the original 1751 RFC5321.MailFrom of a message when re-injecting it for delivery to 1752 the external mailbox. [RFC1123] and [RFC5321] describe this action 1753 as an "alias" rather than a "mail list". This means the external 1754 mailbox's MTA sees all such mail in a connection from a host of the 1755 forwarding service, and so the RFC5321.MailFrom identity will not, in 1756 general, pass authorization. 1758 There are three places that techniques can be used to ameliorate this 1759 problem. 1761 1. The beginning, when email is first sent (Originating ADMDs). 1763 1. "Neutral" results could be given for IP addresses that might 1764 be forwarders, instead of "fail" results. For example: 1766 "v=spf1 mx -exists:%{ir}.sbl.spamhaus.example.org ?all" 1768 This would cause a lookup on an anti-spam DNS blacklist 1769 (DNSBL) and cause a result of "fail" only for email coming 1770 from listed sources. All other email, including email sent 1771 through forwarders, would receive a "neutral" result. By 1772 checking the DNSBL after the known good sources, problems 1773 with incorrect listing on the DNSBL are greatly reduced. 1775 2. The RFC5321.MailFrom identity could have additional 1776 information in the local-part that cryptographically 1777 identifies the mail as coming from an authorized source. In 1778 this case, such an SPF record could be used: 1780 "v=spf1 mx exists:%{l}._spf_verify.%{d} -all" 1782 Then, a specialized DNS server can be set up to serve the 1783 _spf_verify subdomain that validates the local-part. 1784 Although this requires an extra DNS lookup, this happens only 1785 when the email would otherwise be rejected as not coming from 1786 a known good source. 1787 Note that due to the 63-character limit for domain labels, 1788 this approach only works reliably if the local-part signature 1789 scheme is guaranteed either to only produce local-parts with 1790 a maximum of 63 characters or to gracefully handle truncated 1791 local-parts. 1793 3. Similarly, a specialized DNS server could be set up that will 1794 rate-limit the email coming from unexpected IP addresses. 1796 "v=spf1 mx exists:%{ir}._spf_rate.%{d} -all" 1798 4. SPF allows the creation of per-user policies for special 1799 cases. For example, the following SPF record and appropriate 1800 wildcard DNS records can be used: 1802 "v=spf1 mx redirect=%{l1r+}._at_.%{o}._spf.%{d}" 1804 2. The middle, when email is forwarded (Mediating ADMDs). 1806 1. Forwarding services can solve the problem by rewriting the 1807 RFC5321.MailFrom to be in their own domain. This means mail 1808 rejected from the external mailbox will have to be forwarded 1809 back to the original sender by the forwarding service. 1810 Various schemes to do this exist though they vary widely in 1811 complexity and resource requirements on the part of the 1812 forwarding service. 1814 2. Several popular MTAs can be forced from "alias" semantics to 1815 "mailing list" semantics by configuring an additional alias 1816 with "owner-" prepended to the original alias name (e.g., an 1817 alias of "friends: george@example.com, fred@example.org" 1818 would need another alias of the form "owner-friends: 1819 localowner"). 1821 3. The end, when email is received (Receiving ADMDs). 1823 1. If the owner of the external mailbox wishes to trust the 1824 forwarding service, he can direct the external mailbox's MTA 1825 to skip SPF tests when the client host belongs to the 1826 forwarding service. 1828 2. Tests against other identities, such as the RFC5321.HELO/ 1829 .EHLO identity, MAY be used to override a failed test against 1830 the RFC5321.MailFrom identity. 1832 3. For larger domains, it might not be possible to have a 1833 complete or accurate list of forwarding services used by the 1834 owners of the domain's mailboxes. In such cases, whitelists 1835 of generally-recognized forwarding services could be 1836 employed. 1838 9.2.3. Mail Services 1840 MSPs (Mail Service Providers - [RFC5598] Section 2.3) that offer mail 1841 services to third-party domains, such as sending of bulk mail, might 1842 want to adjust their configurations in light of the authorization 1843 check described in this document. If the domain part of the 1844 RFC5321.MailFrom identity used for such email uses the domain of one 1845 of the MSPs domain, then the provider needs only to ensure that its 1846 sending host is authorized by its own SPF record, if any. 1848 If the RFC5321.MailFrom identity does not use the MSP's domain, then 1849 extra care must be taken. The SPF record format has several options 1850 for the third-party domain to authorize the service provider's MTAs 1851 to send mail on its behalf. For MSPs, such as ISPs, that have a wide 1852 variety of customers using the same MTA, steps should be taken to 1853 prevent cross-customer forgery (see Section 10.4). 1855 9.2.4. MTA Relays 1857 Relays are described in [RFC5598] Section 2.2.2. The authorization 1858 check generally precludes the use of arbitrary MTA relays between 1859 sender and receiver of an email message. 1861 Within an organization, MTA relays can be effectively deployed. 1862 However, for purposes of this document, such relays are effectively 1863 transparent. The SPF authorization check is a check between border 1864 MTAs of different ADMDs. 1866 For mail senders, this means that published SPF records must 1867 authorize any MTAs that actually send across the Internet. Usually, 1868 these are just the border MTAs as internal MTAs simply forward mail 1869 to these MTAs for delivery. 1871 The receiving ADMD will generally want to perform the authorization 1872 check at the boundary MTAs, including all secondary MXs. Internal 1873 MTAs (including MTAs that might serve both as boundary MTAs and 1874 internal relays from secondary MXs when they are processing the 1875 relayed mail stream) then do not perform the authorization test. To 1876 perform the authorization test other than at the boundary, the host 1877 that first transferred the message to the receiving ADMD must be 1878 determined, which can be difficult to extract from the message header 1879 because (a) header fields can be forged or malformed, and (b) there's 1880 no standard way to encode that information such that it can be 1881 reliably extracted. Testing other than at the boundary is likely to 1882 produce unreliable results. 1884 9.3. Receivers 1886 SPF results can be used in combination with other methods to 1887 determine the final local disposition (either positive or negative of 1888 a message. It can also be considered dispositive on it's own. 1890 9.3.1. Policy For SPF Pass 1892 SPF pass results can be used in combination with "white lists" of 1893 known "good" domains to bypass some or all additional pre-delivery 1894 email checks. Exactly which checks and how to determine appropriate 1895 white list entries has to be based on local conditions and 1896 requirements. 1898 9.3.2. Policy For SPF Fail 1900 SPF fail results can be used to reject messages during the SMTP 1901 transaction based on either RFC5321.MailFrom or RFC5321.HELO/.EHLO 1902 identity results. This reduces resource requirements for various 1903 content filtering methods and conserves bandwidth since rejection can 1904 be done before the SMTP content is transferred. It also gives 1905 immediate feedback to the sender who might then be able to resolve 1906 the issue. Due to some of the issues described above in this 1907 Section 9 section, SPF based rejection does present some risk of 1908 rejecting legitimate email when rejecting based on RFC5321.MailFrom 1909 results. 1911 SPF fail results can also be used as one input into a larger set of 1912 evaluations which might, based on the overall evaluation result in 1913 the email being marked negatively in some way (this might be via 1914 delivery to a special spam folder, modifying subject lines, or other 1915 locally determined means). Developing the details of such an 1916 approach have to be based on local conditions and requirements. 1917 Using SPF results in this way does not have the advantages of 1918 resource conservation and immediate feedback to the sender associated 1919 with SMTP rejection, but could produce fewer undesireable rejections 1920 in a well designed system. 1922 Either general approach can be used as they both leave a clear 1923 disposition of emails. They are either delivered in some manner or 1924 the sender is notified of the failure. Other dispositions such as 1925 "dropping" or deleting email after acceptance are inappropriate 1926 because they leave uncertainty and reduce the overall reliabilility 1927 and utility of email across the Internet. 1929 9.3.3. Policy For SPF Permerror 1931 The "permerror" result (see Section 2.5.7) indicates the SPF 1932 processing module at the receiver determined that the retrieved SPF 1933 policy record could not be interpreted. This gives no true 1934 indication about the authorized use of the data found in the 1935 envelope. 1937 As with all results, implementers have a choice to make regarding 1938 what to do with a message that yields this result. SMTP allows only 1939 a few basic options. 1941 Rejection of the message is an option, in that it is the one thing a 1942 receiver can do to draw attention to the difficulty encountered while 1943 protecting itself from messages that do not have a definite SPF 1944 result of some kind. However, if the SPF implementation is defective 1945 and returns spurious "permerror" results, only the sender is actively 1946 notified of the defect (in the form of rejected mail), and not the 1947 receiver making use of SPF. 1949 The less intrusive handling choice is to deliver the message, perhaps 1950 with some kind of annotation of the difficulty encountered and/or 1951 logging of a similar nature. However, this will not be desirable to 1952 operators that wish to implement SPF checking as strictly as 1953 possible, nor is this sort of passive problem reporting typically 1954 effective. 1956 There is of course the option placing this choice in the hands of the 1957 operator rather than the implementer since this kind of choice is 1958 often a matter of local policy rather than a condition with a 1959 universal solution, but this adds one more piece of complexity to an 1960 already non-trivial environment. 1962 Both implementers and operators need to be cautious of all choices 1963 and outcomes when handling SPF results. 1965 10. Security Considerations 1967 10.1. Processing Limits 1969 As with most aspects of email, there are a number of ways that 1970 malicious parties could use the protocol as an avenue for a 1971 Denial-of-Service (DoS) attack. The processing limits outlined in 1972 Section 4.6.4 are designed to prevent attacks such as the following: 1974 o A malicious party could create an SPF record with many references 1975 to a victim's domain and send many emails to different SPF 1976 clients; those SPF clients would then create a DoS attack. In 1977 effect, the SPF clients are being used to amplify the attacker's 1978 bandwidth by using fewer bytes in the SMTP session than are used 1979 by the DNS queries. Using SPF clients also allows the attacker to 1980 hide the true source of the attack. 1982 o Whereas implementations of check_host() are supposed to limit the 1983 number of DNS lookups, malicious domains could publish records 1984 that exceed these limits in an attempt to waste computation effort 1985 at their targets when they send them mail. Malicious domains 1986 could also design SPF records that cause particular 1987 implementations to use excessive memory or CPU usage, or to 1988 trigger bugs. 1990 o Malicious parties could send a large volume of mail purporting to 1991 come from the intended target to a wide variety of legitimate mail 1992 hosts. These legitimate machines would then present a DNS load on 1993 the target as they fetched the relevant records. 1995 Of these, the case of a third party referenced in the SPF record is 1996 the easiest for a DoS attack to effectively exploit. As a result, 1997 limits that might seem reasonable for an individual mail server can 1998 still allow an unreasonable amount of bandwidth amplification. 1999 Therefore, the processing limits need to be quite low. 2001 MTAs or other processors SHOULD impose a limit on the maximum amount 2002 of elapsed time to evaluate check_host(). Such a limit SHOULD allow 2003 at least 20 seconds. If such a limit is exceeded, the result of 2004 authorization SHOULD be "temperror". 2006 10.2. SPF-Authorized Email May Contain Other False Identities 2008 The RFC5321.MailFrom and RFC5321.HELO/.EHLO identity authorizations 2009 must not be construed to provide more assurance than they do. It is 2010 entirely possible for a malicious sender to inject a message using 2011 his own domain in the identities used by SPF, to have that domain's 2012 SPF record authorize the sending host, and yet the message can easily 2013 list other identities in its header. Unless the user or the MUA 2014 takes care to note that the authorized identity does not match the 2015 other more commonly-presented identities (such as the From: header 2016 field), the user might be lulled into a false sense of security. 2018 10.3. Spoofed DNS and IP Data 2020 There are two aspects of this protocol that malicious parties could 2021 exploit to undermine the validity of the check_host() function: 2023 o The evaluation of check_host() relies heavily on DNS. A malicious 2024 attacker could attack the DNS infrastructure and cause 2025 check_host() to see spoofed DNS data, and then return incorrect 2026 results. This could include returning "pass" for an value 2027 where the actual domain's record would evaluate to "fail". See 2028 [RFC3833] for a description of DNS weaknesses. 2030 o The client IP address, , is assumed to be correct. A 2031 malicious attacker could spoof TCP sequence numbers to make mail 2032 appear to come from a permitted host for a domain that the 2033 attacker is impersonating. 2035 10.4. Cross-User Forgery 2037 By definition, SPF policies just map domain names to sets of 2038 authorized MTAs, not whole email addresses to sets of authorized 2039 users. Although the "l" macro (Section 8) provides a limited way to 2040 define individual sets of authorized MTAs for specific email 2041 addresses, it is generally impossible to verify, through SPF, the use 2042 of specific email addresses by individual users of the same MTA. 2044 It is up to mail services and their MTAs to directly prevent 2045 cross-user forgery: based on SMTP AUTH ([RFC4954]), users should be 2046 restricted to using only those email addresses that are actually 2047 under their control (see [RFC6409], Section 6.1). Another means to 2048 verify the identity of individual users is message cryptography such 2049 as PGP ([RFC4880]) or S/MIME ([RFC5751]). 2051 10.5. Untrusted Information Sources 2053 An SPF compliant receiver gathers information from the SMTP commands 2054 it receives and from the published DNS records of the sending domain 2055 holder, (e.g., RFC5321.HELO/.EHLO domain name, the RFC5321.MailFrom 2056 address from the envelope, and SPF DNS records published by the 2057 domain holder). 2059 This information, passed to the receiver in the Received-SPF: trace 2060 fields, may be returned to the client MTA as an SMTP rejection 2061 message. If such an SMTP rejection message is generated, the 2062 information from the trace fields must be checked for such problems 2063 as invalid characters and excessively long lines. 2065 When the authorization check fails, an explanation string could be 2066 included in the reject response. Both the sender and the rejecting 2067 receiver need to be aware that the explanation was determined by the 2068 publisher of the SPF record checked and, in general, not the 2069 receiver. The explanation can contain malicious URLs, or it might be 2070 offensive or misleading. 2072 Explanations returned to sender domains due to "exp" modifiers, 2073 (Section 6.2), were generated by the sender policy published by the 2074 domain holders themselves. As long as messages are only returned 2075 with non-delivery notification ([RFC3464]) to domains publishing the 2076 explanation strings from their own DNS SPF records, the only affected 2077 parties are the original publishers of the domain's SPF records. 2079 In practice, such non-delivery notifications can be misdirected, such 2080 as when an MTA accepts an email and only later generates the 2081 notification to a forged address, or when an email forwarder does not 2082 direct the bounce back to the original sender. 2084 10.6. Privacy Exposure 2086 Checking SPF records causes DNS queries to be sent to the domain 2087 owner. These DNS queries, especially if they are caused by the 2088 "exists" mechanism, can contain information about who is sending 2089 email and likely to which MTA the email is being sent. This can 2090 introduce some privacy concerns, which are more or less of an issue 2091 depending on local laws and the relationship between the domain owner 2092 and the person sending the email. 2094 11. Contributors and Acknowledgements 2096 This document is largely based on the work of Meng Weng Wong, Mark 2097 Lentczner, and Wayne Schlitt. Although, as this section 2098 acknowledges, many people have contributed to this document, a very 2099 large portion of the writing and editing are due to Meng, Mark, and 2100 Wayne. 2102 This design owes a debt of parentage to [RMX] by Hadmut Danisch and 2103 to [DMP] by Gordon Fecyk. The idea of using a DNS record to check 2104 the legitimacy of an email address traces its ancestry further back 2105 through messages on the namedroppers mailing list by Paul Vixie 2106 [Vixie] (based on suggestion by Jim Miller) and by David Green 2107 [Green]. 2109 Philip Gladstone contributed the concept of macros to the 2110 specification, multiplying the expressiveness of the language and 2111 making per-user and per-IP lookups possible. 2113 The authors of both this document and [RFC4408] would also like to 2114 thank the literally hundreds of individuals who have participated in 2115 the development of this design. They are far too numerous to name, 2116 but they include the following: 2118 The participants in the SPFbis working group. 2119 The folks on the spf-discuss mailing list. 2120 The folks on the SPAM-L mailing list. 2121 The folks on the IRTF ASRG mailing list. 2122 The folks on the IETF MARID mailing list. 2123 The folks on #perl. 2125 12. IANA Considerations 2127 12.1. The SPF DNS Record Type 2129 Per [RFC4408], the IANA assigned the Resource Record Type and Qtype 2130 from the DNS Parameters Registry for the SPF RR type with code 99. 2131 The format of this type is identical to the TXT RR [RFC1035]. The 2132 character content of the record is encoded as [US-ASCII]. Use of 2133 this record type is obsolete for SPF Version 1. 2135 IANA is requested to add an annotation to the SPF RRTYPE saying 2136 "(OBSOLETE - use TXT)" in the DNS Parameters registry. 2138 [NOTE TO RFC EDITOR: (to be changed to " ... has added ..." upon 2139 publication)] 2141 12.2. The Received-SPF Mail Header Field 2143 Per [RFC3864], the "Received-SPF:" header field is added to the IANA 2144 Permanent Message Header Field Registry. The following is the 2145 registration template: 2147 Header field name: Received-SPF 2148 Applicable protocol: mail ([RFC5322]) 2149 Status: Standards Track 2150 Author/Change controller: IETF 2151 Specification document(s): RFC XXXX 2152 [NOTE TO RFC EDITOR: (this document)] 2154 12.3. SPF Modifier Registration 2156 [RFC6652] created a new SPF Modifier Registration. IANA is requested 2157 to change the reference for the exp and redirect modifiers from 2158 [RFC4408] to this document. Their status should not be changed. 2160 13. References 2162 13.1. Normative References 2164 [RFC1035] Mockapetris, P., "Domain names - implementation and 2165 specification", STD 13, RFC 1035, November 1987. 2167 [RFC1123] Braden, R., "Requirements for Internet Hosts - Application 2168 and Support", STD 3, RFC 1123, October 1989. 2170 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2171 Requirement Levels", BCP 14, RFC 2119, March 1997. 2173 [RFC3463] Vaudreuil, G., "Enhanced Mail System Status Codes", 2174 RFC 3463, January 2003. 2176 [RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration 2177 Procedures for Message Header Fields", BCP 90, RFC 3864, 2178 September 2004. 2180 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 2181 Resource Identifier (URI): Generic Syntax", STD 66, 2182 RFC 3986, January 2005. 2184 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing 2185 Architecture", RFC 4291, February 2006. 2187 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 2188 Specifications: ABNF", STD 68, RFC 5234, January 2008. 2190 [RFC5321] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 2191 October 2008. 2193 [RFC5322] Resnick, P., Ed., "Internet Message Format", RFC 5322, 2194 October 2008. 2196 [RFC5451] Kucherawy, M., "Message Header Field for Indicating 2197 Message Authentication Status", RFC 5451, April 2009. 2199 [RFC5598] Crocker, D., "Internet Mail Architecture", RFC 5598, 2200 July 2009. 2202 [RFC5890] Klensin, J., "Internationalized Domain Names for 2203 Applications (IDNA): Definitions and Document Framework", 2204 RFC 5890, August 2010. 2206 [US-ASCII] 2207 American National Standards Institute (formerly United 2208 States of America Standards Institute), "USA Code for 2209 Information Interchange, X3.4", 1968. 2211 ANSI X3.4-1968 has been replaced by newer versions with 2212 slight modifications, but the 1968 version remains 2213 definitive for the Internet. 2215 13.2. Informative References 2217 [DMP] Fecyk, G., "Designated Mailers Protocol". 2219 Work In Progress 2221 [Green] Green, D., "Domain-Authorized SMTP Mail", 2002. 2223 [RFC1034] Mockapetris, P., "Domain names - concepts and facilities", 2224 STD 13, RFC 1034, November 1987. 2226 [RFC1983] Malkin, G., "Internet Users' Glossary", RFC 1983, 2227 August 1996. 2229 [RFC2308] Andrews, M., "Negative Caching of DNS Queries (DNS 2230 NCACHE)", RFC 2308, March 1998. 2232 [RFC2782] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for 2233 specifying the location of services (DNS SRV)", RFC 2782, 2234 February 2000. 2236 [RFC3464] Moore, K. and G. Vaudreuil, "An Extensible Message Format 2237 for Delivery Status Notifications", RFC 3464, 2238 January 2003. 2240 [RFC3696] Klensin, J., "Application Techniques for Checking and 2241 Transformation of Names", RFC 3696, February 2004. 2243 [RFC3833] Atkins, D. and R. Austein, "Threat Analysis of the Domain 2244 Name System (DNS)", RFC 3833, August 2004. 2246 [RFC3834] Moore, K., "Recommendations for Automatic Responses to 2247 Electronic Mail", RFC 3834, August 2004. 2249 [RFC4408] Wong, M. and W. Schlitt, "Sender Policy Framework (SPF) 2250 for Authorizing Use of Domains in E-Mail, Version 1", 2251 RFC 4408, April 2006. 2253 [RFC4632] Fuller, V. and T. Li, "Classless Inter-domain Routing 2254 (CIDR): The Internet Address Assignment and Aggregation 2255 Plan", BCP 122, RFC 4632, August 2006. 2257 [RFC4880] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R. 2258 Thayer, "OpenPGP Message Format", RFC 4880, November 2007. 2260 [RFC4954] Siemborski, R. and A. Melnikov, "SMTP Service Extension 2261 for Authentication", RFC 4954, July 2007. 2263 [RFC5617] Allman, E., Fenton, J., Delany, M., and J. Levine, 2264 "DomainKeys Identified Mail (DKIM) Author Domain Signing 2265 Practices (ADSP)", RFC 5617, August 2009. 2267 [RFC5751] Ramsdell, B. and S. Turner, "Secure/Multipurpose Internet 2268 Mail Extensions (S/MIME) Version 3.2 Message 2269 Specification", RFC 5751, January 2010. 2271 [RFC5782] Levine, J., "DNS Blacklists and Whitelists", RFC 5782, 2272 February 2010. 2274 [RFC6409] Gellens, R. and J. Klensin, "Message Submission for Mail", 2275 STD 72, RFC 6409, November 2011. 2277 [RFC6647] Kucherawy, M. and D. Crocker, "Email Greylisting: An 2278 Applicability Statement for SMTP", RFC 6647, June 2012. 2280 [RFC6652] Kitterman, S., "Sender Policy Framework (SPF) 2281 Authentication Failure Reporting Using the Abuse Reporting 2282 Format", RFC 6652, June 2012. 2284 [RFC6686] Kucherawy, M., "Resolution of the Sender Policy Framework 2285 (SPF) and Sender ID Experiments", RFC 6686, July 2012. 2287 [RMX] Danisch, H., "The RMX DNS RR Type for light weight sender 2288 authentication". 2290 Work In Progress 2292 [Vixie] Vixie, P., "Repudiating MAIL FROM", 2002. 2294 Appendix A. Collected ABNF 2296 This section is normative and any discrepancies with the ABNF 2297 fragments in the preceding text are to be resolved in favor of this 2298 grammar. 2300 See [RFC5234] for ABNF notation. Please note that as per this ABNF 2301 definition, literal text strings (those in quotes) are case- 2302 insensitive. Hence, "mx" matches "mx", "MX", "mX", and "Mx". 2304 record = version terms *SP 2305 version = "v=spf1" 2307 terms = *( 1*SP ( directive / modifier ) ) 2309 directive = [ qualifier ] mechanism 2310 qualifier = "+" / "-" / "?" / "~" 2311 mechanism = ( all / include 2312 / A / MX / PTR / IP4 / IP6 / exists ) 2314 all = "all" 2315 include = "include" ":" domain-spec 2316 A = "a" [ ":" domain-spec ] [ dual-cidr-length ] 2317 MX = "mx" [ ":" domain-spec ] [ dual-cidr-length ] 2318 PTR = "ptr" [ ":" domain-spec ] 2319 IP4 = "ip4" ":" ip4-network [ ip4-cidr-length ] 2320 IP6 = "ip6" ":" ip6-network [ ip6-cidr-length ] 2321 exists = "exists" ":" domain-spec 2323 modifier = redirect / explanation / unknown-modifier 2324 redirect = "redirect" "=" domain-spec 2325 explanation = "exp" "=" domain-spec 2326 unknown-modifier = name "=" macro-string 2327 ; where name is not any known modifier 2329 ip4-cidr-length = "/" 1*DIGIT 2330 ip6-cidr-length = "/" 1*DIGIT 2331 dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ] 2333 ip4-network = qnum "." qnum "." qnum "." qnum 2334 qnum = DIGIT ; 0-9 2335 / %x31-39 DIGIT ; 10-99 2336 / "1" 2DIGIT ; 100-199 2337 / "2" %x30-34 DIGIT ; 200-249 2338 / "25" %x30-35 ; 250-255 2339 ; conventional dotted quad notation. e.g., 192.0.2.0 2340 ip6-network = 2341 ; e.g., 2001:DB8::CD30 2343 domain-spec = macro-string domain-end 2344 domain-end = ( "." toplabel [ "." ] ) / macro-expand 2346 toplabel = ( *alphanum ALPHA *alphanum ) / 2347 ( 1*alphanum "-" *( alphanum / "-" ) alphanum ) 2348 ; LDH rule plus additional TLD restrictions 2349 ; (see [RFC3696], Section 2 for background) 2350 alphanum = ALPHA / DIGIT 2352 explain-string = *( macro-string / SP ) 2354 macro-string = *( macro-expand / macro-literal ) 2355 macro-expand = ( "%{" macro-letter transformers *delimiter "}" ) 2356 / "%%" / "%_" / "%-" 2357 macro-literal = %x21-24 / %x26-7E 2358 ; visible characters except "%" 2359 macro-letter = "s" / "l" / "o" / "d" / "i" / "p" / "h" / 2360 "c" / "r" / "t" / "v" 2361 transformers = *DIGIT [ "r" ] 2362 delimiter = "." / "-" / "+" / "," / "/" / "_" / "=" 2364 name = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." ) 2366 header-field = "Received-SPF:" [CFWS] result FWS [comment FWS] 2367 [ key-value-list ] CRLF 2369 result = "pass" / "fail" / "softfail" / "neutral" / 2370 "none" / "temperror" / "permerror" 2372 key-value-list = key-value-pair *( ";" [CFWS] key-value-pair ) 2373 [";"] 2375 key-value-pair = key [CFWS] "=" ( dot-atom / quoted-string ) 2377 key = "client-ip" / "envelope-from" / "helo" / 2378 "problem" / "receiver" / identity / 2379 mechanism / name 2381 identity = "mailfrom" ; for the RFC5321.MailFrom identity 2382 / "helo" ; for the RFC5321.HELO/.EHLO identity 2383 / name ; other identities 2385 ALPHA = 2386 DIGIT = <0-9 as per [RFC5234]> 2387 SP = 2388 domain = 2389 dot-atom = 2390 quoted-string = 2391 comment = 2392 CFWS = 2393 FWS = 2394 CRLF = 2395 authserv-id = 2396 reasonspec = 2398 Appendix B. Extended Examples 2400 These examples are based on the following DNS setup: 2402 ; A domain with two mail servers, two hosts 2403 ; and two servers at the domain name 2404 $ORIGIN example.com. 2405 @ MX 10 mail-a 2406 MX 20 mail-b 2407 A 192.0.2.10 2408 A 192.0.2.11 2409 amy A 192.0.2.65 2410 bob A 192.0.2.66 2411 mail-a A 192.0.2.129 2412 mail-b A 192.0.2.130 2413 www CNAME example.com. 2415 ; A related domain 2416 $ORIGIN example.org. 2417 @ MX 10 mail-c 2418 mail-c A 192.0.2.140 2420 ; The reverse IP for those addresses 2421 $ORIGIN 2.0.192.in-addr.arpa. 2422 10 PTR example.com. 2423 11 PTR example.com. 2424 65 PTR amy.example.com. 2425 66 PTR bob.example.com. 2426 129 PTR mail-a.example.com. 2427 130 PTR mail-b.example.com. 2428 140 PTR mail-c.example.org. 2430 ; A rogue reverse IP domain that claims to be 2431 ; something it's not 2432 $ORIGIN 0.0.10.in-addr.arpa. 2433 4 PTR bob.example.com. 2435 B.1. Simple Examples 2437 These examples show various possible published records for 2438 example.com and which values if would cause check_host() to 2439 return "pass". Note that is "example.com". 2441 v=spf1 +all 2442 -- any passes 2444 v=spf1 a -all 2445 -- hosts 192.0.2.10 and 192.0.2.11 pass 2447 v=spf1 a:example.org -all 2448 -- no sending hosts pass since example.org has no A records 2450 v=spf1 mx -all 2451 -- sending hosts 192.0.2.129 and 192.0.2.130 pass 2453 v=spf1 mx:example.org -all 2454 -- sending host 192.0.2.140 passes 2456 v=spf1 mx mx:example.org -all 2457 -- sending hosts 192.0.2.129, 192.0.2.130, and 192.0.2.140 pass 2459 v=spf1 mx/30 mx:example.org/30 -all 2460 -- any sending host in 192.0.2.128/30 or 192.0.2.140/30 passes 2462 v=spf1 ptr -all 2463 -- sending host 192.0.2.65 passes (reverse DNS is valid and is in 2464 example.com) 2465 -- sending host 192.0.2.140 fails (reverse DNS is valid, but not 2466 in example.com) 2467 -- sending host 10.0.0.4 fails (reverse IP is not valid) 2469 v=spf1 ip4:192.0.2.128/28 -all 2470 -- sending host 192.0.2.65 fails 2471 -- sending host 192.0.2.129 passes 2473 B.2. Multiple Domain Example 2475 These examples show the effect of related records: 2477 example.org: "v=spf1 include:example.com include:example.net -all" 2479 This record would be used if mail from example.org actually came 2480 through servers at example.com and example.net. Example.org's 2481 designated servers are the union of example.com's and example.net's 2482 designated servers. 2484 la.example.org: "v=spf1 redirect=example.org" 2485 ny.example.org: "v=spf1 redirect=example.org" 2486 sf.example.org: "v=spf1 redirect=example.org" 2488 These records allow a set of domains that all use the same mail 2489 system to make use of that mail system's record. In this way, only 2490 the mail system's record needs to be updated when the mail setup 2491 changes. These domains' records never have to change. 2493 B.3. DNSBL Style Example 2495 Imagine that, in addition to the domain records listed above, there 2496 are these: 2498 $ORIGIN _spf.example.com. 2499 mary.mobile-users A 127.0.0.2 2500 fred.mobile-users A 127.0.0.2 2501 15.15.168.192.joel.remote-users A 127.0.0.2 2502 16.15.168.192.joel.remote-users A 127.0.0.2 2504 The following records describe users at example.com who mail from 2505 arbitrary servers, or who mail from personal servers. 2507 example.com: 2509 v=spf1 mx 2510 include:mobile-users._spf.%{d} 2511 include:remote-users._spf.%{d} 2512 -all 2514 mobile-users._spf.example.com: 2516 v=spf1 exists:%{l1r+}.%{d} 2518 remote-users._spf.example.com: 2520 v=spf1 exists:%{ir}.%{l1r+}.%{d} 2522 B.4. Multiple Requirements Example 2524 Say that your sender policy requires both that the IP address is 2525 within a certain range and that the reverse DNS for the IP matches. 2526 This can be done several ways, including the following: 2528 example.com. SPF ( "v=spf1 " 2529 "-include:ip4._spf.%{d} " 2530 "-include:ptr._spf.%{d} " 2531 "+all" ) 2532 ip4._spf.example.com. SPF "v=spf1 -ip4:192.0.2.0/24 +all" 2533 ptr._spf.example.com. SPF "v=spf1 -ptr +all" 2535 This example shows how the "-include" mechanism can be useful, how an 2536 SPF record that ends in "+all" can be very restrictive, and the use 2537 of De Morgan's Law. 2539 Appendix C. Change History 2541 Changes since RFC 4408 (to be removed prior to publication) 2543 Moved to standards track 2545 Authors updated 2547 IESG Note regarding experimental use replaced with discussion of 2548 results 2550 Process errata: 2552 Add %v macro to ABNF grammar 2554 Replace "uric" by "unreserved" 2556 Recommend an SMTP reply code for optional permerror rejections 2558 Correct syntax in Received-SPF examples 2560 Fix unknown-modifier clause is too greedy in ABNF 2562 Correct use of empty domain-spec on exp modifier 2564 Fix minor typo errata 2566 Convert to spfbis working group draft, 2567 draft-ietf-spfbis-4408bis-00 2569 Addressed Ticket #1, RFC 4408 Section 2.5.6 - Temporary errors by 2570 giving the option to turn repeated SERVFAIL into permerror and 2571 adding RFC 2308 reference. 2573 Clarified text about IPv4 mapped addresses to resolve test suite 2574 ambiguity 2576 Clarified ambiguity about result when more than 10 "mx" or "ptr" 2577 records are returned for lookup to specify permerror. This 2578 resolves one of the test suite ambiguities 2580 Made all references to result codes lower case per issue #7 2582 Adjusted section 2.2 Requirement to check mail from per issue #15 2584 Added missing "v" element in macro-letter in the collected ABNF 2585 per issue #16 - section 8.1 was already fixed in the pre-WG draft 2586 Marked ptr and "p" macro deprecated/SHOULD NOT use per issue #27 2588 Expunged lower case may from the draft per issue #8 2590 Expunged "x-" name as an obsolete concept 2592 Updated obslete references: RFC2821 to RFC5321, RFC2822 to 2593 RFC5322, and RFC4234 to RFC5234 2595 Refer to RFC6647 to describe greylisting instead of trying to 2596 describe it directly. 2598 Updated informative references to the current versions. 2600 Added definition for deprecated since there are questions. 2602 Start to rework section 9 with some RFC5598 terms. 2604 Added mention of RFC 6552 feedback reports in section 9. 2606 Added draft-ietf-spfbis-experiment as an informational reference. 2608 Drop Type SPF. 2610 Try and clarify informational nature of RFC3696 2612 Fix ABNF nits and add missing definitions per Bill's ABNF checker. 2614 Make DNS lookup time limit SHOULD instead of MAY. 2616 Reorganize and clarify processing limits. Move hard limits to new 2617 section 4.6.4, Evaluation Limits. Move advice to non-normative 2618 section 9. 2620 Removed paragraph in section 10.1 about limiting total data 2621 volumes as it is unused (and removable per the charter) and serves 2622 no purpose (it isn't something that actually can be implemented in 2623 any reasonable way). 2625 Added text and figures from Alessandro Vesely in section 9.1 to 2626 better explain DNS resource limits. 2628 Multiple editorial fixes from Murray Kucherawy's review. 2630 Also based on Murray's review, reworked SMTP identity definitions 2631 and made RFC 5598 a normative reference instead of informative. 2632 This is a downref that will have to be mentioned in the last call. 2634 Added RFC 3834 as an informative reference about backscatter. 2636 Added IDN requirements and normative reference to RFC 5890 to deal 2637 with the question "like DKIM did it.: 2639 Added informative reference to RFC 4632 for CIDR and use CIDR 2640 prefix length instead of CIDR-length to match its terminology. 2642 Added RFC 5782 informative reference on DNSxLs to support 2643 improving the exists description. 2645 Added text on creating a Authentication-Results header field that 2646 matches the Received-SPF header field information and added a 2647 normative reference to RFC 5451. 2649 Added informative reference to RFC 2782 due to SRV mention. 2651 Added informative reference to RFC 3464 due to DSN mention. 2653 Added informative reference to RFC 5617 for it's DNS wildcard use. 2655 Added informative reference to RFC 5782 to enhance the explanation 2656 of how the exists mechanism works. Clarified the intended match/ 2657 no-match method. 2659 Added new sections on Receiver policy for SPF pass, fail, and 2660 permerror. 2662 Added new section 9 discussion on treatment of bounces and the 2663 significance of HELO records. 2665 Added request to IANA to update the SPF modifier registry. 2667 Author's Address 2669 Scott Kitterman 2670 Kitterman Technical Services 2671 3611 Scheel Dr 2672 Ellicott City, MD 21042 2673 United States of America 2675 Email: scott@kitterman.com