idnits 2.17.1 draft-ietf-uta-mta-sts-18.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 2 instances of too long lines in the document, the longest one being 8 characters in excess of 72. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year ** The document contains RFC2119-like boilerplate, but doesn't seem to mention RFC 2119. The boilerplate contains a reference [BCP 14], but that reference does not seem to mention RFC 2119 either. -- The document date (May 20, 2018) is 2168 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. 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: 'BCP 14' is mentioned on line 127, but not defined == Missing Reference: 'CRLF' is mentioned on line 305, but not defined -- Looks like a reference, but probably isn't: '0' on line 1096 -- Looks like a reference, but probably isn't: '1' on line 1098 == Outdated reference: A later version (-23) exists of draft-ietf-uta-smtp-tlsrpt-20 ** Obsolete normative reference: RFC 2818 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) ** Obsolete normative reference: RFC 5785 (Obsoleted by RFC 8615) ** Obsolete normative reference: RFC 6125 (Obsoleted by RFC 9525) ** Obsolete normative reference: RFC 7525 (Obsoleted by RFC 9325) -- Obsolete informational reference (is this intentional?): RFC 7234 (Obsoleted by RFC 9111) Summary: 7 errors (**), 0 flaws (~~), 4 warnings (==), 5 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Using TLS in Applications D. Margolis 3 Internet-Draft M. Risher 4 Intended status: Standards Track Google, Inc 5 Expires: November 21, 2018 B. Ramakrishnan 6 Yahoo!, Inc 7 A. Brotman 8 Comcast, Inc 9 J. Jones 10 Microsoft, Inc 11 May 20, 2018 13 SMTP MTA Strict Transport Security (MTA-STS) 14 draft-ietf-uta-mta-sts-18 16 Abstract 18 SMTP Mail Transfer Agent Strict Transport Security (MTA-STS) is a 19 mechanism enabling mail service providers to declare their ability to 20 receive Transport Layer Security (TLS) secure SMTP connections, and 21 to specify whether sending SMTP servers should refuse to deliver to 22 MX hosts that do not offer TLS with a trusted server certificate. 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 November 21, 2018. 41 Copyright Notice 43 Copyright (c) 2018 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 Table of Contents 58 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 59 1.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 3 60 2. Related Technologies . . . . . . . . . . . . . . . . . . . . 4 61 3. Policy Discovery . . . . . . . . . . . . . . . . . . . . . . 4 62 3.1. MTA-STS TXT Records . . . . . . . . . . . . . . . . . . . 4 63 3.2. MTA-STS Policies . . . . . . . . . . . . . . . . . . . . 6 64 3.3. HTTPS Policy Fetching . . . . . . . . . . . . . . . . . . 9 65 3.4. Policy Selection for Smart Hosts and Subdomains . . . . . 10 66 4. Policy Validation . . . . . . . . . . . . . . . . . . . . . . 10 67 4.1. MX Host Validation . . . . . . . . . . . . . . . . . . . 11 68 4.2. Recipient MTA Certificate Validation . . . . . . . . . . 11 69 5. Policy Application . . . . . . . . . . . . . . . . . . . . . 11 70 5.1. Policy Application Control Flow . . . . . . . . . . . . . 12 71 6. Reporting Failures . . . . . . . . . . . . . . . . . . . . . 12 72 7. Interoperability Considerations . . . . . . . . . . . . . . . 13 73 7.1. SNI Support . . . . . . . . . . . . . . . . . . . . . . . 13 74 7.2. Minimum TLS Version Support . . . . . . . . . . . . . . . 13 75 8. Operational Considerations . . . . . . . . . . . . . . . . . 13 76 8.1. Policy Updates . . . . . . . . . . . . . . . . . . . . . 13 77 8.2. Policy Delegation . . . . . . . . . . . . . . . . . . . . 14 78 8.3. Removing MTA-STS . . . . . . . . . . . . . . . . . . . . 15 79 8.4. Preserving MX Candidate Traversal . . . . . . . . . . . . 15 80 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 16 81 9.1. Well-Known URIs Registry . . . . . . . . . . . . . . . . 16 82 9.2. MTA-STS TXT Record Fields . . . . . . . . . . . . . . . . 16 83 9.3. MTA-STS Policy Fields . . . . . . . . . . . . . . . . . . 16 84 10. Security Considerations . . . . . . . . . . . . . . . . . . . 17 85 10.1. Obtaining a Signed Certificate . . . . . . . . . . . . . 17 86 10.2. Preventing Policy Discovery . . . . . . . . . . . . . . 18 87 10.3. Denial of Service . . . . . . . . . . . . . . . . . . . 18 88 10.4. Weak Policy Constraints . . . . . . . . . . . . . . . . 19 89 10.5. Compromise of the Web PKI System . . . . . . . . . . . . 19 90 11. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 20 91 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 20 92 12.1. Normative References . . . . . . . . . . . . . . . . . . 20 93 12.2. Informative References . . . . . . . . . . . . . . . . . 22 94 Appendix A. MTA-STS example record & policy . . . . . . . . . . 23 95 Appendix B. Message delivery pseudocode . . . . . . . . . . . . 23 96 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 25 98 1. Introduction 100 The STARTTLS extension to SMTP [RFC3207] allows SMTP clients and 101 hosts to negotiate the use of a TLS channel for encrypted mail 102 transmission. 104 While this opportunistic encryption protocol by itself provides a 105 high barrier against passive man-in-the-middle traffic interception, 106 any attacker who can delete parts of the SMTP session (such as the 107 "250 STARTTLS" response) or who can redirect the entire SMTP session 108 (perhaps by overwriting the resolved MX record of the delivery 109 domain) can perform downgrade or interception attacks. 111 This document defines a mechanism for recipient domains to publish 112 policies, via a combination of DNS and HTTPS, specifying: 114 o whether MTAs sending mail to this domain can expect PKIX- 115 authenticated TLS support 117 o what a conforming client should do with messages when TLS cannot 118 be successfully negotiated 120 1.1. Terminology 122 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 123 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 124 "OPTIONAL" in this document are to be interpreted as described in 125 [BCP 14] [RFC2119] [RFC8174] when, and only when, they appear in all 126 capitals, as shown here. 128 We also define the following terms for further use in this document: 130 o MTA-STS Policy: A commitment by the Policy Domain to support PKIX 131 [RFC5280] authenticated TLS for the specified MX hosts. 133 o Policy Domain: The domain for which an MTA-STS Policy is defined. 134 This is the next-hop domain; when sending mail to 135 "alice@example.com" this would ordinarily be "example.com", but 136 this may be overridden by explicit routing rules (as described in 137 Section 3.4, "Policy Selection for Smart Hosts and Subdomains"). 139 o Policy Host: The HTTPS host which serves the MTA-STS Policy for a 140 Policy Domain. Rules for constructing the hostname are described 141 in Section 3.2, "MTA-STS Policies". 143 o Sender: The SMTP Mail Transfer Agent sending an email message. 145 2. Related Technologies 147 The DANE TLSA record [RFC7672] is similar, in that DANE is also 148 designed to upgrade unauthenticated encryption or plaintext 149 transmission into authenticated, downgrade-resistant encrypted 150 transmission. DANE requires DNSSEC [RFC4033] for authentication; the 151 mechanism described here instead relies on certificate authorities 152 (CAs) and does not require DNSSEC, at a cost of risking malicious 153 downgrades. For a thorough discussion of this trade-off, see 154 Section 10, "Security Considerations". 156 In addition, MTA-STS provides an optional testing-only mode, enabling 157 soft deployments to detect policy failures; partial deployments can 158 be achieved in DANE by deploying TLSA records only for some of a 159 domain's MXs, but such a mechanism is not possible for the per-domain 160 policies used by MTA-STS. 162 The primary motivation of MTA-STS is to provide a mechanism for 163 domains to ensure transport security even when deploying DNSSEC is 164 undesirable or impractical. However, MTA-STS is designed not to 165 interfere with DANE deployments when the two overlap; in particular, 166 senders who implement MTA-STS validation MUST NOT allow a "valid" or 167 "testing"-only MTA-STS validation to override a failing DANE 168 validation. 170 3. Policy Discovery 172 MTA-STS policies are distributed via HTTPS from a "well-known" 173 [RFC5785] path served within the Policy Domain, and their presence 174 and current version are indicated by a TXT record at the Policy 175 Domain. These TXT records additionally contain a policy "id" field, 176 allowing sending MTAs to check the currency of a cached policy 177 without performing an HTTPS request. 179 To discover if a recipient domain implements MTA-STS, a sender need 180 only resolve a single TXT record. To see if an updated policy is 181 available for a domain for which the sender has a previously cached 182 policy, the sender need only check the TXT record's version "id" 183 against the cached value. 185 3.1. MTA-STS TXT Records 187 The MTA-STS TXT record is a TXT record with the name "_mta-sts" at 188 the Policy Domain. For the domain "example.com", this record would 189 be "_mta-sts.example.com". MTA-STS TXT records MUST be US-ASCII, 190 semicolon-separated key/value pairs containing the following fields: 192 o "v": (plain-text, required). Currently only "STSv1" is supported. 194 o "id": (plain-text, required). A short string used to track policy 195 updates. This string MUST uniquely identify a given instance of a 196 policy, such that senders can determine when the policy has been 197 updated by comparing to the "id" of a previously seen policy. 198 There is no implied ordering of "id" fields between revisions. 200 An example TXT record is as below: 202 "_mta-sts.example.com. IN TXT "v=STSv1; id=20160831085700Z;"" 204 The formal definition of the "_mta-sts" TXT record, defined using 205 [RFC7405], is as follows: 207 sts-text-record = sts-version 1*(field-delim sts-field) [field-delim] 209 sts-field = sts-id / ; Note that sts-id record 210 sts-extension ; is required. 212 field-delim = *WSP ";" *WSP 214 sts-version = %s"v=STSv1" 216 sts-id = %s"id=" 1*32(ALPHA / DIGIT) ; id=... 218 sts-extension = sts-ext-name "=" sts-ext-value ; name=value 220 sts-ext-name = (ALPHA / DIGIT) 221 *31(ALPHA / DIGIT / "_" / "-" / ".") 223 sts-ext-value = 1*(%x21-3A / %x3C / %x3E-7E) 224 ; chars excluding "=", ";", and control chars 226 The TXT record MUST begin with sts-version field, and the order of 227 other fields is not significant. If multiple TXT records for "_mta- 228 sts" are returned by the resolver, records which do not begin with 229 "v=STSv1;" are discarded. If the number of resulting records is not 230 one, senders MUST assume the recipient domain does not have an 231 available MTA-STS policy and skip the remaining steps of policy 232 discovery. (Note that lack of an available policy does not signal 233 opting out of MTA-STS altogether if the sender has a previously 234 cached policy for the recipient domain, as discussed in Section 5.1, 235 "Policy Application Control Flow".) If the resulting TXT record 236 contains multiple strings, then the record MUST be treated as if 237 those strings are concatenated together without adding spaces. 239 3.2. MTA-STS Policies 241 The policy itself is a set of key/value pairs (similar to [RFC5322] 242 header fields) served via the HTTPS GET method from the fixed 243 [RFC5785] "well-known" path of ".well-known/mta-sts.txt" served by 244 the Policy Host. The Policy Host DNS name is constructed by 245 prepending "mta-sts" to the Policy Domain. 247 Thus for a Policy Domain of "example.com" the path is "https://mta- 248 sts.example.com/.well-known/mta-sts.txt". 250 When fetching a policy, senders SHOULD validate that the media type 251 is "text/plain" to guard against cases where webservers allow 252 untrusted users to host non-text content (typically, HTML or images) 253 at a user-defined path. All parameters other than charset=utf-8 or 254 charset=us-ascii are ignored. Additional "Content-Type" parameters 255 are also ignored. 257 This resource contains the following CRLF-separated key/value pairs: 259 o "version": Currently only "STSv1" is supported. 261 o "mode": One of "enforce", "testing", or "none", indicating the 262 expected behavior of a sending MTA in the case of a policy 263 validation failure. See Section 5, "Policy Application." for more 264 details about the three modes. 266 o "max_age": Max lifetime of the policy (plain-text non-negative 267 integer seconds, maximum value of 31557600). Well-behaved clients 268 SHOULD cache a policy for up to this value from last policy fetch 269 time. To mitigate the risks of attacks at policy refresh time, it 270 is expected that this value typically be in the range of weeks or 271 greater. 273 o "mx": Allowed MX patterns. One or more patterns matching allowed 274 MX hosts for the Policy Domain. As an example, 276 mx: mail.example.com 277 mx: *.example.net 279 indicates that mail for this domain might be handled by MX 280 "mail.example.com" or any MX at "example.net". Valid patterns can be 281 either fully specified names ("example.com") or suffixes prefixed by 282 a wildcard ("*.example.net"). If a policy specifies more than one 283 MX, each MX MUST have its own "mx:" key, and each MX key/value pair 284 MUST be on its own line in the policy file. In the case of 285 Internationalized Domain Names ([RFC5891]), the "mx" value MUST 286 specify the Punycode-encoded A-label [RFC3492] to match against, and 287 not the Unicode-encoded U-label. The full semantics of certificate 288 validation (including the use of wildcard patterns) are described in 289 Section 4.1, "MX Host Validation." 291 An example policy is as below: 293 version: STSv1 294 mode: enforce 295 mx: mail.example.com 296 mx: *.example.net 297 mx: backupmx.example.com 298 max_age: 604800 300 The formal definition of the policy resource, defined using 301 [RFC7405], is as follows: 303 sts-policy-record = sts-policy-field *WSP 304 *(CRLF sts-policy-field *WSP) 305 [CRLF] 307 sts-policy-field = sts-policy-version / ; required once 308 sts-policy-mode / ; required once 309 sts-policy-max-age / ; required once 311 0*(sts-policy-mx *WSP CRLF) / 312 ; required at least once, except when 313 ; mode is "none" 315 sts-policy-extension ; other fields 317 field-delim = ":" *WSP 319 sts-policy-version = sts-policy-version-field field-delim 320 sts-policy-version-value 322 sts-policy-version-field = %s"version" 324 sts-policy-version-value = %s"STSv1" 326 sts-policy-mode = sts-policy-mode-field field-delim 327 sts-policy-mode-value 329 sts-policy-mode-field = %s"mode" 331 sts-policy-mode-value = %s"testing" / %s"enforce" / %s"none" 333 sts-policy-mx = sts-policy-mx-field field-delim 334 sts-policy-mx-value 336 sts-policy-mx-field = %s"mx" 338 sts-policy-mx-value = ["*."] *(sts-policy-mx-label ".") 339 sts-policy-mx-toplabel 341 sts-policy-mx-label = sts-policy-alphanum | 342 sts-policy-alphanum *(sts-policy-alphanum | "-") 343 sts-policy-alphanum 345 sts-policy-mx-toplabel = ALPHA | ALPHA *(sts-policy-alphanum | "-") 346 sts-policy-alphanum 348 sts-policy-max-age = sts-policy-max-age-field field-delim 349 sts-policy-max-age-value 351 sts-policy-max-age-field = %s"max_age" 353 sts-policy-max-age-value = 1*10(DIGIT) 355 sts-policy-extension = sts-policy-ext-name ; additional 356 field-delim ; extension 357 sts-policy-ext-value ; fields 359 sts-policy-ext-name = (sts-policy-alphanum) 360 *31(sta-policy-alphanum / "_" / "-" / ".") 362 sts-policy-term = CRLF / LF 364 sts-policy-ext-value = sts-policy-vchar 365 [*(%x20 / sts-policy-vchar) 366 sts-policy-vchar] 367 ; chars, including UTF-8 [@?RFC3629], 368 ; excluding CTLs and no 369 ; leading/trailing spaces 371 sts-policy-alphanum = ALPHA | DIGIT 373 sts-policy-vchar = %x21-7E / UTF8-2 / UTF8-3 / UTF8-4 375 Parsers MUST accept TXT records and policy files which are 376 syntactically valid (i.e., valid key/value pairs separated by semi- 377 colons for TXT records) and but containing additional key/value pairs 378 not specified in this document, in which case unknown fields SHALL be 379 ignored. If any non-repeated field--i.e., all fields excepting "mx" 380 --is duplicated, all entries except for the first SHALL be ignored. 381 If any field is not specified, the policy SHALL be treated as 382 invalid. 384 3.3. HTTPS Policy Fetching 386 Policy bodies are, as described above, retrieved by sending MTAs via 387 HTTPS [RFC2818]. During the TLS handshake initiated to fetch a new 388 or updated policy from the Policy Host, the Policy Host HTTPS server 389 MUST present a X.509 certificate which is valid for the "mta-sts" 390 DNS-ID ([RFC6125]) (e.g., "mta-sts.example.com") as described below, 391 chain to a root CA that is trusted by the sending MTA, and be non- 392 expired. It is expected that sending MTAs use a set of trusted CAs 393 similar to those in widely deployed Web browsers and operating 394 systems. See [RFC5280] for more details about certificate 395 verification. 397 The certificate is valid for the Policy Host (i.e., "mta-sts" 398 prepended to the Policy Domain) with respect to the rules described 399 in [RFC6125], with the following application-specific considerations: 401 o Matching is performed only against the DNS-ID identifiers. 403 o DNS domain names in server certificates MAY contain the wildcard 404 character '*' as the complete left-most label within the 405 identifier. 407 The certificate MAY be checked for revocation via the Online 408 Certificate Status Protocol (OCSP) [RFC6960], certificate revocation 409 lists (CRLs), or some other mechanism. 411 Policies fetched via HTTPS are only valid if the HTTP response code 412 is 200 (OK). HTTP 3xx redirects MUST NOT be followed, and HTTP 413 caching (as specified in [RFC7234]) MUST NOT be used. 415 Senders may wish to rate-limit the frequency of attempts to fetch the 416 HTTPS endpoint even if a valid TXT record for the recipient domain 417 exists. In the case that the HTTPS GET fails, we implementions 418 SHOULD limit further attempts to a period of five minutes or longer 419 per version ID, to avoid overwhelming resource-constrained recipients 420 with cascading failures. 422 Senders MAY impose a timeout on the HTTPS GET and/or a limit on the 423 maximum size of the response body to avoid long delays or resource 424 exhaustion during attempted policy updates. A suggested timeout is 425 one minute, and a suggested maximum policy size 64 kilobytes; policy 426 hosts SHOULD respond to requests with a complete policy body within 427 that timeout and size limit. 429 If a valid TXT record is found but no policy can be fetched via HTTPS 430 (for any reason), and there is no valid (non-expired) previously- 431 cached policy, senders MUST continue with delivery as though the 432 domain has not implemented MTA-STS. 434 Conversely, if no "live" policy can be discovered via DNS or fetched 435 via HTTPS, but a valid (non-expired) policy exists in the sender's 436 cache, the sender MUST apply that cached policy. 438 Finally, to mitigate the risk of persistent interference with policy 439 refresh, as discussed in-depth in Section 10, MTAs SHOULD proactively 440 refresh cached policies before they expire; a suggested refresh 441 frequency is once per day. To enable administrators to discover 442 problems with policy refresh, MTAs SHOULD alert administrators 443 (through the use of logs or similar) when such attempts fail, unless 444 the cached policy mode is "none". 446 3.4. Policy Selection for Smart Hosts and Subdomains 448 When sending mail via a "smart host"--an administratively configured 449 intermediate SMTP relay, which is different from the message 450 recipient's server as determined from DNS --compliant senders MUST 451 treat the smart host domain as the policy domain for the purposes of 452 policy discovery and application. 454 When sending mail to a mailbox at a subdomain, compliant senders MUST 455 NOT attempt to fetch a policy from the parent zone. Thus for mail 456 sent to "user@mail.example.com", the policy can be fetched only from 457 "mail.example.com", not "example.com". 459 4. Policy Validation 461 When sending to an MX at a domain for which the sender has a valid 462 and non-expired MTA-STS policy, a sending MTA honoring MTA-STS MUST 463 check whether: 465 1. At least one of the policy's "mx" patterns matches the selected 466 MX host, as described in Section 4.1, "MX Host Validation". 468 2. The recipient mail server supports STARTTLS and offers a PKIX- 469 based TLS certificate, during TLS handshake, which is valid for 470 that host, as described in Section 4.2, "Recipient MTA 471 Certificate Validation". 473 When these conditions are not met, a policy is said to fail to 474 validate. This section does not dictate the behavior of sending MTAs 475 when the above conditions are not met; see Section 5, "Policy 476 Application" for a description of sending MTA behavior when policy 477 validation fails. 479 4.1. MX Host Validation 481 A receiving candidate MX host is valid according to an applied MTA- 482 STS policy if the MX record name matches one or more of the "mx" 483 fields in the applied policy. Matching is identical to the rules 484 given in [RFC6125], with restriction that the wildcard character "*" 485 may only be used to match the entire left-most label in the presented 486 identifier. Thus the mx pattern "*.example.com" matches 487 "mail.example.com" but not "example.com" or "foo.bar.example.com". 489 4.2. Recipient MTA Certificate Validation 491 The certificate presented by the receiving MTA MUST chain to a root 492 CA that is trusted by the sending MTA and be non-expired. The 493 certificate MUST have a subject alternative name (SAN, [RFC5280]) 494 with a DNS-ID ([RFC6125]) matching the host name, per the rules given 495 in [RFC6125]. The MX's certificate MAY also be checked for 496 revocation via OCSP [RFC6960], CRLs [RFC6818], or some other 497 mechanism. 499 5. Policy Application 501 When sending to an MX at a domain for which the sender has a valid, 502 non-expired MTA-STS policy, a sending MTA honoring MTA-STS applies 503 the result of a policy validation failure one of two ways, depending 504 on the value of the policy "mode" field: 506 1. "enforce": In this mode, sending MTAs MUST NOT deliver the 507 message to hosts which fail MX matching or certificate 508 validation, or do not support STARTTLS. 510 2. "testing": In this mode, sending MTAs which also implement the 511 TLSRPT specification [I-D.ietf-uta-smtp-tlsrpt] merely send a 512 report indicating policy application failures (so long as TLSRPT 513 is also implemented by the recipient domain). 515 3. "none": In this mode, sending MTAs should treat the policy domain 516 as though it does not have any active policy; see Section 8.3, 517 "Removing MTA-STS", for use of this mode value. 519 When a message fails to deliver due to an "enforce" policy, a 520 compliant MTA MUST NOT permanently fail to deliver messages before 521 checking, via DNS, for the presence of an updated policy at the 522 Policy Domain. (In all cases, MTAs SHOULD treat such failures as 523 transient errors and retry delivery later.) This allows implementing 524 domains to update long-lived policies on the fly. 526 5.1. Policy Application Control Flow 528 An example control flow for a compliant sender consists of the 529 following steps: 531 1. Check for a cached policy whose time-since-fetch has not exceeded 532 its "max_age". If none exists, attempt to fetch a new policy 533 (perhaps asynchronously, so as not to block message delivery). 534 Optionally, sending MTAs may unconditionally check for a new 535 policy at this step. 537 2. For each candidate MX, in order of MX priority, attempt to 538 deliver the message. If a policy is present with an "enforce" 539 mode, when attempting to deliver to each candidate MX, ensure 540 STARTTLS support and host identity validity as described in 541 Section 4, "Policy Validation". If a candidate fails validation, 542 continue to the next candidate (if there is one). 544 3. A message delivery MUST NOT be permanently failed until the 545 sender has first checked for the presence of a new policy (as 546 indicated by the "id" field in the "_mta-sts" TXT record). If a 547 new policy is not found, existing rules for the case of temporary 548 message delivery failures apply (as discussed in [RFC5321] 549 section 4.5.4.1). 551 6. Reporting Failures 553 MTA-STS is intended to be used along with TLSRPT 554 [I-D.ietf-uta-smtp-tlsrpt] in order to ensure implementing domains 555 can detect cases of both benign and malicious failures, and to ensure 556 that failures that indicate an active attack are discoverable. As 557 such, senders who also implement TLSRPT SHOULD treat the following 558 events as reportable failures: 560 o HTTPS policy fetch failures when a valid TXT record is present. 562 o Policy fetch failures of any kind when a valid policy exists in 563 the policy cache, except if that policy's mode is "none". 565 o Delivery attempts in which a contacted MX does not support 566 STARTTLS or does not present a certificate which validates 567 according to the applied policy, except if that policy's mode is 568 "none". 570 7. Interoperability Considerations 572 7.1. SNI Support 574 To ensure that the server sends the right certificate chain, the SMTP 575 client MUST have support for the TLS SNI extension [RFC6066]. When 576 connecting to a HTTP server to retrieve the MTA-STS policy, the SNI 577 extension MUST contain the name of the policy host (e.g., "mta- 578 sts.example.com"). When connecting to an SMTP server, the SNI 579 extension MUST contain the MX hostname. 581 HTTP servers used to deliver MTA-STS policies MAY rely on SNI to 582 determine which certificate chain to present to the client. HTTP 583 servers MUST respond with a certificate chain that matches the policy 584 hostname or abort the TLS handshake if unable to do so. Clients that 585 do not send SNI information may not see the expected certificate 586 chain. 588 SMTP servers MAY rely on SNI to determine which certificate chain to 589 present to the client. However servers that have one identity and a 590 single matching certificate do not require SNI support. Servers MUST 591 NOT enforce the use of SNI by clients, as the client may be using 592 unauthenticated opportunistic TLS and may not expect any particular 593 certificate from the server. If the client sends no SNI extension or 594 sends an SNI extension for an unsupported server name, the server 595 MUST simply send a fallback certificate chain of its choice. The 596 reason for not enforcing strict matching of the requested SNI 597 hostname is that MTA-STS TLS clients may be typically willing to 598 accept multiple server names but can only send one name in the SNI 599 extension. The server's fallback certificate may match a different 600 name that is acceptable to the client, e.g., the original next-hop 601 domain. 603 7.2. Minimum TLS Version Support 605 MTAs supporting MTA-STS MUST have support for TLS version 1.2 606 [RFC5246] or higher. The general TLS usage guidance in [RFC7525] 607 SHOULD be followed. 609 8. Operational Considerations 611 8.1. Policy Updates 613 Updating the policy requires that the owner make changes in two 614 places: the "_mta-sts" TXT record in the Policy Domain's DNS zone and 615 at the corresponding HTTPS endpoint. As a result, recipients should 616 expect a policy will continue to be used by senders until both the 617 HTTPS and TXT endpoints are updated and the TXT record's TTL has 618 passed. 620 In other words, a sender who is unable to successfully deliver a 621 message while applying a cache of the recipient's now-outdated policy 622 may be unable to discover that a new policy exists until the DNS TTL 623 has passed. Recipients SHOULD therefore ensure that old policies 624 continue to work for message delivery during this period of time, or 625 risk message delays. 627 Recipients SHOULD also update the HTTPS policy body before updating 628 the TXT record; this ordering avoids the risk that senders, seeing a 629 new TXT record, mistakenly cache the old policy from HTTPS. 631 8.2. Policy Delegation 633 Domain owners commonly delegate SMTP hosting to a different 634 organization, such as an ISP or a Web host. In such a case, they may 635 wish to also delegate the MTA-STS policy to the same organization 636 which can be accomplished with two changes. 638 First, the Policy Domain must point the "_mta-sts" record, via CNAME, 639 to the "_mta-sts" record maintained by the hosting organization. 640 This allows the hosting organization to control update signaling. 642 Second, the Policy Domain must point the "well-known" policy location 643 to the hosting organization. This can be done either by setting the 644 "mta-sts" record to an IP address or CNAME specified by the hosting 645 organization and by giving the hosting organization a TLS certificate 646 which is valid for that host, or by setting up a "reverse proxy" 647 (also known as a "gateway") server that serves as the Policy Domain's 648 policy the policy currently served by the hosting organization. 650 For example, given a user domain "user.example" hosted by a mail 651 provider "provider.example", the following configuration would allow 652 policy delegation: 654 DNS: 656 _mta-sts.user.example. IN CNAME _mta-sts.provider.example. 658 Policy: 660 > GET /.well-known/mta-sts.txt Host: mta-sts.user.example 661 < HTTP/1.1 200 OK # Response proxies content from 662 # https://mta-sts.provider.example 664 Note that in all such cases, the policy endpoint ("https://mta- 665 sts.user.example/.well-known/mta-sts.txt" in this example) must still 666 present a certificate valid for the Policy Domain ("user.example"), 667 and not for that of the provider ("provider.example"). 669 Note that while sending MTAs MUST NOT use HTTP caching when fetching 670 policies via HTTPS, such caching may nonetheless be useful to a 671 reverse proxy configured as described in this section. An HTTPS 672 policy endpoint expecting to be proxied for multiple hosted domains-- 673 as with a large mail hosting provider or similar--may wish to 674 indicate an HTTP Cache-Control "max-age" response directive (as 675 specified in [RFC7234]) of 60 seconds as a reasonable value to save 676 reverse proxies an unnecessarily high-rate of proxied policy 677 fetching. 679 8.3. Removing MTA-STS 681 In order to facilitate clean opt-out of MTA-STS by implementing 682 policy domains, and to distinguish clearly between failures which 683 indicate attacks and those which indicate such opt-outs, MTA-STS 684 implements the "none" mode, which allows validated policies to 685 indicate authoritatively that the policy domain wishes to no longer 686 implement MTA-STS and may, in the future, remove the MTA-STS TXT and 687 policy endpoints entirely. 689 A suggested workflow to implement such an opt out is as follows: 691 1. Publish a new policy with "mode" equal to "none" and a small 692 "max_age" (e.g., one day). 694 2. Publish a new TXT record to trigger fetching of the new policy. 696 3. When all previously served policies have expired--normally this 697 is the time the previously published policy was last served plus 698 that policy's "max_age", but note that older policies may have 699 been served with a greater "max_age", allowing overlapping policy 700 caches--safely remove the TXT record and HTTPS endpoint. 702 8.4. Preserving MX Candidate Traversal 704 Implementors of send-time MTA-STS validation in mail transfer agents 705 should take note of the risks of modifying the logic of traversing MX 706 candidate lists. Because an MTA-STS policy can be used to prefilter 707 invalid MX candidates from the MX candidate list, it is tempting to 708 implement a "two-pass" model, where MX candidates are first filtered 709 for possible validity according to the MTA-STS policy, and then the 710 remaining candidates attempted in order as without an MTA-STS policy. 711 This may lead to incorrect implementations, such a message loops; 712 implementors are instead recommended to traverse the MX candidate 713 list as usual, and treat invalid candidates as though they were 714 unreachable (i.e., as though there were some transient error when 715 trying to deliver to that candidate). 717 One consequence of validating MX hosts in order of ordinary candidate 718 traversal is that, in the event that a higher-priority MX is MTA-STS 719 valid and a lower-priority MX is not, senders may never encounter the 720 lower-priority MX, leading to a risk that policy misconfigurations 721 that apply only to "backup" MXes may only be discovered in the case 722 of primary MX failure. 724 9. IANA Considerations 726 9.1. Well-Known URIs Registry 728 A new "well-known" URI as described in Section 3 will be registered 729 in the Well-Known URIs registry as described below: 731 URI Suffix: mta-sts.txt Change Controller: IETF 733 9.2. MTA-STS TXT Record Fields 735 IANA is requested to create a new registry titled "MTA-STS TXT Record 736 Fields". The initial entries in the registry are: 738 +------------+--------------------+------------------------+ 739 | Field Name | Description | Reference | 740 +------------+--------------------+------------------------+ 741 | v | Record version | Section 3.1 of RFC XXX | 742 | id | Policy instance ID | Section 3.1 of RFC XXX | 743 +------------+--------------------+------------------------+ 745 New fields are added to this registry using IANA's "Expert Review" 746 policy. 748 9.3. MTA-STS Policy Fields 750 IANA is requested to create a new registry titled "MTA-STS Policy 751 Fields". The initial entries in the registry are: 753 +------------+----------------------+------------------------+ 754 | Field Name | Description | Reference | 755 +------------+----------------------+------------------------+ 756 | version | Policy version | Section 3.2 of RFC XXX | 757 | mode | Enforcement behavior | Section 3.2 of RFC XXX | 758 | max_age | Policy lifetime | Section 3.2 of RFC XXX | 759 | mx | MX identities | Section 3.2 of RFC XXX | 760 +------------+----------------------+------------------------+ 762 New fields are added to this registry using IANA's "Expert Review" 763 policy. 765 10. Security Considerations 767 SMTP MTA Strict Transport Security attempts to protect against an 768 active attacker trying to intercept or tamper with mail between hosts 769 that support STARTTLS. There are two classes of attacks considered: 771 o Foiling TLS negotiation, for example by deleting the "250 772 STARTTLS" response from a server or altering TLS session 773 negotiation. This would result in the SMTP session occurring over 774 plaintext, despite both parties supporting TLS. 776 o Impersonating the destination mail server, whereby the sender 777 might deliver the message to an impostor, who could then monitor 778 and/or modify messages despite opportunistic TLS. This 779 impersonation could be accomplished by spoofing the DNS MX record 780 for the recipient domain, or by redirecting client connections 781 intended for the legitimate recipient server (for example, by 782 altering BGP routing tables). 784 MTA-STS can thwart such attacks only if the sender is able to 785 previously obtain and cache a policy for the recipient domain, and 786 only if the attacker is unable to obtain a valid certificate that 787 complies with that policy. Below, we consider specific attacks on 788 this model. 790 10.1. Obtaining a Signed Certificate 792 SMTP MTA-STS relies on certificate validation via PKIX based TLS 793 identity checking [RFC6125]. Attackers who are able to obtain a 794 valid certificate for the targeted recipient mail service (e.g., by 795 compromising a certificate authority) are thus able to circumvent STS 796 authentication. 798 10.2. Preventing Policy Discovery 800 Since MTA-STS uses DNS TXT records for policy discovery, an attacker 801 who is able to block DNS responses can suppress the discovery of an 802 MTA-STS Policy, making the Policy Domain appear not to have an MTA- 803 STS Policy. The sender policy cache is designed to resist this 804 attack by decreasing the frequency of policy discovery and thus 805 reducing the window of vulnerability; it is nonetheless a risk that 806 attackers who can predict or induce policy discovery--for example, by 807 inducing a sending domain to send mail to a never-before-contacted 808 recipient while carrying out a man-in-the-middle attack--may be able 809 to foil policy discovery and effectively downgrade the security of 810 the message delivery. 812 Since this attack depends upon intercepting initial policy discovery, 813 implementers SHOULD prefer policy "max_age" values to be as long as 814 is practical. 816 Because this attack is also possible upon refresh of a cached policy, 817 implementors SHOULD NOT wait until a cached policy has expired before 818 checking for an update; if senders attempt to refresh the cache 819 regularly (for example, by fetching currently live policy in a 820 background task that runs daily or weekly, regardless of the state of 821 the "_mta_sts" TXT record, and updating their cache's "max age" 822 accordingly), an attacker would have to foil policy discovery 823 consistently over the lifetime of a cached policy to prevent a 824 successful refresh. 826 Additionally, MTAs SHOULD alert administrators to repeated policy 827 refresh failures long before cached policies expire (through warning 828 logs or similar applicable mechanisms), allowing administrators to 829 detect such a persistent attack on policy refresh. (However, they 830 should not implement such alerts if the cached policy has a "none" 831 mode, to allow clean MTA-STS removal, as described in Section 8.3.) 833 Resistance to downgrade attacks of this nature--due to the ability to 834 authoritatively determine "lack of a record" even for non- 835 participating recipients--is a feature of DANE, due to its use of 836 DNSSEC for policy discovery. 838 10.3. Denial of Service 840 We additionally consider the Denial of Service risk posed by an 841 attacker who can modify the DNS records for a recipient domain. 842 Absent MTA-STS, such an attacker can cause a sending MTA to cache 843 invalid MX records, but only for however long the sending resolver 844 caches those records. With MTA-STS, the attacker can additionally 845 advertise a new, long-"max_age" MTA-STS policy with "mx" constraints 846 that validate the malicious MX record, causing senders to cache the 847 policy and refuse to deliver messages once the victim has resecured 848 the MX records. 850 This attack is mitigated in part by the ability of a victim domain to 851 (at any time) publish a new policy updating the cached, malicious 852 policy, though this does require the victim domain to both obtain a 853 valid CA-signed certificate and to understand and properly configure 854 MTA-STS. 856 Similarly, we consider the possibility of domains that deliberately 857 allow untrusted users to serve untrusted content on user-specified 858 subdomains. In some cases (e.g., the service Tumblr.com) this takes 859 the form of providing HTTPS hosting of user-registered subdomains; in 860 other cases (e.g. dynamic DNS providers) this takes the form of 861 allowing untrusted users to register custom DNS records at the 862 provider's domain. 864 In these cases, there is a risk that untrusted users would be able to 865 serve custom content at the "mta-sts" host, including serving an 866 illegitimate MTA-STS policy. We believe this attack is rendered more 867 difficult by the need for the attacker to also serve the "_mta-sts" 868 TXT record on the same domain--something not, to our knowledge, 869 widely provided to untrusted users. This attack is additionally 870 mitigated by the aforementioned ability for a victim domain to update 871 an invalid policy at any future date. 873 10.4. Weak Policy Constraints 875 Even if an attacker cannot modify a served policy, the potential 876 exists for configurations that allow attackers on the same domain to 877 receive mail for that domain. For example, an easy configuration 878 option when authoring an MTA-STS Policy for "example.com" is to set 879 the "mx" equal to "*.example.com"; recipient domains must consider in 880 this case the risk that any user possessing a valid hostname and CA- 881 signed certificate (for example, "dhcp-123.example.com") will, from 882 the perspective of MTA-STS Policy validation, be a valid MX host for 883 that domain. 885 10.5. Compromise of the Web PKI System 887 A host of risks apply to the PKI system used for certificate 888 authentication, both of the "mta-sts" HTTPS host's certificate and 889 the SMTP servers' certificates. These risks are broadly applicable 890 within the Web PKI ecosystem and are not specific to MTA-STS; 891 nonetheless, they deserve some consideration in this context. 893 Broadly speaking, attackers may compromise the system by obtaining 894 certificates under fraudulent circumstances (i.e., by impersonating 895 the legitimate owner of the victim domain), by compromising a 896 Certificate Authority or Delegate Authority's private keys, by 897 obtaining a legitimate certificate issued to the victim domain, and 898 similar. 900 One approach commonly employed by Web browsers to help mitigate 901 against some of these attacks is to allow for revocation of 902 compromised or fraudulent certificates via OCSP [RFC6960] or CRLs 903 [RFC6818]. Such mechanisms themselves represent tradeoffs and are 904 not universally implemented; we nonetheless recommend implementors of 905 MTA-STS to implement revocation mechanisms which are most applicable 906 to their implementations. 908 11. Contributors 910 Wei Chuang Google, Inc weihaw@google.com 912 Viktor Dukhovni ietf-dane@dukhovni.de 914 Markus Laber 1&1 Mail & Media Development & Technology GmbH 915 markus.laber@1und1.de 917 Nicolas Lidzborski Google, Inc nlidz@google.com 919 Brandon Long Google, Inc blong@google.com 921 Franck Martin LinkedIn, Inc fmartin@linkedin.com 923 Klaus Umbach 1&1 Mail & Media Development & Technology GmbH 924 klaus.umbach@1und1.de 926 12. References 928 12.1. Normative References 930 [I-D.ietf-uta-smtp-tlsrpt] 931 Margolis, D., Brotman, A., Ramakrishnan, B., Jones, J., 932 and M. Risher, "SMTP TLS Reporting", draft-ietf-uta-smtp- 933 tlsrpt-20 (work in progress), May 2018. 935 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 936 Requirement Levels", BCP 14, RFC 2119, 937 DOI 10.17487/RFC2119, March 1997, . 940 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, 941 DOI 10.17487/RFC2818, May 2000, . 944 [RFC3207] Hoffman, P., "SMTP Service Extension for Secure SMTP over 945 Transport Layer Security", RFC 3207, DOI 10.17487/RFC3207, 946 February 2002, . 948 [RFC3492] Costello, A., "Punycode: A Bootstring encoding of Unicode 949 for Internationalized Domain Names in Applications 950 (IDNA)", RFC 3492, DOI 10.17487/RFC3492, March 2003, 951 . 953 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 954 (TLS) Protocol Version 1.2", RFC 5246, 955 DOI 10.17487/RFC5246, August 2008, . 958 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 959 Housley, R., and W. Polk, "Internet X.509 Public Key 960 Infrastructure Certificate and Certificate Revocation List 961 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 962 . 964 [RFC5321] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 965 DOI 10.17487/RFC5321, October 2008, . 968 [RFC5785] Nottingham, M. and E. Hammer-Lahav, "Defining Well-Known 969 Uniform Resource Identifiers (URIs)", RFC 5785, 970 DOI 10.17487/RFC5785, April 2010, . 973 [RFC6066] Eastlake 3rd, D., "Transport Layer Security (TLS) 974 Extensions: Extension Definitions", RFC 6066, 975 DOI 10.17487/RFC6066, January 2011, . 978 [RFC6125] Saint-Andre, P. and J. Hodges, "Representation and 979 Verification of Domain-Based Application Service Identity 980 within Internet Public Key Infrastructure Using X.509 981 (PKIX) Certificates in the Context of Transport Layer 982 Security (TLS)", RFC 6125, DOI 10.17487/RFC6125, March 983 2011, . 985 [RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF", 986 RFC 7405, DOI 10.17487/RFC7405, December 2014, 987 . 989 [RFC7525] Sheffer, Y., Holz, R., and P. Saint-Andre, 990 "Recommendations for Secure Use of Transport Layer 991 Security (TLS) and Datagram Transport Layer Security 992 (DTLS)", BCP 195, RFC 7525, DOI 10.17487/RFC7525, May 993 2015, . 995 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 996 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 997 May 2017, . 999 12.2. Informative References 1001 [RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., and S. 1002 Rose, "DNS Security Introduction and Requirements", 1003 RFC 4033, DOI 10.17487/RFC4033, March 2005, 1004 . 1006 [RFC5322] Resnick, P., Ed., "Internet Message Format", RFC 5322, 1007 DOI 10.17487/RFC5322, October 2008, . 1010 [RFC5891] Klensin, J., "Internationalized Domain Names in 1011 Applications (IDNA): Protocol", RFC 5891, 1012 DOI 10.17487/RFC5891, August 2010, . 1015 [RFC6818] Yee, P., "Updates to the Internet X.509 Public Key 1016 Infrastructure Certificate and Certificate Revocation List 1017 (CRL) Profile", RFC 6818, DOI 10.17487/RFC6818, January 1018 2013, . 1020 [RFC6960] Santesson, S., Myers, M., Ankney, R., Malpani, A., 1021 Galperin, S., and C. Adams, "X.509 Internet Public Key 1022 Infrastructure Online Certificate Status Protocol - OCSP", 1023 RFC 6960, DOI 10.17487/RFC6960, June 2013, 1024 . 1026 [RFC7234] Fielding, R., Ed., Nottingham, M., Ed., and J. Reschke, 1027 Ed., "Hypertext Transfer Protocol (HTTP/1.1): Caching", 1028 RFC 7234, DOI 10.17487/RFC7234, June 2014, 1029 . 1031 [RFC7672] Dukhovni, V. and W. Hardaker, "SMTP Security via 1032 Opportunistic DNS-Based Authentication of Named Entities 1033 (DANE) Transport Layer Security (TLS)", RFC 7672, 1034 DOI 10.17487/RFC7672, October 2015, . 1037 Appendix A. MTA-STS example record & policy 1039 The owner of "example.com" wishes to begin using MTA-STS with a 1040 policy that will solicit reports from senders without affecting how 1041 the messages are processed, in order to verify the identity of MXs 1042 that handle mail for "example.com", confirm that TLS is correctly 1043 used, and ensure that certificates presented by the recipient MX 1044 validate. 1046 MTA-STS policy indicator TXT RR: 1048 _mta-sts.example.com. IN TXT "v=STSv1; id=20160831085700Z;" 1050 MTA-STS Policy file served as the response body at "https://mta- 1051 sts.example.com/.well-known/mta-sts.txt": 1053 version: STSv1 1054 mode: testing 1055 mx: mx1.example.com 1056 mx: mx2.example.com 1057 mx: mx.backup-example.com 1058 max_age: 1296000 1060 Appendix B. Message delivery pseudocode 1062 Below is pseudocode demonstrating the logic of a compliant sending 1063 MTA. 1065 While this pseudocode implementation suggests synchronous policy 1066 retrieval in the delivery path, in a working implementation that may 1067 be undesirable, and we expect some implementers to instead prefer a 1068 background fetch that does not block delivery if no cached policy is 1069 present. 1071 func isEnforce(policy) { 1072 // Return true if the policy mode is "enforce". 1073 } 1075 func isNonExpired(policy) { 1076 // Return true if the policy is not expired. 1077 } 1079 func tryStartTls(connection) { 1080 // Attempt to open an SMTP connection with STARTTLS with the MX. 1081 } 1083 func certMatches(connection, host) { 1084 // Assume a handy function to return check if the server certificate presented 1085 // in "connection" is valid for "host". 1086 } 1088 func policyMatches(candidate, policy) { 1089 for mx in policy.mx { 1090 // Literal match. 1091 if mx == candidate { 1092 return true 1093 } 1094 // Wildcard matches only the leftmost label. 1095 // Wildcards must always be followed by a '.'. 1096 if mx[0] == '*' { 1097 parts = SplitN(candidate, '.', 2) // Split on the first '.'. 1098 if len(parts) > 1 && parts[1] == mx[2:] { 1099 return true 1100 } 1101 } 1102 } 1103 return false 1104 } 1106 func tryDeliverMail(connection, message) { 1107 // Attempt to deliver "message" via "connection". 1108 } 1110 func tryGetNewPolicy(domain) { 1111 // Check for an MTA-STS TXT record for "domain" in DNS, and return the 1112 // indicated policy. 1113 } 1115 func cachePolicy(domain, policy) { 1116 // Store "policy" as the cached policy for "domain". 1117 } 1119 func tryGetCachedPolicy(domain) { 1120 // Return a cached policy for "domain". 1121 } 1123 func reportError(error) { 1124 // Report an error via TLSRPT. 1125 } 1127 func tryMxAccordingTo(message, mx, policy) { 1128 connection := connect(mx) 1129 if !connection { 1130 return false // Can't connect to the MX so it's not an MTA-STS 1131 // error. 1133 } 1134 secure := true 1135 if !policyMatches(mx, policy) { 1136 secure = false 1137 reportError(E_HOST_MISMATCH) 1138 } else if !tryStartTls(connection) { 1139 secure = false 1140 reportError(E_NO_VALID_TLS) 1141 } else if !certMatches(connection, policy) { 1142 secure = false 1143 reportError(E_CERT_MISMATCH) 1144 } 1145 if secure || !isEnforce(policy) { 1146 return tryDeliverMail(connection, message) 1147 } 1148 return false 1149 } 1151 func tryWithPolicy(message, domain, policy) { 1152 mxes := getMxForDomain(domain) 1153 for mx in mxes { 1154 if tryMxAccordingTo(message, mx, policy) { 1155 return true 1156 } 1157 } 1158 return false 1159 } 1161 func handleMessage(message) { 1162 domain := ... // domain part after '@' from recipient 1163 policy := tryGetNewPolicy(domain) 1164 if policy { 1165 cachePolicy(domain, policy) 1166 } else { 1167 policy = tryGetCachedPolicy(domain) 1168 } 1169 if policy { 1170 return tryWithPolicy(message, domain, policy) 1171 } 1172 // Try to deliver the message normally (i.e., without MTA-STS). 1173 } 1175 Authors' Addresses 1176 Daniel Margolis 1177 Google, Inc 1179 Email: dmargolis@google.com 1181 Mark Risher 1182 Google, Inc 1184 Email: risher@google.com 1186 Binu Ramakrishnan 1187 Yahoo!, Inc 1189 Email: rbinu@yahoo-inc.com 1191 Alexander Brotman 1192 Comcast, Inc 1194 Email: alex_brotman@comcast.com 1196 Janet Jones 1197 Microsoft, Inc 1199 Email: janet.jones@microsoft.com