idnits 2.17.1 draft-ietf-spfbis-4408bis-08.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 6 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 1367 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 (October 22, 2012) is 4196 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 2400, 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) October 22, 2012 5 Intended status: Standards Track 6 Expires: April 25, 2013 8 Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, 9 Version 1 10 draft-ietf-spfbis-4408bis-08.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 "MAIL FROM" of a message or the domain given on 17 the SMTP HELO/EHLO commands. This document describes version 1 of 18 the Sender Policy Framework (SPF) protocol, whereby an ADMD can 19 explicitly authorize the hosts that are allowed to use its domain 20 names, 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 April 25, 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 "HELO" Identity . . . . . . . . . . . . . . . . . . . 9 81 2.2. The "MAIL FROM" 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 . . . . . . . . . . . . . . . . . . . . 18 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 . . . . . . . . . . . 44 136 9.2.3. Mail Services . . . . . . . . . . . . . . . . . . . . 46 137 9.2.4. MTA Relays . . . . . . . . . . . . . . . . . . . . . . 46 138 9.3. Receivers . . . . . . . . . . . . . . . . . . . . . . . . 47 139 9.3.1. Policy For SPF Pass . . . . . . . . . . . . . . . . . 47 140 9.3.2. Policy For SPF Fail . . . . . . . . . . . . . . . . . 47 141 9.3.3. Policy For SPF Permerror . . . . . . . . . . . . . . . 48 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.5.1. Recorded Results . . . . . . . . . . . . . . . . . . . 50 149 10.5.2. External Explanations . . . . . . . . . . . . . . . . 51 150 10.5.3. Macro Expansion . . . . . . . . . . . . . . . . . . . 51 151 10.6. Privacy Exposure . . . . . . . . . . . . . . . . . . . . . 51 152 11. Contributors and Acknowledgements . . . . . . . . . . . . . . 52 153 12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 53 154 12.1. The SPF DNS Record Type . . . . . . . . . . . . . . . . . 53 155 12.2. The Received-SPF Mail Header Field . . . . . . . . . . . . 53 156 12.3. SPF Modifier Registration . . . . . . . . . . . . . . . . 53 157 13. References . . . . . . . . . . . . . . . . . . . . . . . . . . 54 158 13.1. Normative References . . . . . . . . . . . . . . . . . . . 54 159 13.2. Informative References . . . . . . . . . . . . . . . . . . 55 160 Appendix A. Collected ABNF . . . . . . . . . . . . . . . . . . . 57 161 Appendix B. Extended Examples . . . . . . . . . . . . . . . . . . 60 162 B.1. Simple Examples . . . . . . . . . . . . . . . . . . . . . 60 163 B.2. Multiple Domain Example . . . . . . . . . . . . . . . . . 61 164 B.3. DNSBL Style Example . . . . . . . . . . . . . . . . . . . 62 165 B.4. Multiple Requirements Example . . . . . . . . . . . . . . 62 166 Appendix C. Change History . . . . . . . . . . . . . . . . . . . 63 167 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 66 169 1. Introduction 171 The current email infrastructure has the property that any host 172 injecting mail into the system can use any DNS domain name it wants 173 in each of the various identifiers specified by [RFC5321] and 174 [RFC5322]. Although this feature is desirable in some circumstances, 175 it is a major obstacle to reducing Unsolicited Bulk Email (UBE, aka 176 spam). Furthermore, many domain owning ADMDs (ADministrative 177 Management Domains, see [RFC5598]) are understandably concerned about 178 the ease with which other entities can make use of their domain 179 names, often with malicious intent. 181 This document defines a protocol by which ADMDs can authorize hosts 182 to use their domain names in the "MAIL FROM" or "HELO" identities. 183 Compliant ADMDs publish Sender Policy Framework (SPF) records in the 184 DNS specifying which hosts are permitted to use their names, and 185 compliant mail receivers use the published SPF records to test the 186 authorization of sending Mail Transfer Agents (MTAs) using a given 187 "HELO" or "MAIL FROM" identity 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 [RFC4408] was designed to clearly document the protocol defined by 208 earlier draft specifications of SPF as used in existing 209 implementations. This updated specification is intended to clarify 210 identified ambiguities in [RFC4408], resolve techincal issues 211 identified in post-RFC 4408 deplyment experience, and document widely 212 deployed extensions to SPF that have been developed since [RFC4408] 213 was published. 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", "MAIL FROM", or RFC5321.MailFrom. 256 Since these terms are either not well defined or often used casually, 257 this document uses "MAIL FROM" for consistency. This means the 258 RFC5321.MailFrom as defined in [RFC5598]. Note that other terms that 259 might superficially look like the common terms, such as "reverse- 260 path", are used only with the defined meanings from normative 261 documents. 263 1.3.4. HELO Definition 265 This document also makes use of the HELO/EHLO identity. The "HELO" 266 identity derives from either the SMTP HELO or EHLO command (see 267 [RFC5321]). Since HELO and EHLO can, in many cases, be used 268 interchangeably, they are identified commonly as "HELO" in this 269 document. This means RFC5321.HELO/.EHLO as defined in [RFC5598]. 270 These commands supply the identity of the SMTP client (sending host) 271 for the SMTP session. 273 1.3.5. Deprecated 275 There are [RFC4408] features that are marked "deprecated". In the 276 context of this document, deprecated means that senders SHOULD NOT 277 publish SPF records that make use of such features because they might 278 be removed entirely in future updates to the protocol. Such features 279 do, however, remain part of the SPF protocol and receiving systems 280 MUST support them unless this document explicitly says otherwise. 282 2. Operation 284 2.1. The "HELO" Identity 286 It is RECOMMENDED that SPF verifiers not only check the "MAIL FROM" 287 identity, but also separately check the "HELO" identity by applying 288 the check_host() function (Section 4) to the "HELO" identity as the 289 . Checking "HELO" promotes consistency of results and can 290 reduce DNS resource usage. Additionally, since SPF records published 291 for "HELO" identities refer to a single host, when available, they 292 are a very reliable source of host authorization 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 verifiers 296 MUST be prepared for the "HELO" identity to be malformed or an IP 297 address literal. This SPF check can only be performed when the 298 "HELO" string is a valid fully qualified domain. 300 2.2. The "MAIL FROM" Identity 302 SPF verifiers MUST check the ""MAIL FROM" identity if a completed 303 "HELO" check has not reached a definitive policy result by applying 304 the check_host() function to the "MAIL FROM" identity as the 305 . 307 [RFC5321] allows the reverse-path to be null (see Section 4.5.5 in 308 [RFC5321]). In this case, there is no explicit sender mailbox, and 309 such a message can be assumed to be a notification message from the 310 mail system itself. When the reverse-path is null, this document 311 defines the "MAIL FROM" identity to be the mailbox composed of the 312 local-part "postmaster" and the "HELO" identity (which might or might 313 not have been checked separately before). 315 2.3. Publishing Authorization 317 An SPF-compliant domain MUST have valid SPF records as described in 318 Section 3. These records authorize the use of the relevant domain 319 names in the "HELO" and "MAIL FROM" identities by the MTAs specified 320 therein. 322 SPF results can be used to make both positive (source is authorized) 323 and negative (source is not authorized) determinations. If domain 324 owners choose to publish SPF records and want to support receivers 325 making negative authorization determinations, then they MUST publish 326 records that end in "-all", or redirect to other records that do, 327 otherwise, no definitive determination of authorization can be made. 328 Potential issues and mitigations associated with negative 329 determinations are discussed in Section 9. 331 ADMDs can publish SPF records that explicitly authorize no hosts for 332 domain names that are neither used in the domain part of email 333 addresses nor expected to originate mail. 335 When changing SPF records, care has to be taken to ensure that there 336 is a transition period so that the old policy remains valid until all 337 legitimate email can reasonably expect to have been checked. This 338 can be as much as 30 days. 340 2.4. Checking Authorization 342 A mail receiver can perform a set of SPF checks for each mail message 343 it receives. An SPF check tests the authorization of a client host 344 to emit mail with a given identity. Typically, such checks are done 345 by a receiving MTA, but can be performed elsewhere in the mail 346 processing chain so long as the required information is available and 347 reliable. At least the "MAIL FROM" identity MUST be checked, but it 348 is RECOMMENDED that the "HELO" identity also be checked beforehand. 350 Without explicit approval of the domain owner, checking other 351 identities against SPF version 1 records is NOT RECOMMENDED because 352 there are cases that are known to give incorrect results. For 353 example, almost all mailing lists rewrite the "MAIL FROM" identity 354 (see Section 9.2.1), but some do not change any other identities in 355 the message. The scenario described in Section 9.2.2, sub-section 356 1.2, is another example. Documents that define other identities will 357 have to define the method for explicit approval. 359 It is possible that mail receivers will use the SPF check as part of 360 a larger set of tests on incoming mail. The results of other tests 361 might influence whether or not a particular SPF check is performed. 362 For example, finding the sending host's IP address on a local white 363 list might cause all other tests to be skipped and all mail from that 364 host to be accepted. 366 When a mail receiver decides to perform an SPF check, it MUST use a 367 correctly-implemented check_host() function (Section 4) evaluated 368 with the correct parameters. Although the test as a whole is 369 optional, once it has been decided to perform a test it has to be 370 performed as specified so that the correct semantics are preserved 371 between publisher and receiver. 373 To make the test, the mail receiver MUST evaluate the check_host() 374 function with the arguments set as follows: 376 - the IP address of the SMTP client that is emitting the 377 mail, either IPv4 or IPv6. 379 - the domain portion of the "MAIL FROM" or "HELO" identity. 381 - the "MAIL FROM" or "HELO" 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 "MAIL FROM". Rejecting email will prevent one 393 method of circumventing of SPF records. 395 Implementations have to take care to correctly extract the 396 from 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 interprets 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. This is further discussed in 445 Section 9.3.1. 447 2.5.4. Fail 449 A "fail" result is an explicit statement that the client is not 450 authorized to use the domain in the given identity. Disposition of 451 SPF fail messages is a matter of local policy. See Section 9.3.2 for 452 considerations on developing local policy. 454 If the checking software chooses to reject the mail during the SMTP 455 transaction, then it SHOULD use an SMTP reply code of 550 (see 456 [RFC5321]) and, if supported, the 5.7.1 enhanced status code (see 457 [RFC3463]), in addition to an appropriate reply text. The 458 check_host() function will return either a default explanation string 459 or one from the domain that published the SPF records (see 460 Section 6.2). If the information does not originate with the 461 checking software, it is good to make it clear that the text is 462 provided by the sender's domain. For example: 464 550-5.7.1 SPF MAIL FROM check failed: 465 550-5.7.1 The domain example.com explains: 466 550 5.7.1 Please see http://www.example.com/mailpolicy.html 468 If the checking software chooses not to reject the mail during the 469 SMTP transaction, then it SHOULD add a Received-SPF or 470 Authentication-Results header field (see Section 7) to communicate 471 this result to downstream message processors. While this is true for 472 all SPF results, it is of particular importance for "fail" results 473 since the message is explicitly not authorized by the domain owner. 475 2.5.5. Softfail 477 A "softfail" result ought to be treated as somewhere between "fail" 478 and "neutral"/"none". The domain owner believes the host is not 479 authorized but is not willing to make a strong policy statement. 480 Receiving software SHOULD NOT reject the message based solely on this 481 result, but MAY subject the message to closer scrutiny than normal. 483 The domain owner wants to discourage the use of this host and thus 484 desires limited feedback when a "softfail" result occurs. For 485 example, the recipient's Mail User Agent (MUA) could highlight the 486 "softfail" status, or the receiving MTA could give the sender a 487 message using greylisting, [RFC6647], with a note the first time the 488 message is received, but accept it on a later attempt based on 489 receiver policy. 491 2.5.6. Temperror 493 A "temperror" result means the SPF verifier encountered a transient 494 (generally DNS) error while performing the check. Checking software 495 can choose to accept or temporarily reject the message. If the 496 message is rejected during the SMTP transaction for this reason, the 497 software SHOULD use an SMTP reply code of 451 and, if supported, the 498 4.4.3 enhanced status code. These errors can be caused by problems 499 in either the sender's or receiver's DNS software. 501 2.5.7. Permerror 503 A "permerror" result means the domain's published records could not 504 be correctly interpreted. This signals an error condition that 505 definitely requires manual intervention to be resolved. If the 506 message is rejected during the SMTP transaction for this reason, the 507 software SHOULD use an SMTP reply code of 550 and, if supported, the 508 5.5.2 enhanced status code. Be aware that if the domain owner uses 509 macros (Section 8), it is possible that this result is due to the 510 checked identities having an unexpected format. It is also possible 511 that this result is generated by certain SPF clients due to the input 512 arguments having an unexpected format; see Section 4.8. 514 3. SPF Records 516 An SPF record is a DNS record that declares which hosts are, and are 517 not, authorized to use a domain name for the "HELO" and "MAIL FROM" 518 identities. Loosely, the record partitions all hosts into permitted 519 and not-permitted sets (though some hosts might fall into neither 520 category). 522 The SPF record is a single string of text. The record format is 523 described below in Section 4. An example record is the following: 525 v=spf1 +mx a:colo.example.com/28 -all 527 This record has a version of "spf1" and three directives: "+mx", 528 "a:colo.example.com/28" (the + is implied), and "-all". 530 Each SPF record is placed in the DNS tree at the host name it 531 pertains to, not a subdomain under it, such as is done with SRV 532 records [RFC2782]. 534 The example in this section might be published via these lines in a 535 domain zone file: 537 example.com. TXT "v=spf1 +mx a:colo.example.com/28 -all" 538 smtp-out.example.com. TXT "v=spf1 a -all" 540 Since TXT records have multiple uses, beware of other TXT records 541 published there for other purposes. They might cause problems with 542 size limits (see Section 3.4) and care has to be taken to ensure only 543 SPF records are used for SPF processing. 545 ADMDs publishing SPF records SHOULD try to keep the number of 546 "include" mechanisms and chained "redirect" modifiers to a minimum. 547 ADMDs SHOULD also try to minimize the amount of other DNS information 548 needed to evaluate a record. Section 4.6.4 and Section 9.1.1 provide 549 some suggestions on how to achieve this. 551 3.1. DNS Resource Records 553 SPF records MUST be published as a DNS TXT (type 16) Resource Record 554 (RR) [RFC1035] only. The character content of the record is encoded 555 as [US-ASCII]. Use of alternate DNS RR types was supported in SPF's 556 experimental phase, but has been discontinued. See Appendix A of 557 [RFC6686] for further information. 559 3.2. Multiple DNS Records 561 A domain name MUST NOT have multiple records that would cause an 562 authorization check to select more than one record. See Section 4.5 563 for the selection rules. 565 3.3. Multiple Strings in a Single DNS record 567 As defined in [RFC1035] sections 3.3.14 and 3.3, a single text DNS 568 record can be composed of more than one string. If a published 569 record contains multiple character-strings, then the record MUST be 570 treated as if those strings are concatenated together without adding 571 spaces. For example: 573 IN TXT "v=spf1 .... first" "second string..." 575 MUST be treated as equivalent to 577 IN TXT "v=spf1 .... firstsecond string..." 579 TXT records containing multiple strings are useful in constructing 580 records that would exceed the 255-byte maximum length of a character- 581 string within a single TXT record. 583 3.4. Record Size 585 The published SPF record for a given domain name SHOULD remain small 586 enough that the results of a query for it will fit within 512 octets. 587 This UDP limit is defined in [RFC1035] section 2.3.4. This will keep 588 even older DNS implementations from falling over to TCP. Since the 589 answer size is dependent on many things outside the scope of this 590 document, it is only possible to give this guideline: If the combined 591 length of the DNS name and the text of all the records of a given 592 type is under 450 characters, then DNS answers ought to fit in UDP 593 packets. Note that when computing the sizes for queries of the TXT 594 format, one has to take into account any other TXT records published 595 at the domain name. Records that are too long to fit in a single UDP 596 packet could be silently ignored by SPF verifiers due to firewall and 597 other issues that cause DNS over TCP to be less reliable than DNS 598 over UDP. 600 3.5. Wildcard Records 602 Use of wildcard records for publishing is discouraged and care has to 603 be taken if they are used. If a zone includes wildcard MX records, 604 it might want to publish wildcard declarations, subject to the same 605 requirements and problems. In particular, the declaration MUST be 606 repeated for any host that has any RR records at all, and for 607 subdomains thereof. Consider the example in [RFC1034], Section 608 4.3.3. Based on that, we can do the following: 610 EXAMPLE.COM. MX 10 A.EXAMPLE.COM 611 EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all" 613 *.EXAMPLE.COM. MX 10 A.EXAMPLE.COM 614 *.EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all" 616 A.EXAMPLE.COM. A 203.0.113.1 617 A.EXAMPLE.COM. MX 10 A.EXAMPLE.COM 618 A.EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all" 620 *.A.EXAMPLE.COM. MX 10 A.EXAMPLE.COM 621 *.A.EXAMPLE.COM. TXT "v=spf1 a:A.EXAMPLE.COM -all" 623 SPF records have to be listed twice for every name within the zone: 624 once for the name, and once with a wildcard to cover the tree under 625 the name, in order to cover all domains in use in outgoing mail. 627 4. The check_host() Function 629 This description is not an API (Application Program Interface) 630 definition, but rather a function description used to illustrate the 631 algorithm. A compliant SPF implementation MUST do something 632 semantically equivalent to this description. 634 The check_host() function fetches SPF records, parses them, and 635 evaluates them to determine whether a particular host is or is not 636 permitted to send mail with a given identity. Mail receivers that 637 perform this check MUST correctly evaluate the check_host() function 638 as described here. 640 Implementations MAY use a different algorithm than the canonical 641 algorithm defined here, so long as the results are the same in all 642 cases. 644 4.1. Arguments 646 The check_host() function takes these arguments: 648 - the IP address of the SMTP client that is emitting the 649 mail, either IPv4 or IPv6. 651 - the domain that provides the sought-after authorization 652 information; initially, the domain portion of the "MAIL 653 FROM" or "HELO" identity. 655 - the "MAIL FROM" or "HELO" identity. 657 The domain portion of will usually be the same as the 658 argument when check_host() is initially evaluated. However, 659 this will generally not be true for recursive evaluations (see 660 Section 5.2 below). 662 4.2. Results 664 The function check_host() can return one of several results described 665 in Section 2.5. Based on the result, the action to be taken is 666 determined by the local policies of the receiver. 668 4.3. Initial Processing 670 If the is malformed (e.g. label longer than 63 characters, 671 zero-length label not at the end, etc.) or is not a fully qualified 672 domain name, or if the DNS lookup returns "domain does not exist" 673 (RCODE 3), check_host() immediately returns the result "none". 674 Properly formed domains are fully qualified email domains as 675 described in [RFC5321] Section 2.3.5. Internationalized domain names 676 MUST be encoded as A-labels, as described in Section 2.3 of 677 [RFC5890].on 2.3 of [RFC5890]. 679 If the has no local-part, substitute the string "postmaster" 680 for the local-part. 682 4.4. Record Lookup 684 In accordance with how the records are published (see Section 3 685 above), a DNS query needs to be made for the name, querying 686 for type TXT only. 688 If all DNS lookups that are made return a server failure (RCODE 2), 689 or other error (RCODE other than 0 or 3), or time out, then 690 check_host() terminates immediately with the result "temperror". 691 Alternatively, for a server failure (RCODE 2) result, check_host() 692 MAY track failures and treat multiple failures within 24 hours for 693 the same domain as "permerror". 695 This alternative is intended to shorten the queue time of messages 696 that cannot be accepted, by returning a permanent negative completion 697 reply code to the client, instead of a transient one. [RFC2308] 698 suggests on an algorithm for doing such tracking and handling of 699 server failure codes. 701 4.5. Selecting Records 703 Records begin with a version section: 705 record = version terms *SP 706 version = "v=spf1" 708 Starting with the set of records that were returned by the lookup, 709 discard records that do not begin with a version section of exactly 710 "v=spf1". Note that the version section is terminated either by an 711 SP character or the end of the record. A record with a version 712 section of "v=spf10" does not match and MUST be discarded. 714 If the resultant record set includes no records, check_host() 715 produces the "none" result. If the resultant record set includes 716 more than one record, check_host() produces the "permerror" result. 718 4.6. Record Evaluation 720 The check_host() function parses and interprets the SPF record to 721 find a result for the current test. If there are any syntax errors, 722 check_host() returns immediately with 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 return 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 returns 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 cause any DNS query to at most 10 during SPF 799 evaluation. Specifically, the "include", "a", "mx", "ptr", and 800 "exists" mechanisms as well as the "redirect" modifier count against 801 this limit. The "all", "ip4", and "ip6" mechanisms do not count 802 against this limit. If this number is exceeded during a check, a 803 permerror MUST be returned. The "exp" modifier does not count 804 against this limit because the DNS lookup to fetch the explanation 805 string occurs 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 MTAs or other processors SHOULD impose a limit on the maximum amount 815 of elapsed time to evaluate check_host(). Such a limit SHOULD allow 816 at least 20 seconds. If such a limit is exceeded, the result of 817 authorization SHOULD be "temperror". 819 4.7. Default Result 821 If none of the mechanisms match and there is no "redirect" modifier, 822 then the check_host() returns a result of "neutral", just as if 823 "?all" were specified as the last directive. If there is a 824 "redirect" modifier, check_host() proceeds as defined in Section 6.1. 826 Note that records SHOULD always use either a "redirect" modifier or 827 an "all" mechanism to explicitly terminate processing. Although the 828 latter has default (specifically "?all"), it aids debugging efforts 829 if it is explicitly included. 831 For example: 833 v=spf1 +mx -all 834 or 835 v=spf1 +mx redirect=_spf.example.com 837 4.8. Domain Specification 839 Several of these mechanisms and modifiers have a domain-spec section. 840 The domain-spec string is subject to macro expansion (see Section 8). 841 The resulting string is the common presentation form of a fully- 842 qualified DNS name: a series of labels separated by periods. This 843 domain is called the in the rest of this document. 845 Note: The result of the macro expansion is not subject to any further 846 escaping. Hence, this facility cannot produce all characters that 847 are legal in a DNS label (e.g., the control characters). However, 848 this facility is powerful enough to express legal host names and 849 common utility labels (such as "_spf") that are used in DNS. 851 For several mechanisms, the is optional. If it is not 852 provided, the is used as the . Domain and 853 domain-spec are syntactically identical after macro expansion. 854 Domain is an input value for check_host() while domain-spec is 855 computed by check_host(). 857 Note: Historically, this document has made no provisions for how to 858 handle domain-specs, or macro-expansions thereof, that are 859 syntactically invalid per [RFC1035], such as names with empty labels 860 (e.g., "foo..example.com") or overlong labels (more than 63 861 characters). Some implementations choose to treat as a no-match 862 mechanisms, and ignore modifiers, with such names, whereas others 863 return a "permerror" exception. The outcome for an unexpected 864 domain-spec without macros might even differ from that for an 865 unexpected target-name after macro expansion. 867 5. Mechanism Definitions 869 This section defines two types of mechanisms. 871 Basic mechanisms contribute to the language framework. They do not 872 specify a particular type of authorization scheme. 874 all 875 include 877 Designated sender mechanisms are used to designate a set of 878 addresses as being permitted or not permitted to use the for 879 sending mail. 881 a 882 mx 883 ptr (deprecated) 884 ip4 885 ip6 886 exists 888 The following conventions apply to all mechanisms that perform a 889 comparison between and an IP address at any point: 891 If no CIDR prefix length is given in the directive, then and the 892 IP address are compared for equality. (Here, CIDR is Classless 893 Inter-Domain Routing, described in [RFC4632].) 895 If a CIDR prefix length is specified, then only the specified number 896 of high-order bits of and the IP address are compared for 897 equality. 899 When any mechanism fetches host addresses to compare with , when 900 is an IPv4 address, A records are fetched; when is an IPv6 901 address, AAAA records are fetched. Even if the SMTP connection uses 902 IPv6, an IPv4-mapped IPv6 IP address (see [RFC4291], Section 2.5.5) 903 MUST still be considered an IPv4 address and MUST be evaluated using 904 IPv4 mechanisms (i.e. "ip4" and "a"). 906 Several mechanisms rely on information fetched from the DNS. For 907 these DNS queries, except where noted, if the DNS server returns an 908 error (RCODE other than 0 or 3) or the query times out, the mechanism 909 stops and the topmost check_host() returns "temperror". If the 910 server returns "domain does not exist" (RCODE 3), then evaluation of 911 the mechanism continues as if the server returned no error (RCODE 0) 912 and zero answer records. 914 5.1. "all" 916 all = "all" 918 The "all" mechanism is a test that always matches. It is used as the 919 rightmost mechanism in a record to provide an explicit default. 921 For example: 923 v=spf1 a mx -all 925 Mechanisms after "all" will never be tested. Mechanisms listed after 926 "all" MUST be ignored. Any "redirect" modifier (Section 6.1) MUST be 927 ignored when there is an "all" mechanism in the record. 929 5.2. "include" 931 include = "include" ":" domain-spec 933 The "include" mechanism triggers a recursive evaluation of 934 check_host(). 936 1. The domain-spec is expanded as per Section 8. 938 2. Check_host() is evaluated with the resulting string as the 939 . The and arguments remain the same as in 940 the current evaluation of check_host(). 942 3. The recursive evaluation returns either match, not match, or an 943 error. If it matches, then the appropriate result for the 944 include: mechanism is used (e.g. include or +include gives a 945 "pass" result and -include gives "fail). 947 4. If there is no match, the parent check_host() resumes processing 948 as per the table below, with the previous value of 949 restored. 951 In hindsight, the name "include" was poorly chosen. Only the 952 evaluated result of the referenced SPF record is used, rather than 953 acting as if the referenced SPF record was literally included in the 954 first. For example, evaluating a "-all" directive in the referenced 955 record does not terminate the overall processing and does not 956 necessarily result in an overall "fail". (Better names for this 957 mechanism would have been "if-match", "on-match", etc.) 959 The "include" mechanism makes it possible for one domain to designate 960 multiple administratively-independent domains. For example, a vanity 961 domain "example.net" might send mail using the servers of 962 administratively-independent domains example.com and example.org. 964 Example.net could say 966 IN TXT "v=spf1 include:example.com include:example.org -all" 968 This would direct check_host() to, in effect, check the records of 969 example.com and example.org for a "pass" result. Only if the host 970 were not permitted for either of those domains would the result be 971 "fail". 973 Whether this mechanism matches, does not match, or returns an 974 exception depends on the result of the recursive evaluation of 975 check_host(): 977 +---------------------------------+---------------------------------+ 978 | A recursive check_host() result | Causes the "include" mechanism | 979 | of: | to: | 980 +---------------------------------+---------------------------------+ 981 | pass | match | 982 | | | 983 | fail | not match | 984 | | | 985 | softfail | not match | 986 | | | 987 | neutral | not match | 988 | | | 989 | temperror | return temperror | 990 | | | 991 | permerror | return permerror | 992 | | | 993 | none | return permerror | 994 +---------------------------------+---------------------------------+ 996 The "include" mechanism is intended for crossing administrative 997 boundaries. For example, if example.com and example.org were managed 998 by the same entity, and if the permitted set of hosts for both 999 domains was 1000 "mx:example.com", it would be possible for example.org to specify 1001 "include:example.com", but it would be preferable to specify 1002 "redirect=example.com" or even "mx:example.com". 1004 With the "include" mechanism an administratively external set of 1005 hosts can be authorized, but determination of sender policy is still 1006 a function of the original domain's SPF record (as determined by the 1007 "all" mechanism in that record). The redirect modifier is more 1008 suitable for consolidating both authorizations and policy into a 1009 common set to be shared within an ADMD. Redirect is much more like a 1010 common code element to be shared among records in a single ADMD. It 1011 is possible to control both authorized hosts and policy for an 1012 arbitrary number of domains from a single record. 1014 5.3. "a" 1016 This mechanism matches if is one of the 's IP 1017 addresses. 1019 a = "a" [ ":" domain-spec ] [ dual-cidr-length ] 1021 An address lookup is done on the . The is compared 1022 to the returned address(es). If any address matches, the mechanism 1023 matches. 1025 5.4. "mx" 1027 This mechanism matches if is one of the MX hosts for a domain 1028 name. 1030 mx = "mx" [ ":" domain-spec ] [ dual-cidr-length ] 1032 check_host() first performs an MX lookup on the . Then 1033 it performs an address lookup on each MX name returned. The is 1034 compared to each returned IP address. To prevent Denial of Service 1035 (DoS) attacks, more than 10 MX names MUST NOT be looked up during the 1036 evaluation of an "mx" mechanism. If there are more than 10 MX names 1037 then permerror is returned and the evaluation terminated (see 1038 Section 4.6.4). If any address matches, the mechanism matches. 1040 Note regarding implicit MXs: If the has no MX records, 1041 check_host() MUST NOT pretend the target is its single MX, and MUST 1042 NOT default to an A or AAAA lookup on the directly. 1043 This behavior diverges from the legacy "implicit MX" rule, (See 1044 [RFC5321], Section 5. If such behavior is desired, the publisher 1045 will have to specify an "a" directive). 1047 5.5. "ptr" (deprecated) 1049 This mechanism tests whether the DNS reverse-mapping for exists 1050 and correctly points to a domain name within a particular domain. 1051 This mechanism is deprecated and SHOULD NOT be used. 1053 ptr = "ptr" [ ":" domain-spec ] 1055 The 's name is looked up using this procedure: 1057 1. Perform a DNS reverse-mapping for : Look up the corresponding 1058 PTR record in "in-addr.arpa." if the address is an IPv4 one and 1059 in "ip6.arpa." if it is an IPv6 address. 1061 2. For each record returned, validate the domain name by looking up 1062 its IP addresses. To prevent DoS attacks, more than 10 PTR names 1063 MUST NOT be looked up during the evaluation of a "ptr" mechanism 1064 (see Section 4.6.4). 1066 3. If is among the returned IP addresses, then that domain name 1067 is validated. 1069 Check all validated domain names to see if they either match the 1070 domain or are a subdomain of the domain. 1071 If any do, this mechanism matches. If no validated domain name can 1072 be found, or if none of the validated domain names match or are a 1073 subdomain of the , this mechanism fails to match. If a 1074 DNS error occurs while doing the PTR RR lookup, then this mechanism 1075 fails to match. If a DNS error occurs while doing an A RR lookup, 1076 then that domain name is skipped and the search continues. 1078 Pseudocode: 1080 sending-domain_names := ptr_lookup(sending-host_IP); 1081 if more than 10 sending-domain_names are found, use at most 10. 1082 for each name in (sending-domain_names) { 1083 IP_addresses := a_lookup(name); 1084 if the sending-domain_IP is one of the IP_addresses { 1085 validated-sending-domain_names += name; 1086 } 1087 } 1089 for each name in (validated-sending-domain_names) { 1090 if name ends in , return match. 1091 if name is , return match. 1092 } 1093 return no-match. 1095 This mechanism matches if the is either a subdomain of 1096 a validated domain name or if the and a validated 1097 domain name are the same. For example: "mail.example.com" is within 1098 the domain "example.com", but "mail.bad-example.com" is not. 1100 Note: This mechanism has been deprecated because it is slow, it is 1101 not as reliable as other mechanisms in cases of DNS errors, and it 1102 places a large burden on the .arpa name servers. If used, proper PTR 1103 records MUST be in place for the domain's hosts and the "ptr" 1104 mechanism SHOULD be one of the last mechanisms checked. After many 1105 years of SPF deployment experience it has been concluded it is 1106 unnecessary and more reliable alternatives used instead. It is, 1107 however, still in use and part of the SPF protocol, so compliant 1108 check_host() implementations MUST support it. 1110 5.6. "ip4" and "ip6" 1112 These mechanisms test whether is contained within a given IP 1113 network. 1115 ip4 = "ip4" ":" ip4-network [ ip4-cidr-length ] 1116 ip6 = "ip6" ":" ip6-network [ ip6-cidr-length ] 1118 ip4-cidr-length = "/" 1*DIGIT 1119 ip6-cidr-length = "/" 1*DIGIT 1120 dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ] 1122 ip4-network = qnum "." qnum "." qnum "." qnum 1123 qnum = DIGIT ; 0-9 1124 / %x31-39 DIGIT ; 10-99 1125 / "1" 2DIGIT ; 100-199 1126 / "2" %x30-34 DIGIT ; 200-249 1127 / "25" %x30-35 ; 250-255 1128 ; as per conventional dotted quad notation. e.g., 192.0.2.0 1129 ip6-network = 1130 ; e.g., 2001:DB8::CD30 1132 The is compared to the given network. If CIDR prefix length 1133 high-order bits match, the mechanism matches. 1135 If ip4-cidr-length is omitted, it is taken to be "/32". If 1136 ip6-cidr-length is omitted, it is taken to be "/128". It is not 1137 permitted to omit parts of the IP address instead of using CIDR 1138 notations. That is, use 192.0.2.0/24 instead of 192.0.2. 1140 5.7. "exists" 1142 This mechanism is used to construct an arbitrary domain name that is 1143 used for a DNS A record query. It allows for complicated schemes 1144 involving arbitrary parts of the mail envelope to determine what is 1145 permitted. 1147 exists = "exists" ":" domain-spec 1149 The domain-spec is expanded as per Section 8. The resulting domain 1150 name is used for a DNS A RR lookup. If any A record is returned, 1151 this mechanism matches. The lookup type is A even when the 1152 connection type is IPv6. 1154 Domains can use this mechanism to specify arbitrarily complex 1155 queries. For example, suppose example.com publishes the record: 1157 v=spf1 exists:%{ir}.%{l1r+-}._spf.%{d} -all 1159 The might expand to 1160 "1.2.0.192.someuser._spf.example.com". This makes fine-grained 1161 decisions possible at the level of the user and client IP address. 1163 This mechanism enables queries that mimic the style of tests that 1164 existing DNS white/black lists (DNSxLs) use, as described in 1165 [RFC5782]. The query will either return NXDOMAIN (no match), any 1166 valid answer (match), or an error. 1168 6. Modifier Definitions 1170 Modifiers are name/value pairs that provide additional information. 1171 Modifiers always have an "=" separating the name and the value. 1173 The modifiers defined in this document ("redirect" and "exp") MAY 1174 appear anywhere in the record, but SHOULD appear at the end, after 1175 all mechanisms. Ordering of these two modifiers does not matter. 1176 These two modifiers MUST NOT appear in a record more than once each. 1177 If they do, then check_host() exits with a result of "permerror". 1179 Unrecognized modifiers MUST be ignored no matter where in a record, 1180 or how often. This allows implementations of this document to 1181 gracefully handle records with modifiers that are defined in other 1182 specifications. 1184 6.1. redirect: Redirected Query 1186 The redirect modifier is intended for consolidating both 1187 authorizations and policy into a common set to be shared within a 1188 single ADMD. Redirect is like a common code element to be shared 1189 among records in a single ADMD. It is possible to control both 1190 authorized hosts and policy for an arbitrary number of domains from a 1191 single record. 1193 redirect = "redirect" "=" domain-spec 1195 If all mechanisms fail to match, and a "redirect" modifier is 1196 present, then processing proceeds as follows: 1198 The domain-spec portion of the redirect section is expanded as per 1199 the macro rules in Section 8. Then check_host() is evaluated with 1200 the resulting string as the . The and 1201 arguments remain the same as in the current evaluation of 1202 check_host(). 1204 The result of this new evaluation of check_host() is then considered 1205 the result of the current evaluation with the exception that if no 1206 SPF record is found, or if the target-name is malformed, the result 1207 is a "permerror" rather than "none". 1209 Note that the newly-queried domain can itself specify redirect 1210 processing. 1212 This facility is intended for use by organizations that wish to apply 1213 the same record to multiple domains. For example: 1215 la.example.com. TXT "v=spf1 redirect=_spf.example.com" 1216 ny.example.com. TXT "v=spf1 redirect=_spf.example.com" 1217 sf.example.com. TXT "v=spf1 redirect=_spf.example.com" 1218 _spf.example.com. TXT "v=spf1 mx:example.com -all" 1220 In this example, mail from any of the three domains is described by 1221 the same record. This can be an administrative advantage. 1223 Note: In general, the domain "A" cannot reliably use a redirect to 1224 another domain "B" not under the same administrative control. Since 1225 the stays the same, there is no guarantee that the record at 1226 domain "B" will correctly work for mailboxes in domain "A", 1227 especially if domain "B" uses mechanisms involving local-parts. An 1228 "include" directive is generally be more appropriate. 1230 For clarity, it is RECOMMENDED that any "redirect" modifier appear as 1231 the very last term in a record. 1233 6.2. exp: Explanation 1235 explanation = "exp" "=" domain-spec 1237 If check_host() results in a "fail" due to a mechanism match (such as 1238 "-all"), and the "exp" modifier is present, then the explanation 1239 string returned is computed as described below. If no "exp" modifier 1240 is present, then either a default explanation string or an empty 1241 explanation string MUST be returned. 1243 The domain-spec is macro expanded (see Section 8) and becomes the 1244 . The DNS TXT record for the is fetched. 1246 If there are any DNS processing errors (any RCODE other than 0), or 1247 if no records are returned, or if more than one record is returned, 1248 or if there are syntax errors in the explanation string, then proceed 1249 as if no exp modifier was given. 1251 The fetched TXT record's strings are concatenated with no spaces, and 1252 then treated as an explain-string, which is macro-expanded. This 1253 final result is the explanation string. Implementations MAY limit 1254 the length of the resulting explanation string to allow for other 1255 protocol constraints and/or reasonable processing limits. Since the 1256 explanation string is intended for an SMTP response and [RFC5321] 1257 Section 2.4 says that responses are in [US-ASCII], the explanation 1258 string MUST be limited to US-ASCII. 1260 Software evaluating check_host() can use this string to communicate 1261 information from the publishing domain in the form of a short message 1262 or URL. Software SHOULD make it clear that the explanation string 1263 comes from a third party. For example, it can prepend the macro 1264 string "%{o} explains: " to the explanation, such as shown in 1265 Section 2.5.4. 1267 Suppose example.com has this record: 1269 v=spf1 mx -all exp=explain._spf.%{d} 1271 Here are some examples of possible explanation TXT records at 1272 explain._spf.example.com: 1274 "Mail from example.com should only be sent by its own servers." 1275 -- a simple, constant message 1277 "%{i} is not one of %{d}'s designated mail servers." 1278 -- a message with a little more information, including the IP 1279 address that failed the check 1281 "See http://%{d}/why.html?s=%{S}&i=%{I}" 1282 -- a complicated example that constructs a URL with the 1283 arguments to check_host() so that a web page can be 1284 generated with detailed, custom instructions 1286 Note: During recursion into an "include" mechanism, an exp= modifier 1287 from the MUST NOT be used. In contrast, when executing 1288 a "redirect" modifier, an exp= modifier from the original domain MUST 1289 NOT be used. 1291 7. Recording The Result 1293 To provide downstream agents, such as MUAs, with the information they 1294 might need in terms of evaluating or representing the apparent safety 1295 of the message content, it is RECOMMENDED that SMTP receivers record 1296 the result of SPF processing in the message header. For operators 1297 that choose to record SPF results in the header of the message for 1298 processing by internal filters or MUAs, two methods are presented. 1299 Section 7.1 defines the Received-SPF field, which is the results 1300 field originally defined for SPF use. Section 7.2 discusses 1301 Authentication-Results [RFC5451] which was specified more recently 1302 and is designed for use by SPF and other authentication methods. 1304 Both are in common use, and hence both are included here. However, 1305 it is important to note that they were designed to serve slightly 1306 different purposes. Received-SPF is intended to include enough 1307 forensic information to enable reconstruction of the SPF evaluation 1308 of the message, while Authentication-Results is designed only to 1309 relay the result itself and related output details of likely use to 1310 end users (e.g., what property of the message was actually 1311 authenticated and what it contained), leaving forensic work to the 1312 purview of system logs and the Received field contents. Also, 1313 Received-SPF relies on compliance of agents within the receiving ADMD 1314 to adhere to the header field ordering rules of [RFC5321] and 1315 [RFC5322], while Authentication-Results includes some provisions to 1316 protect against non-compliant implementations. 1318 An operator could choose to use both to serve different downstream 1319 agents. In such cases, care needs to be taken to ensure both fields 1320 are conveying the same details, or unexpected results can occur. 1322 7.1. The Received-SPF Header Field 1324 The Received-SPF header field is a trace field (see [RFC5322] Section 1325 3.6.7) and SHOULD be prepended to the existing header, above the 1326 Received: field that is generated by the SMTP receiver. It MUST 1327 appear above all other Received-SPF fields in the message. The 1328 header field has the following format: 1330 header-field = "Received-SPF:" [CFWS] result FWS [comment FWS] 1331 [ key-value-list ] CRLF 1333 result = "pass" / "fail" / "softfail" / "neutral" / 1334 "none" / "temperror" / "permerror" 1336 key-value-list = key-value-pair *( ";" [CFWS] key-value-pair ) 1337 [";"] 1339 key-value-pair = key [CFWS] "=" ( dot-atom / quoted-string ) 1341 key = "client-ip" / "envelope-from" / "helo" / 1342 "problem" / "receiver" / "identity" / 1343 mechanism / name 1345 identity = "mailfrom" ; for the "MAIL FROM" identity 1346 / "helo" ; for the "HELO" identity 1347 / name ; other identities 1349 dot-atom = 1350 quoted-string = 1351 comment = 1352 CFWS = 1353 FWS = 1354 CRLF = 1356 The header field SHOULD include a "(...)" style comment after the 1357 result, conveying supporting information for the result, such as 1358 , , and . 1360 The following key-value pairs are designed for later machine parsing. 1361 SPF verifiers SHOULD give enough information so that the SPF results 1362 can be verified. That is, at least "client-ip", "helo", and, if the 1363 "MAIL FROM" identity was checked, "envelope-from". 1365 client-ip the IP address of the SMTP client 1367 envelope-from the envelope sender mailbox 1369 helo the host name given in the HELO or EHLO command 1371 mechanism the mechanism that matched (if no mechanisms matched, 1372 substitute the word "default") 1374 problem if an error was returned, details about the error 1375 receiver the host name of the SPF verifier 1377 identity the identity that was checked; see the ABNF 1378 rule 1380 Other keys MAY be defined by SPF verifiers. 1382 SPF verifiers MUST make sure that the Received-SPF header field does 1383 not contain invalid characters, is not excessively long (See 1384 [RFC5322] Section 2.1.1), and does not contain malicious data that 1385 has been provided by the sender. 1387 Examples of various header field styles that could be generated are 1388 the following: 1390 Received-SPF: pass (mybox.example.org: domain of 1391 myname@example.com designates 192.0.2.1 as permitted sender) 1392 receiver=mybox.example.org; client-ip=192.0.2.1; 1393 envelope-from="myname@example.com"; helo=foo.example.com; 1395 Received-SPF: fail (mybox.example.org: domain of 1396 myname@example.com does not designate 1397 192.0.2.1 as permitted sender) 1398 identity=mailfrom; client-ip=192.0.2.1; 1399 envelope-from="myname@example.com"; 1401 7.2. SPF Results in the Authentication-Results Header Field 1403 As mentioned in Section 7, the Authentication-Results header field is 1404 designed to communicate lists of tests a border MTA did and their 1405 results. The specified elements of the field provide less 1406 information than the SPF-Received field: 1408 Authentication-Results: myhost.example.org; spf=pass 1409 smtp.mailfrom=example.net 1411 Received-SPF: pass (myhost.example.org: domain of 1412 myname@example.com designates 192.0.2.1 as permitted sender) 1413 receiver=mybox.example.org; client-ip=192.0.2.1; 1414 envelope-from="myname@example.com"; helo=foo.example.com; 1416 It is, however, possible to add CFWS in the "reason" part of an 1417 Authentication-Results header field and provide the equivalent 1418 information, if desired. 1420 As an example, an expanded Authentication-Results header field might 1421 look like (for a "MAIL FROM" check in this example): 1423 Authentication-Results: myhost.example.org; spf=pass 1424 reason="client-ip=192.0.2.1; smtp.helo=foo.example.com" 1425 smtp.mailfrom=user@example.net 1427 8. Macros 1429 8.1. Macro Definitions 1431 Many mechanisms and modifiers perform macro expansion on a term. 1433 domain-spec = macro-string domain-end 1434 domain-end = ( "." toplabel [ "." ] ) / macro-expand 1436 toplabel = ( *alphanum ALPHA *alphanum ) / 1437 ( 1*alphanum "-" *( alphanum / "-" ) alphanum ) 1438 ; LDH rule plus additional TLD restrictions 1439 ; (see [RFC3696], Section 2 for background) 1440 alphanum = ALPHA / DIGIT 1442 explain-string = *( macro-string / SP ) 1444 macro-string = *( macro-expand / macro-literal ) 1445 macro-expand = ( "%{" macro-letter transformers *delimiter "}" ) 1446 / "%%" / "%_" / "%-" 1447 macro-literal = %x21-24 / %x26-7E 1448 ; visible characters except "%" 1449 macro-letter = "s" / "l" / "o" / "d" / "i" / "p" / "h" / 1450 "c" / "r" / "t" / "v" 1451 transformers = *DIGIT [ "r" ] 1452 delimiter = "." / "-" / "+" / "," / "/" / "_" / "=" 1454 A literal "%" is expressed by "%%". 1456 "%_" expands to a single " " space. 1457 "%-" expands to a URL-encoded space, viz., "%20". 1459 The following macro letters are expanded in term arguments: 1461 s = 1462 l = local-part of 1463 o = domain of 1464 d = 1465 i = 1466 p = the validated domain name of (deprecated) 1467 v = the string "in-addr" if is ipv4, or "ip6" if is ipv6 1468 h = HELO/EHLO domain 1470 The following macro letters are allowed only in "exp" text: 1472 c = SMTP client IP (easily readable format) 1473 r = domain name of host performing the check 1474 t = current timestamp 1476 A '%' character not followed by a '{', '%', '-', or '_' character is 1477 a syntax error. So 1478 -exists:%(ir).sbl.spamhaus.example.org 1479 is incorrect and will cause check_host() to yield a "permerror". 1480 Instead, say 1481 -exists:%{ir}.sbl.spamhaus.example.org 1483 Optional transformers are the following: 1485 *DIGIT = zero or more digits 1486 'r' = reverse value, splitting on dots by default 1488 If transformers or delimiters are provided, the replacement value for 1489 a macro letter is split into parts. After performing any reversal 1490 operation and/or removal of left-hand parts, the parts are rejoined 1491 using "." and not the original splitting characters. 1493 By default, strings are split on "." (dots). Note that no special 1494 treatment is given to leading, trailing, or consecutive delimiters in 1495 input strings, and so the list of parts might contain empty strings. 1496 Some older implementations of SPF prohibit trailing dots in domain 1497 names, so trailing dots SHOULD NOT be published by domain owners, 1498 although they MUST be accepted by implementations conforming to this 1499 document. Macros can specify delimiter characters that are used 1500 instead of ".". 1502 The 'r' transformer indicates a reversal operation: if the client IP 1503 address were 192.0.2.1, the macro %{i} would expand to "192.0.2.1" 1504 and the macro %{ir} would expand to "1.2.0.192". 1506 The DIGIT transformer indicates the number of right-hand parts to 1507 use, after optional reversal. If a DIGIT is specified, the value 1508 MUST be nonzero. If no DIGITs are specified, or if the value 1509 specifies more parts than are available, all the available parts are 1510 used. If the DIGIT was 5, and only 3 parts were available, the macro 1511 interpreter would pretend the DIGIT was 3. Implementations MUST 1512 support at least a value of 128, as that is the maximum number of 1513 labels in a domain name. 1515 The "s" macro expands to the argument. It is an email 1516 address with a local-part, an "@" character, and a domain. The "l" 1517 macro expands to just the local-part. The "o" macro expands to just 1518 the domain part. Note that these values remain the same during 1519 recursive and chained evaluations due to "include" and/or "redirect". 1520 Note also that if the original had no local-part, the local- 1521 part was set to "postmaster" in initial processing (see Section 4.3). 1523 For IPv4 addresses, both the "i" and "c" macros expand to the 1524 standard dotted-quad format. 1526 For IPv6 addresses, the "i" macro expands to a dot-format address; it 1527 is intended for use in %{ir}. The "c" macro can expand to any of the 1528 hexadecimal colon-format addresses specified in [RFC4291], Section 1529 2.2. It is intended for humans to read. 1531 The "p" macro expands to the validated domain name of . The 1532 procedure for finding the validated domain name is defined in 1533 Section 5.5. If the is present in the list of validated 1534 domains, it SHOULD be used. Otherwise, if a subdomain of the 1535 is present, it SHOULD be used. Otherwise, any name from the 1536 list can be used. If there are no validated domain names or if a DNS 1537 error occurs, the string "unknown" is used. This macro is deprecated 1538 and SHOULD NOT be used. 1540 The "r" macro expands to the name of the receiving MTA. This SHOULD 1541 be a fully qualified domain name, but if one does not exist (as when 1542 the checking is done by a MUA) or if policy restrictions dictate 1543 otherwise, the word "unknown" SHOULD be substituted. The domain name 1544 can be different from the name found in the MX record that the client 1545 MTA used to locate the receiving MTA. 1547 The "t" macro expands to the decimal representation of the 1548 approximate number of seconds since the Epoch (Midnight, January 1, 1549 1970, UTC) at the time of the evaluation. This is the same value as 1550 is returned by the POSIX time() function in most standards-compliant 1551 libraries. 1553 When the result of macro expansion is used in a domain name query, if 1554 the expanded domain name exceeds 253 characters (the maximum length 1555 of a domain name), the left side is truncated to fit, by removing 1556 successive domain labels (and their following dots) until the total 1557 length does not exceed 253 characters. 1559 Uppercased macros expand exactly as their lowercased equivalents, and 1560 are then URL escaped. URL escaping MUST be performed for characters 1561 not in the "unreserved" set, which is defined in [RFC3986]. 1563 Note: Care has to be taken so that macro expansion for legitimate 1564 email does not exceed the 63-character limit on DNS labels. The 1565 local-part of email addresses, in particular, can have more than 63 1566 characters between dots. 1568 Note: Domains SHOULD avoid using the "s", "l", "o", or "h" macros in 1569 conjunction with any mechanism directive. Although these macros are 1570 powerful and allow per-user records to be published, they severely 1571 limit the ability of implementations to cache results of check_host() 1572 and they reduce the effectiveness of DNS caches. 1574 Note: If no directive processed during the evaluation of check_host() 1575 contains an "s", "l", "o", or "h" macro, then the results of the 1576 evaluation can be cached on the basis of and alone for 1577 as long as the shortest Time To Live (TTL) of all the DNS records 1578 involved. 1580 8.2. Expansion Examples 1582 The is strong-bad@email.example.com. 1583 The IPv4 SMTP client IP is 192.0.2.3. 1584 The IPv6 SMTP client IP is 2001:DB8::CB01. 1585 The PTR domain name of the client IP is mx.example.org. 1587 macro expansion 1588 ------- ---------------------------- 1589 %{s} strong-bad@email.example.com 1590 %{o} email.example.com 1591 %{d} email.example.com 1592 %{d4} email.example.com 1593 %{d3} email.example.com 1594 %{d2} example.com 1595 %{d1} com 1596 %{dr} com.example.email 1597 %{d2r} example.email 1598 %{l} strong-bad 1599 %{l-} strong.bad 1600 %{lr} strong-bad 1601 %{lr-} bad.strong 1602 %{l1r-} strong 1604 macro-string expansion 1605 -------------------------------------------------------------------- 1606 %{ir}.%{v}._spf.%{d2} 3.2.0.192.in-addr._spf.example.com 1607 %{lr-}.lp._spf.%{d2} bad.strong.lp._spf.example.com 1609 %{lr-}.lp.%{ir}.%{v}._spf.%{d2} 1610 bad.strong.lp.3.2.0.192.in-addr._spf.example.com 1612 %{ir}.%{v}.%{l1r-}.lp._spf.%{d2} 1613 3.2.0.192.in-addr.strong.lp._spf.example.com 1615 %{d2}.trusted-domains.example.net 1616 example.com.trusted-domains.example.net 1618 IPv6: 1619 %{ir}.%{v}._spf.%{d2} 1.0.B.C.0.0.0.0. 1621 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 1623 9. Implications 1625 This section outlines the major implications that adoption of this 1626 document will have on various entities involved in Internet email. 1627 It is intended to make clear to the reader where this document 1628 knowingly affects the operation of such entities. This section is 1629 not a "how-to" manual, or a "best practices" document, and it is not 1630 a comprehensive list of what such entities SHOULD do in light of this 1631 document. 1633 This section is non-normative. [RFC5598] describes the Internet 1634 email architecture. This section is organized based on the different 1635 segments of the architecture. 1637 9.1. Sending Domains 1639 Originating ADMDs (ADministrative Management Domains - [RFC5598] 1640 Section 2.2.1 and Section 2.3) that wish to be compliant with this 1641 specification will need to determine the list of relays ([RFC5598] 1642 Section 2.2.2) that they allow to use their domain name in the "HELO" 1643 and "MAIL FROM" identities when relaying to other ADMDs. It is 1644 recognized that forming such a list is not just a simple technical 1645 exercise, but involves policy decisions with both technical and 1646 administrative considerations. 1648 9.1.1. DNS Resource Considerations 1650 Minimizing the DNS resources required for SPF lookups can be done by 1651 choosing directives that require less DNS information and by placing 1652 lower-cost mechanisms earlier in the SPF record. 1654 +----------+--------+-----------------+ 1655 | term | cost | limit | 1656 +----------+--------+-----------------+ 1657 | ip4/ip6 | 0 | - | 1658 | a | 1 | 10 | 1659 | include | 1 | 10 | 1660 | redirect | 1 | 10 | 1661 | exists | 1 | 10 | 1662 | mx | 1 + N* | 10 and N* <= 10 | 1663 | ptr/%{p} | 1 + N* | 10 and N* <= 10 | 1664 | all | 0 | - | 1665 +----------+--------+-----------------+ 1666 * N is the number of RRs found during each term evaluation 1668 Section 4.6.4 specifies the limits receivers have to use. It is 1669 essential to publish records that do not exceed these requirements. 1670 It is also required to carefully weight the cost and the 1671 maintainability of licit solutions. 1673 For example, consider a domain set up as follows: 1675 example.com. IN MX 10 mx.example.com. 1676 IN MX 20 mx2.example.com. 1677 mx.example.com. IN A 192.0.2.1 1678 mx2.example.com. IN A 192.0.2.129 1680 Assume the administrative point is to authorize (pass) mx and mx2 1681 while failing every other host. Compare the following solutions: 1683 Best record: 1684 example.com. IN TXT "v=spf1 ip4:192.0.2.1 ip4:192.0.2.129 -all" 1686 Good record: 1687 $ORIGIN example.com. 1688 @ IN TXT "v=spf1 a:authorized-spf.example.com -all" 1689 authorized-spf IN A 192.0.2.1 1690 IN A 192.0.2.129 1692 Expensive record: 1693 example.com. IN TXT "v=spf1 mx:example.com -all" 1695 Wasteful, bad record: 1696 example.com. IN TXT "v=spf1 ip4:192.0.2.0/24 mx -all" 1698 9.1.2. Administrator's Considerations 1700 There might be administrative considerations: using "a" over "ip4" or 1701 "ip6" allows hosts to be renumbered easily. Using "mx" over "a" 1702 allows the set of mail hosts to be changed easily. Unless such 1703 changes are common, it is better to use the less resource intensive 1704 mechanisms like "ip4" and "ip6" over "a" or "a" or "mx". 1706 In some specific cases, standard advice on record content is 1707 appropriate. Publishing SPF records for domains that send no mail is 1708 a well established best practice. The record for a domain that sends 1709 no mail is: 1711 www.example.com. IN TXT "v=spf1 -all" 1713 Publishing SPF records for individual hosts is also best practice. 1714 The hostname is generally the identity used in the 5321.HELO/.EHLO 1715 command. In the case of messages with a null 5321.MailFrom, this is 1716 used as the domain for 5321.MailFrom SPF checks, in addition to being 1717 used in 5321.HELO/.EHLO based SPF checks. The standard SPF record 1718 for an individual host that is involved in mail processing is: 1720 relay.example.com. IN TXT "v=spf1 a -all" 1722 Validating correct deployment is difficult. [RFC6652] describes one 1723 mechanism for soliciting feedback on SPF failures. Another approach 1724 that can be helpful to publish records that include a "tracking 1725 exists:" mechanism. By looking at the name server logs, a rough list 1726 can then be generated. For example: 1728 v=spf1 exists:_h.%{h}._l.%{l}._o.%{o}._i.%{i}._spf.%{d} ?all 1730 Regardless of the method used, understanding the ADMD's outbound mail 1731 architecture is essential to effective deployment. 1733 9.1.3. Bounces 1735 As explained in Section 1.3.3, [RFC5321] allows the reverse-path to 1736 be null, which is typical of some Delivery Status Notification 1737 [RFC3464], commonly called email bounces. In this case the only 1738 entity available for performing an SPF check is the "HELO" identity 1739 defined in Section 1.3.4. SPF functionality is enhanced by 1740 administrators ensuring this identity is set correctly and has an 1741 appropriate SPF record. It is normal to have the HELO identity set 1742 to hostname instead of domain. Zone file generation for significant 1743 numbers of hosts can be consolidated using the redirect modifier and 1744 scripted for initial deployment. Specific deployment advice is given 1745 above in Section 9.1.2. 1747 9.2. Mediators 1749 Broadly speaking, there are two types of mediating ADMDs that can 1750 affect SPF deployment of other ADMDs: mailing lists (see [RFC5598] 1751 Section 5.3) and ReSenders ([RFC5598] Section 5.2). 1753 9.2.1. Mailing Lists 1755 Mailing lists have to be aware of how they re-inject mail that is 1756 sent to the list. Mailing lists MUST comply with the requirements in 1757 [RFC5321], Section 3.10, and [RFC1123], Section 5.3.6, that say that 1758 the reverse-path MUST be changed to be the mailbox of a person or 1759 other entity who administers the list. Whereas the reasons for 1760 changing the reverse-path are many and long-standing, SPF adds 1761 enforcement to this requirement. 1763 In practice, almost all mailing list software in use already complies 1764 with this requirement. Mailing lists that do not comply might 1765 encounter problems depending on how access to the list is restricted. 1766 Such lists that are entirely internal to a domain (only people in the 1767 domain can send to or receive from the list) are not affected. 1769 9.2.2. Forwarding Services and Aliases 1771 Forwarding services take mail that is received at a mailbox and 1772 direct it to some external mailbox. At the time of this writing, the 1773 near-universal practice of such services is to use the original "MAIL 1774 FROM" of a message when re-injecting it for delivery to the external 1775 mailbox. [RFC1123] and [RFC5321] describe this action as an "alias" 1776 rather than a "mail list". This means the external mailbox's MTA 1777 sees all such mail in a connection from a host of the forwarding 1778 service, and so the "MAIL FROM" identity will not, in general, pass 1779 authorization. 1781 There are three places that techniques can be used to ameliorate this 1782 problem. 1784 1. The beginning, when email is first sent (Originating ADMDs). 1786 1. "Neutral" results could be given for IP addresses that might 1787 be forwarders, instead of "fail" results based on a list of 1788 known reliable forwarders. For example: 1790 "v=spf1 mx ?exists:%{ir}.whitlist.example.org -all" 1792 This would cause a lookup on an DNS white list (DNSWL) and 1793 cause a result of "fail" only for email not either coming 1794 from the domain's mx host(s) (SPF pass) or white listed 1795 sources (SPF neutral). This, in effect, outsources an 1796 element of sender policy to the maintainer of the whitelist. 1798 2. The "MAIL FROM" identity could have additional information in 1799 the local-part that cryptographically identifies the mail as 1800 coming from an authorized source. In this case, such an SPF 1801 record could be used: 1803 "v=spf1 mx exists:%{l}._spf_verify.%{d} -all" 1805 Then, a specialized DNS server can be set up to serve the 1806 _spf_verify subdomain that validates the local-part. 1807 Although this requires an extra DNS lookup, this happens only 1808 when the email would otherwise be rejected as not coming from 1809 a known good source. 1810 Note that due to the 63-character limit for domain labels, 1811 this approach only works reliably if the local-part signature 1812 scheme is guaranteed either to only produce local-parts with 1813 a maximum of 63 characters or to gracefully handle truncated 1814 local-parts. 1816 3. Similarly, a specialized DNS server could be set up that will 1817 rate-limit the email coming from unexpected IP addresses. 1819 "v=spf1 mx exists:%{ir}._spf_rate.%{d} -all" 1821 4. SPF allows the creation of per-user policies for special 1822 cases. For example, the following SPF record and appropriate 1823 wildcard DNS records can be used: 1825 "v=spf1 mx redirect=%{l1r+}._at_.%{o}._spf.%{d}" 1827 2. The middle, when email is forwarded (Mediating ADMDs). 1829 1. Forwarding services can solve the problem by rewriting the 1830 "MAIL FROM" to be in their own domain. This means mail 1831 rejected from the external mailbox will have to be forwarded 1832 back to the original sender by the forwarding service. 1833 Various schemes to do this exist though they vary widely in 1834 complexity and resource requirements on the part of the 1835 forwarding service. 1837 2. Several popular MTAs can be forced from "alias" semantics to 1838 "mailing list" semantics by configuring an additional alias 1839 with "owner-" prepended to the original alias name (e.g., an 1840 alias of "friends: george@example.com, fred@example.org" 1841 would need another alias of the form "owner-friends: 1842 localowner"). 1844 3. Forwarding servers could reject mail that would "fail" SPF if 1845 forwarded using an SMTP reply code of 551, User not local, 1846 (see [RFC5321] section 3.4) to communicate the correct target 1847 address to resend the mail to. 1849 3. The end, when email is received (Receiving ADMDs). 1851 1. If the owner of the external mailbox wishes to trust the 1852 forwarding service, he can direct the external mailbox's MTA 1853 to skip SPF tests when the client host belongs to the 1854 forwarding service. 1856 2. Tests against other identities, such as the "HELO" identity, 1857 MAY be used to override a failed test against the "MAIL FROM" 1858 identity. 1860 3. For larger domains, it might not be possible to have a 1861 complete or accurate list of forwarding services used by the 1862 owners of the domain's mailboxes. In such cases, whitelists 1863 of generally-recognized forwarding services could be 1864 employed. 1866 9.2.3. Mail Services 1868 MSPs (Mail Service Providers - [RFC5598] Section 2.3) that offer mail 1869 services to third-party domains, such as sending of bulk mail, might 1870 want to adjust their configurations in light of the authorization 1871 check described in this document. If the domain part of the "MAIL 1872 FROM" identity used for such email uses the domain of one of the MSPs 1873 domain, then the provider needs only to ensure that its sending host 1874 is authorized by its own SPF record, if any. 1876 If the "MAIL FROM" identity does not use the MSP's domain, then extra 1877 care has to be taken. The SPF record format has several options for 1878 the third-party domain to authorize the service provider's MTAs to 1879 send mail on its behalf. For MSPs, such as ISPs, that have a wide 1880 variety of customers using the same MTA, steps are required to 1881 mitiate the risk of cross-customer forgery (see Section 10.4). 1883 9.2.4. MTA Relays 1885 Relays are described in [RFC5598] Section 2.2.2. The authorization 1886 check generally precludes the use of arbitrary MTA relays between 1887 sender and receiver of an email message. 1889 Within an organization, MTA relays can be effectively deployed. 1890 However, for purposes of this document, such relays are effectively 1891 transparent. The SPF authorization check is a check between border 1892 MTAs of different ADMDs. 1894 For mail senders, this means that published SPF records have to 1895 authorize any MTAs that actually send across the Internet. Usually, 1896 these are just the border MTAs as internal MTAs simply forward mail 1897 to these MTAs for relaying. 1899 The receiving ADMD will generally want to perform the authorization 1900 check at the boundary MTAs, including all secondary MXs. Internal 1901 MTAs (including MTAs that might serve both as boundary MTAs and 1902 internal relays from secondary MXs when they are processing the 1903 relayed mail stream) then do not perform the authorization test. To 1904 perform the authorization test other than at the boundary, the host 1905 that first transferred the message to the receiving ADMD have to be 1906 determined, which can be difficult to extract from the message header 1907 because (a) header fields can be forged or malformed, and (b) there's 1908 no standard way to encode that information such that it can be 1909 reliably extracted. Testing other than at the boundary is likely to 1910 produce unreliable results. 1912 9.3. Receivers 1914 SPF results can be used in combination with other methods to 1915 determine the final local disposition (either positive or negative of 1916 a message. It can also be considered dispositive on its own. 1918 9.3.1. Policy For SPF Pass 1920 SPF pass results can be used in combination with "white lists" of 1921 known "good" domains to bypass some or all additional pre-delivery 1922 email checks. Exactly which checks and how to determine appropriate 1923 white list entries has to be based on local conditions and 1924 requirements. 1926 9.3.2. Policy For SPF Fail 1928 SPF fail results can be used to reject messages during the SMTP 1929 transaction based on either "MAIL FROM" or "HELO" identity results. 1930 This reduces resource requirements for various content filtering 1931 methods and conserves bandwidth since rejection can be done before 1932 the SMTP content is transferred. It also gives immediate feedback to 1933 the sender who might then be able to resolve the issue. Due to some 1934 of the issues described above in this section (Section 9), SPF based 1935 rejection does present some risk of rejecting legitimate email when 1936 rejecting based on "MAIL FROM" results. 1938 SPF fail results can alternately be used as one input into a larger 1939 set of evaluations which might, based on a combination with other 1940 evaluation techniques, result in the email being marked negatively in 1941 some way (this might be via delivery to a special spam folder, 1942 modifying subject lines, or other locally determined means). 1943 Developing the details of such an approach have to be based on local 1944 conditions and requirements. Using SPF results in this way does not 1945 have the advantages of resource conservation and immediate feedback 1946 to the sender associated with SMTP rejection, but could produce fewer 1947 undesirable rejections in a well designed system. Such an approach 1948 might result in email that was not authorized by the sending ADMD 1949 being unknowingly delivered to end users. 1951 Either general approach can be used as they both leave a clear 1952 disposition of emails. They are either delivered in some manner or 1953 the sender is notified of the failure. Other dispositions such as 1954 "dropping" or deleting email after acceptance are inappropriate 1955 because they leave uncertainty and reduce the overall reliabilility 1956 and utility of email across the Internet. 1958 9.3.3. Policy For SPF Permerror 1960 The "permerror" result (see Section 2.5.7) indicates the SPF 1961 processing module at the receiver determined that the retrieved SPF 1962 policy record could not be interpreted. This gives no true 1963 indication about the authorized use of the data found in the 1964 envelope. 1966 As with all results, implementers have a choice to make regarding 1967 what to do with a message that yields this result. SMTP allows only 1968 a few basic options. 1970 Rejection of the message is an option, in that it is the one thing a 1971 receiver can do to draw attention to the difficulty encountered while 1972 protecting itself from messages that do not have a definite SPF 1973 result of some kind. However, if the SPF implementation is defective 1974 and returns spurious "permerror" results, only the sender is actively 1975 notified of the defect (in the form of rejected mail), and not the 1976 receiver making use of SPF. 1978 The less intrusive handling choice is to deliver the message, perhaps 1979 with some kind of annotation of the difficulty encountered and/or 1980 logging of a similar nature. However, this will not be desirable to 1981 operators that wish to implement SPF checking as strictly as 1982 possible, nor is this sort of passive problem reporting typically 1983 effective. 1985 There is of course the option placing this choice in the hands of the 1986 operator rather than the implementer since this kind of choice is 1987 often a matter of local policy rather than a condition with a 1988 universal solution, but this adds one more piece of complexity to an 1989 already non-trivial environment. 1991 Both implementers and operators need to be cautious of all choices 1992 and outcomes when handling SPF results. 1994 10. Security Considerations 1996 10.1. Processing Limits 1998 As with most aspects of email, there are a number of ways that 1999 malicious parties could use the protocol as an avenue for a 2000 Denial-of-Service (DoS) attack. The processing limits outlined in 2001 Section 4.6.4 are designed to prevent attacks such as the following: 2003 o A malicious party could create an SPF record with many references 2004 to a victim's domain and send many emails to different SPF 2005 verifiers; those SPF verifiers would then create a DoS attack. In 2006 effect, the SPF verifiers are being used to amplify the attacker's 2007 bandwidth by using fewer bytes in the SMTP session than are used 2008 by the DNS queries. Using SPF clients also allows the attacker to 2009 hide the true source of the attack. 2011 o Whereas implementations of check_host() are supposed to limit the 2012 number of DNS lookups, malicious domains could publish records 2013 that exceed these limits in an attempt to waste computation effort 2014 at their targets when they send them mail. Malicious domains 2015 could also design SPF records that cause particular 2016 implementations to use excessive memory or CPU usage, or to 2017 trigger bugs. 2019 o Malicious parties could send a large volume of mail purporting to 2020 come from the intended target to a wide variety of legitimate mail 2021 hosts. These legitimate machines would then present a DNS load on 2022 the target as they fetched the relevant records. 2024 Of these, the case of a third party referenced in the SPF record is 2025 the easiest for a DoS attack to effectively exploit. As a result, 2026 limits that might seem reasonable for an individual mail server can 2027 still allow an unreasonable amount of bandwidth amplification. 2028 Therefore, the processing limits need to be quite low. 2030 10.2. SPF-Authorized Email May Contain Other False Identities 2032 Do not construe the "MAIL FROM" and "HELO" identity authorizations to 2033 provide more assurance than they do. It is entirely possible for a 2034 malicious sender to inject a message using his own domain in the 2035 identities used by SPF, to have that domain's SPF record authorize 2036 the sending host, and yet the message can easily list other 2037 identities in its header. Unless the user or the MUA takes care to 2038 note that the authorized identity does not match the other more 2039 commonly-presented identities (such as the From: header field), the 2040 user might be lulled into a false sense of security. 2042 10.3. Spoofed DNS and IP Data 2044 There are two aspects of this protocol that malicious parties could 2045 exploit to undermine the validity of the check_host() function: 2047 o The evaluation of check_host() relies heavily on DNS. A malicious 2048 attacker could attack the DNS infrastructure and cause 2049 check_host() to see spoofed DNS data, and then return incorrect 2050 results. This could include returning "pass" for an value 2051 where the actual domain's record would evaluate to "fail". See 2052 [RFC3833] for a description of DNS weaknesses. 2054 o The client IP address, , is assumed to be correct. In a 2055 modern, correctly configured system the risk of this not being 2056 true is nil. 2058 10.4. Cross-User Forgery 2060 By definition, SPF policies just map domain names to sets of 2061 authorized MTAs, not whole email addresses to sets of authorized 2062 users. Although the "l" macro (Section 8) provides a limited way to 2063 define individual sets of authorized MTAs for specific email 2064 addresses, it is generally impossible to verify, through SPF, the use 2065 of specific email addresses by individual users of the same MTA. 2067 It is up to mail services and their MTAs to directly prevent 2068 cross-user forgery: based on SMTP AUTH ([RFC4954]), users have to be 2069 restricted to using only those email addresses that are actually 2070 under their control (see [RFC6409], Section 6.1). Another means to 2071 verify the identity of individual users is message cryptography such 2072 as PGP ([RFC4880]) or S/MIME ([RFC5751]). 2074 10.5. Untrusted Information Sources 2076 An SPF compliant receiver gathers information from the SMTP commands 2077 it receives and from the published DNS records of the sending domain 2078 holder, (e.g., "HELO" domain name, the "MAIL FROM" address from the 2079 envelope, and SPF DNS records published by the domain holder). 2081 10.5.1. Recorded Results 2083 This information, passed to the receiver in the Received-SPF: or 2084 Authentication-Results: trace fields, may be returned to the client 2085 MTA as an SMTP rejection message. If such an SMTP rejection message 2086 is generated, the information from the trace fields has to be checked 2087 for such problems as invalid characters and excessively long lines. 2089 10.5.2. External Explanations 2091 When the authorization check fails, an explanation string could be 2092 included in the reject response. Both the sender and the rejecting 2093 receiver need to be aware that the explanation was determined by the 2094 publisher of the SPF record checked and, in general, not the 2095 receiver. The explanation can contain malicious URLs, or it might be 2096 offensive or misleading. 2098 Explanations returned to sender domains due to "exp" modifiers, 2099 (Section 6.2), were generated by the sender policy published by the 2100 domain holders themselves. As long as messages are only returned 2101 with non-delivery notification ([RFC3464]) to domains publishing the 2102 explanation strings from their own DNS SPF records, the only affected 2103 parties are the original publishers of the domain's SPF records. 2105 In practice, such non-delivery notifications can be misdirected, such 2106 as when an MTA accepts an email and only later generates the 2107 notification to a forged address, or when an email forwarder does not 2108 direct the bounce back to the original sender. 2110 10.5.3. Macro Expansion 2112 Macros (Section 8) allow senders to inject arbitrary text (any non- 2113 null [US-ASCII] character) into receiver DNS queries. It is necesary 2114 to be prepared for hostile or unexpected content. 2116 10.6. Privacy Exposure 2118 Checking SPF records causes DNS queries to be sent to the domain 2119 owner. These DNS queries, especially if they are caused by the 2120 "exists" mechanism, can contain information about who is sending 2121 email and likely to which MTA the email is being sent. This can 2122 introduce some privacy concerns, which are more or less of an issue 2123 depending on local laws and the relationship between the domain owner 2124 and the person sending the email. 2126 11. Contributors and Acknowledgements 2128 This document is largely based on the work of Meng Weng Wong, Mark 2129 Lentczner, and Wayne Schlitt. Although, as this section 2130 acknowledges, many people have contributed to this document, a very 2131 large portion of the writing and editing are due to Meng, Mark, and 2132 Wayne. 2134 This design owes a debt of parentage to [RMX] by Hadmut Danisch and 2135 to [DMP] by Gordon Fecyk. The idea of using a DNS record to check 2136 the legitimacy of an email address traces its ancestry further back 2137 through messages on the namedroppers mailing list by Paul Vixie 2138 [Vixie] (based on suggestion by Jim Miller) and by David Green 2139 [Green]. 2141 Philip Gladstone contributed the concept of macros to the 2142 specification, multiplying the expressiveness of the language and 2143 making per-user and per-IP lookups possible. 2145 The authors of both this document and [RFC4408] would also like to 2146 thank the literally hundreds of individuals who have participated in 2147 the development of this design. They are far too numerous to name, 2148 but they include the following: 2150 The participants in the SPFbis working group. 2151 The folks on the spf-discuss mailing list. 2152 The folks on the SPAM-L mailing list. 2153 The folks on the IRTF ASRG mailing list. 2154 The folks on the IETF MARID mailing list. 2155 The folks on #perl. 2157 12. IANA Considerations 2159 12.1. The SPF DNS Record Type 2161 Per [RFC4408], the IANA assigned the Resource Record Type and Qtype 2162 from the DNS Parameters Registry for the SPF RR type with code 99. 2163 The format of this type is identical to the TXT RR [RFC1035]. The 2164 character content of the record is encoded as [US-ASCII]. Use of 2165 this record type is obsolete for SPF Version 1. 2167 IANA is requested to add an annotation to the SPF RRTYPE saying 2168 "(OBSOLETE - use TXT)" in the DNS Parameters registry. 2170 [NOTE TO RFC EDITOR: (to be changed to " ... has added ..." upon 2171 publication)] 2173 12.2. The Received-SPF Mail Header Field 2175 Per [RFC3864], the "Received-SPF:" header field is added to the IANA 2176 Permanent Message Header Field Registry. The following is the 2177 registration template: 2179 Header field name: Received-SPF 2180 Applicable protocol: mail ([RFC5322]) 2181 Status: Standards Track 2182 Author/Change controller: IETF 2183 Specification document(s): RFC XXXX 2184 [NOTE TO RFC EDITOR: (this document)] 2186 12.3. SPF Modifier Registration 2188 [RFC6652] created a new SPF Modifier Registration. IANA is requested 2189 to change the reference for the exp and redirect modifiers from 2190 [RFC4408] to this document. Their status should not be changed. 2192 13. References 2194 13.1. Normative References 2196 [RFC1035] Mockapetris, P., "Domain names - implementation and 2197 specification", STD 13, RFC 1035, November 1987. 2199 [RFC1123] Braden, R., "Requirements for Internet Hosts - Application 2200 and Support", STD 3, RFC 1123, October 1989. 2202 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2203 Requirement Levels", BCP 14, RFC 2119, March 1997. 2205 [RFC3463] Vaudreuil, G., "Enhanced Mail System Status Codes", 2206 RFC 3463, January 2003. 2208 [RFC3864] Klyne, G., Nottingham, M., and J. Mogul, "Registration 2209 Procedures for Message Header Fields", BCP 90, RFC 3864, 2210 September 2004. 2212 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 2213 Resource Identifier (URI): Generic Syntax", STD 66, 2214 RFC 3986, January 2005. 2216 [RFC4291] Hinden, R. and S. Deering, "IP Version 6 Addressing 2217 Architecture", RFC 4291, February 2006. 2219 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 2220 Specifications: ABNF", STD 68, RFC 5234, January 2008. 2222 [RFC5321] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 2223 October 2008. 2225 [RFC5322] Resnick, P., Ed., "Internet Message Format", RFC 5322, 2226 October 2008. 2228 [RFC5451] Kucherawy, M., "Message Header Field for Indicating 2229 Message Authentication Status", RFC 5451, April 2009. 2231 [RFC5598] Crocker, D., "Internet Mail Architecture", RFC 5598, 2232 July 2009. 2234 [RFC5890] Klensin, J., "Internationalized Domain Names for 2235 Applications (IDNA): Definitions and Document Framework", 2236 RFC 5890, August 2010. 2238 [US-ASCII] 2239 American National Standards Institute (formerly United 2240 States of America Standards Institute), "USA Code for 2241 Information Interchange, X3.4", 1968. 2243 ANSI X3.4-1968 has been replaced by newer versions with 2244 slight modifications, but the 1968 version remains 2245 definitive for the Internet. 2247 13.2. Informative References 2249 [DMP] Fecyk, G., "Designated Mailers Protocol". 2251 Work In Progress 2253 [Green] Green, D., "Domain-Authorized SMTP Mail", 2002. 2255 [RFC1034] Mockapetris, P., "Domain names - concepts and facilities", 2256 STD 13, RFC 1034, November 1987. 2258 [RFC1983] Malkin, G., "Internet Users' Glossary", RFC 1983, 2259 August 1996. 2261 [RFC2308] Andrews, M., "Negative Caching of DNS Queries (DNS 2262 NCACHE)", RFC 2308, March 1998. 2264 [RFC2782] Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for 2265 specifying the location of services (DNS SRV)", RFC 2782, 2266 February 2000. 2268 [RFC3464] Moore, K. and G. Vaudreuil, "An Extensible Message Format 2269 for Delivery Status Notifications", RFC 3464, 2270 January 2003. 2272 [RFC3696] Klensin, J., "Application Techniques for Checking and 2273 Transformation of Names", RFC 3696, February 2004. 2275 [RFC3833] Atkins, D. and R. Austein, "Threat Analysis of the Domain 2276 Name System (DNS)", RFC 3833, August 2004. 2278 [RFC3834] Moore, K., "Recommendations for Automatic Responses to 2279 Electronic Mail", RFC 3834, August 2004. 2281 [RFC4408] Wong, M. and W. Schlitt, "Sender Policy Framework (SPF) 2282 for Authorizing Use of Domains in E-Mail, Version 1", 2283 RFC 4408, April 2006. 2285 [RFC4632] Fuller, V. and T. Li, "Classless Inter-domain Routing 2286 (CIDR): The Internet Address Assignment and Aggregation 2287 Plan", BCP 122, RFC 4632, August 2006. 2289 [RFC4880] Callas, J., Donnerhacke, L., Finney, H., Shaw, D., and R. 2290 Thayer, "OpenPGP Message Format", RFC 4880, November 2007. 2292 [RFC4954] Siemborski, R. and A. Melnikov, "SMTP Service Extension 2293 for Authentication", RFC 4954, July 2007. 2295 [RFC5751] Ramsdell, B. and S. Turner, "Secure/Multipurpose Internet 2296 Mail Extensions (S/MIME) Version 3.2 Message 2297 Specification", RFC 5751, January 2010. 2299 [RFC5782] Levine, J., "DNS Blacklists and Whitelists", RFC 5782, 2300 February 2010. 2302 [RFC6409] Gellens, R. and J. Klensin, "Message Submission for Mail", 2303 STD 72, RFC 6409, November 2011. 2305 [RFC6647] Kucherawy, M. and D. Crocker, "Email Greylisting: An 2306 Applicability Statement for SMTP", RFC 6647, June 2012. 2308 [RFC6652] Kitterman, S., "Sender Policy Framework (SPF) 2309 Authentication Failure Reporting Using the Abuse Reporting 2310 Format", RFC 6652, June 2012. 2312 [RFC6686] Kucherawy, M., "Resolution of the Sender Policy Framework 2313 (SPF) and Sender ID Experiments", RFC 6686, July 2012. 2315 [RMX] Danisch, H., "The RMX DNS RR Type for light weight sender 2316 authentication". 2318 Work In Progress 2320 [Vixie] Vixie, P., "Repudiating MAIL FROM", 2002. 2322 Appendix A. Collected ABNF 2324 This section is normative and any discrepancies with the ABNF 2325 fragments in the preceding text are to be resolved in favor of this 2326 grammar. 2328 See [RFC5234] for ABNF notation. Please note that as per this ABNF 2329 definition, literal text strings (those in quotes) are case- 2330 insensitive. Hence, "mx" matches "mx", "MX", "mX", and "Mx". 2332 record = version terms *SP 2333 version = "v=spf1" 2335 terms = *( 1*SP ( directive / modifier ) ) 2337 directive = [ qualifier ] mechanism 2338 qualifier = "+" / "-" / "?" / "~" 2339 mechanism = ( all / include 2340 / A / MX / PTR / IP4 / IP6 / exists ) 2342 all = "all" 2343 include = "include" ":" domain-spec 2344 A = "a" [ ":" domain-spec ] [ dual-cidr-length ] 2345 MX = "mx" [ ":" domain-spec ] [ dual-cidr-length ] 2346 PTR = "ptr" [ ":" domain-spec ] 2347 IP4 = "ip4" ":" ip4-network [ ip4-cidr-length ] 2348 IP6 = "ip6" ":" ip6-network [ ip6-cidr-length ] 2349 exists = "exists" ":" domain-spec 2351 modifier = redirect / explanation / unknown-modifier 2352 redirect = "redirect" "=" domain-spec 2353 explanation = "exp" "=" domain-spec 2354 unknown-modifier = name "=" macro-string 2355 ; where name is not any known modifier 2357 ip4-cidr-length = "/" 1*DIGIT 2358 ip6-cidr-length = "/" 1*DIGIT 2359 dual-cidr-length = [ ip4-cidr-length ] [ "/" ip6-cidr-length ] 2361 ip4-network = qnum "." qnum "." qnum "." qnum 2362 qnum = DIGIT ; 0-9 2363 / %x31-39 DIGIT ; 10-99 2364 / "1" 2DIGIT ; 100-199 2365 / "2" %x30-34 DIGIT ; 200-249 2366 / "25" %x30-35 ; 250-255 2367 ; conventional dotted quad notation. e.g., 192.0.2.0 2368 ip6-network = 2369 ; e.g., 2001:DB8::CD30 2371 domain-spec = macro-string domain-end 2372 domain-end = ( "." toplabel [ "." ] ) / macro-expand 2374 toplabel = ( *alphanum ALPHA *alphanum ) / 2375 ( 1*alphanum "-" *( alphanum / "-" ) alphanum ) 2376 ; LDH rule plus additional TLD restrictions 2377 ; (see [RFC3696], Section 2 for background) 2378 alphanum = ALPHA / DIGIT 2380 explain-string = *( macro-string / SP ) 2382 macro-string = *( macro-expand / macro-literal ) 2383 macro-expand = ( "%{" macro-letter transformers *delimiter "}" ) 2384 / "%%" / "%_" / "%-" 2385 macro-literal = %x21-24 / %x26-7E 2386 ; visible characters except "%" 2387 macro-letter = "s" / "l" / "o" / "d" / "i" / "p" / "h" / 2388 "c" / "r" / "t" / "v" 2389 transformers = *DIGIT [ "r" ] 2390 delimiter = "." / "-" / "+" / "," / "/" / "_" / "=" 2392 name = ALPHA *( ALPHA / DIGIT / "-" / "_" / "." ) 2394 header-field = "Received-SPF:" [CFWS] result FWS [comment FWS] 2395 [ key-value-list ] CRLF 2397 result = "pass" / "fail" / "softfail" / "neutral" / 2398 "none" / "temperror" / "permerror" 2400 key-value-list = key-value-pair *( ";" [CFWS] key-value-pair ) 2401 [";"] 2403 key-value-pair = key [CFWS] "=" ( dot-atom / quoted-string ) 2405 key = "client-ip" / "envelope-from" / "helo" / 2406 "problem" / "receiver" / identity / 2407 mechanism / name 2409 identity = "mailfrom" ; for the "MAIL FROM" identity 2410 / "helo" ; for the "HELO" identity 2411 / name ; other identities 2413 ALPHA = 2414 DIGIT = <0-9 as per [RFC5234]> 2415 SP = 2416 domain = 2417 dot-atom = 2418 quoted-string = 2419 comment = 2420 CFWS = 2421 FWS = 2422 CRLF = 2423 authserv-id = 2424 reasonspec = 2426 Appendix B. Extended Examples 2428 These examples are based on the following DNS setup: 2430 ; A domain with two mail servers, two hosts 2431 ; and two servers at the domain name 2432 $ORIGIN example.com. 2433 @ MX 10 mail-a 2434 MX 20 mail-b 2435 A 192.0.2.10 2436 A 192.0.2.11 2437 amy A 192.0.2.65 2438 bob A 192.0.2.66 2439 mail-a A 192.0.2.129 2440 mail-b A 192.0.2.130 2441 www CNAME example.com. 2443 ; A related domain 2444 $ORIGIN example.org. 2445 @ MX 10 mail-c 2446 mail-c A 192.0.2.140 2448 ; The reverse IP for those addresses 2449 $ORIGIN 2.0.192.in-addr.arpa. 2450 10 PTR example.com. 2451 11 PTR example.com. 2452 65 PTR amy.example.com. 2453 66 PTR bob.example.com. 2454 129 PTR mail-a.example.com. 2455 130 PTR mail-b.example.com. 2456 140 PTR mail-c.example.org. 2458 ; A rogue reverse IP domain that claims to be 2459 ; something it's not 2460 $ORIGIN 0.0.10.in-addr.arpa. 2461 4 PTR bob.example.com. 2463 B.1. Simple Examples 2465 These examples show various possible published records for 2466 example.com and which values if would cause check_host() to 2467 return "pass". Note that is "example.com". 2469 v=spf1 +all 2470 -- any passes 2472 v=spf1 a -all 2473 -- hosts 192.0.2.10 and 192.0.2.11 pass 2475 v=spf1 a:example.org -all 2476 -- no sending hosts pass since example.org has no A records 2478 v=spf1 mx -all 2479 -- sending hosts 192.0.2.129 and 192.0.2.130 pass 2481 v=spf1 mx:example.org -all 2482 -- sending host 192.0.2.140 passes 2484 v=spf1 mx mx:example.org -all 2485 -- sending hosts 192.0.2.129, 192.0.2.130, and 192.0.2.140 pass 2487 v=spf1 mx/30 mx:example.org/30 -all 2488 -- any sending host in 192.0.2.128/30 or 192.0.2.140/30 passes 2490 v=spf1 ptr -all 2491 -- sending host 192.0.2.65 passes (reverse DNS is valid and is in 2492 example.com) 2493 -- sending host 192.0.2.140 fails (reverse DNS is valid, but not 2494 in example.com) 2495 -- sending host 10.0.0.4 fails (reverse IP is not valid) 2497 v=spf1 ip4:192.0.2.128/28 -all 2498 -- sending host 192.0.2.65 fails 2499 -- sending host 192.0.2.129 passes 2501 B.2. Multiple Domain Example 2503 These examples show the effect of related records: 2505 example.org: "v=spf1 include:example.com include:example.net -all" 2507 This record would be used if mail from example.org actually came 2508 through servers at example.com and example.net. Example.org's 2509 designated servers are the union of example.com's and example.net's 2510 designated servers. 2512 la.example.org: "v=spf1 redirect=example.org" 2513 ny.example.org: "v=spf1 redirect=example.org" 2514 sf.example.org: "v=spf1 redirect=example.org" 2516 These records allow a set of domains that all use the same mail 2517 system to make use of that mail system's record. In this way, only 2518 the mail system's record needs to be updated when the mail setup 2519 changes. These domains' records never have to change. 2521 B.3. DNSBL Style Example 2523 Imagine that, in addition to the domain records listed above, there 2524 are these: 2526 $ORIGIN _spf.example.com. 2527 mary.mobile-users A 127.0.0.2 2528 fred.mobile-users A 127.0.0.2 2529 15.15.168.192.joel.remote-users A 127.0.0.2 2530 16.15.168.192.joel.remote-users A 127.0.0.2 2532 The following records describe users at example.com who mail from 2533 arbitrary servers, or who mail from personal servers. 2535 example.com: 2537 v=spf1 mx 2538 include:mobile-users._spf.%{d} 2539 include:remote-users._spf.%{d} 2540 -all 2542 mobile-users._spf.example.com: 2544 v=spf1 exists:%{l1r+}.%{d} 2546 remote-users._spf.example.com: 2548 v=spf1 exists:%{ir}.%{l1r+}.%{d} 2550 B.4. Multiple Requirements Example 2552 Say that your sender policy requires both that the IP address is 2553 within a certain range and that the reverse DNS for the IP matches. 2554 This can be done several ways, including the following: 2556 example.com. SPF ( "v=spf1 " 2557 "-include:ip4._spf.%{d} " 2558 "-include:ptr._spf.%{d} " 2559 "+all" ) 2560 ip4._spf.example.com. SPF "v=spf1 -ip4:192.0.2.0/24 +all" 2561 ptr._spf.example.com. SPF "v=spf1 -ptr +all" 2563 This example shows how the "-include" mechanism can be useful, how an 2564 SPF record that ends in "+all" can be very restrictive, and the use 2565 of De Morgan's Law. 2567 Appendix C. Change History 2569 Changes since RFC 4408 (to be removed prior to publication) 2571 Moved to standards track 2573 Authors updated 2575 IESG Note regarding experimental use replaced with discussion of 2576 results 2578 Process errata: 2580 Resolved Section 2.5.7 PermError on invalid domains after macro 2581 expansion errata in favor of documenting that different clients 2582 produce different results. 2584 Add %v macro to ABNF grammar 2586 Replace "uric" by "unreserved" 2588 Recommend an SMTP reply code for optional permerror rejections 2590 Correct syntax in Received-SPF examples 2592 Fix unknown-modifier clause is too greedy in ABNF 2594 Correct use of empty domain-spec on exp modifier 2596 Fix minor typo errata 2598 Convert to spfbis working group draft, 2599 draft-ietf-spfbis-4408bis-00 2601 Addressed Ticket #1, RFC 4408 Section 2.5.6 - Temporary errors by 2602 giving the option to turn repeated SERVFAIL into permerror and 2603 adding RFC 2308 reference. 2605 Clarified text about IPv4 mapped addresses to resolve test suite 2606 ambiguity 2608 Clarified ambiguity about result when more than 10 "mx" or "ptr" 2609 records are returned for lookup to specify permerror. This 2610 resolves one of the test suite ambiguities 2612 Made all references to result codes lower case per issue #7 2613 Adjusted section 2.2 Requirement to check mail from per issue #15 2615 Added missing "v" element in macro-letter in the collected ABNF 2616 per issue #16 - section 8.1 was already fixed in the pre-WG draft 2618 Marked ptr and "p" macro deprecated/SHOULD NOT use per issue #27 2620 Expunged lower case may from the draft per issue #8 2622 Expunged "x-" name as an obsolete concept 2624 Updated obslete references: RFC2821 to RFC5321, RFC2822 to 2625 RFC5322, and RFC4234 to RFC5234 2627 Refer to RFC6647 to describe greylisting instead of trying to 2628 describe it directly. 2630 Updated informative references to the current versions. 2632 Added definition for deprecated since there are questions. 2634 Start to rework section 9 with some RFC5598 terms. 2636 Added mention of RFC 6552 feedback reports in section 9. 2638 Added draft-ietf-spfbis-experiment as an informational reference. 2640 Drop Type SPF. 2642 Try and clarify informational nature of RFC3696 2644 Fix ABNF nits and add missing definitions per Bill's ABNF checker. 2646 Make DNS lookup time limit SHOULD instead of MAY. 2648 Reorganize and clarify processing limits. Move hard limits to new 2649 section 4.6.4, Evaluation Limits. Move advice to non-normative 2650 section 9. 2652 Removed paragraph in section 10.1 about limiting total data 2653 volumes as it is unused (and removable per the charter) and serves 2654 no purpose (it isn't something that actually can be implemented in 2655 any reasonable way). 2657 Added text and figures from Alessandro Vesely in section 9.1 to 2658 better explain DNS resource limits. 2660 Multiple editorial fixes from Murray Kucherawy's review. 2662 Also based on Murray's review, reworked SMTP identity definitions 2663 and made RFC 5598 a normative reference instead of informative. 2664 This is a downref that will have to be mentioned in the last call. 2666 Added RFC 3834 as an informative reference about backscatter. 2668 Added IDN requirements and normative reference to RFC 5890 to deal 2669 with the question "like DKIM did it.: 2671 Added informative reference to RFC 4632 for CIDR and use CIDR 2672 prefix length instead of CIDR-length to match its terminology. 2674 Added RFC 5782 informative reference on DNSxLs to support 2675 improving the exists description. 2677 Added text on creating a Authentication-Results header field that 2678 matches the Received-SPF header field information and added a 2679 normative reference to RFC 5451. 2681 Added informative reference to RFC 2782 due to SRV mention. 2683 Added informative reference to RFC 3464 due to DSN mention. 2685 Added informative reference to RFC 5617 for it's DNS wildcard use. 2687 Added informative reference to RFC 5782 to enhance the explanation 2688 of how the exists mechanism works. Clarified the intended match/ 2689 no-match method. 2691 Added new sections on Receiver policy for SPF pass, fail, and 2692 permerror. 2694 Added new section 9 discussion on treatment of bounces and the 2695 significance of HELO records. 2697 Added request to IANA to update the SPF modifier registry. 2699 Author's Address 2701 Scott Kitterman 2702 Kitterman Technical Services 2703 3611 Scheel Dr 2704 Ellicott City, MD 21042 2705 United States of America 2707 Email: scott@kitterman.com