idnits 2.17.1 draft-ietf-uta-mta-sts-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 2 instances of too long lines in the document, the longest one being 10 characters in excess of 72. == There are 1 instance of lines with non-RFC2606-compliant FQDNs in the document. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). -- The document date (August 15, 2017) is 2446 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) -- Looks like a reference, but probably isn't: '1' on line 874 -- Looks like a reference, but probably isn't: '0' on line 723 ** Obsolete normative reference: RFC 2560 (Obsoleted by RFC 6960) ** Obsolete normative reference: RFC 2616 (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) ** Obsolete normative reference: RFC 5785 (Obsoleted by RFC 8615) ** Obsolete normative reference: RFC 6125 (Obsoleted by RFC 9525) Summary: 5 errors (**), 0 flaws (~~), 3 warnings (==), 3 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: February 16, 2018 B. Ramakrishnan 6 Yahoo!, Inc 7 A. Brotman 8 Comcast, Inc 9 J. Jones 10 Microsoft, Inc 11 August 15, 2017 13 SMTP MTA Strict Transport Security (MTA-STS) 14 draft-ietf-uta-mta-sts-08 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 February 16, 2018. 41 Copyright Notice 43 Copyright (c) 2017 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 . . . . . . . . . . . . . . . . . . . . . . . . 2 59 1.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 3 60 2. Related Technologies . . . . . . . . . . . . . . . . . . . . 3 61 3. Policy Discovery . . . . . . . . . . . . . . . . . . . . . . 4 62 3.1. MTA-STS TXT Records . . . . . . . . . . . . . . . . . . . 4 63 3.2. MTA-STS Policies . . . . . . . . . . . . . . . . . . . . 5 64 3.3. HTTPS Policy Fetching . . . . . . . . . . . . . . . . . . 7 65 3.4. Policy Selection for Smart Hosts and Subdomains . . . . . 9 66 4. Policy Validation . . . . . . . . . . . . . . . . . . . . . . 9 67 4.1. MX Certificate Validation . . . . . . . . . . . . . . . . 9 68 5. Policy Application . . . . . . . . . . . . . . . . . . . . . 10 69 5.1. Policy Application Control Flow . . . . . . . . . . . . . 10 70 6. Operational Considerations . . . . . . . . . . . . . . . . . 11 71 6.1. Policy Updates . . . . . . . . . . . . . . . . . . . . . 11 72 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11 73 7.1. Well-Known URIs Registry . . . . . . . . . . . . . . . . 11 74 7.2. MTA-STS TXT Record Fields . . . . . . . . . . . . . . . . 12 75 7.3. MTA-STS Policy Fields . . . . . . . . . . . . . . . . . . 12 76 8. Security Considerations . . . . . . . . . . . . . . . . . . . 12 77 8.1. Obtaining a Signed Certificate . . . . . . . . . . . . . 13 78 8.2. Preventing Policy Discovery . . . . . . . . . . . . . . . 13 79 8.3. Denial of Service . . . . . . . . . . . . . . . . . . . . 14 80 8.4. Weak Policy Constraints . . . . . . . . . . . . . . . . . 14 81 9. Contributors . . . . . . . . . . . . . . . . . . . . . . . . 15 82 10. Appendix 1: MTA-STS example record & policy . . . . . . . . . 15 83 11. Appendix 2: Message delivery pseudocode . . . . . . . . . . . 15 84 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 18 85 12.1. Normative References . . . . . . . . . . . . . . . . . . 18 86 12.2. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 19 87 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 19 89 1. Introduction 91 The STARTTLS extension to SMTP [RFC3207] allows SMTP clients and 92 hosts to negotiate the use of a TLS channel for encrypted mail 93 transmission. 95 While this opportunistic encryption protocol by itself provides a 96 high barrier against passive man-in-the-middle traffic interception, 97 any attacker who can delete parts of the SMTP session (such as the 98 "250 STARTTLS" response) or who can redirect the entire SMTP session 99 (perhaps by overwriting the resolved MX record of the delivery 100 domain) can perform downgrade or interception attacks. 102 This document defines a mechanism for recipient domains to publish 103 policies specifying: 105 o whether MTAs sending mail to this domain can expect PKIX- 106 authenticated TLS support 108 o what a conforming client should do with messages when TLS cannot 109 be successfully negotiated 111 1.1. Terminology 113 The keywords MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, 114 SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL, when they appear in this 115 document, are to be interpreted as described in [RFC2119]. 117 We also define the following terms for further use in this document: 119 o MTA-STS Policy: A commitment by the Policy Domain to support PKIX 120 authenticated TLS for the specified MX hosts. 122 o Policy Domain: The domain for which an MTA-STS Policy is defined. 123 This is the next-hop domain; when sending mail to 124 "alice@example.com" this would ordinarly be "example.com", but 125 this may be overriden by explicit routing rules (as described in 126 Section 3.4, "Policy Selection for Smart Hosts and Subdomains"). 128 2. Related Technologies 130 The DANE TLSA record [RFC7672] is similar, in that DANE is also 131 designed to upgrade unauthenticated encryption or plaintext 132 transmission into authenticated, downgrade-resistent encrypted 133 tarnsmission. DANE requires DNSSEC [RFC4033] for authentication; the 134 mechanism described here instead relies on certificate authorities 135 (CAs) and does not require DNSSEC, at a cost of risking malicious 136 downgrades. For a thorough discussion of this trade-off, see 137 Section 8, "Security Considerations". 139 In addition, MTA-STS provides an optional report-only mode, enabling 140 soft deployments to detect policy failures; partial deployments can 141 be achieved in DANE by deploying TLSA records only for some of a 142 domain's MXs, but such a mechanism is not possible for the per-domain 143 policies used by MTA-STS. 145 The primary motivation of MTA-STS is to provide a mechanism for 146 domains to upgrade their transport security even when deploying 147 DNSSEC is undesirable or impractical. However, MTA-STS is designed 148 not to interfere with DANE deployments when the two overlap; in 149 particular, senders who implement MTA-STS validation MUST NOT allow a 150 "valid" or "report-only" MTA-STS validation to override a failing 151 DANE validation. 153 3. Policy Discovery 155 MTA-STS policies are distributed via HTTPS from a "well-known" 156 [RFC5785] path served within the Policy Domain, and their presence 157 and current version are indicated by a TXT record at the Policy 158 Domain. These TXT records additionally contain a policy "id" field, 159 allowing sending MTAs to check the currency of a cached policy 160 without performing an HTTPS request. 162 To discover if a recipient domain implements MTA-STS, a sender need 163 only resolve a single TXT record. To see if an updated policy is 164 available for a domain for which the sender has a previously cached 165 policy, the sender need only check the TXT record's version "id" 166 against the cached value. 168 3.1. MTA-STS TXT Records 170 The MTA-STS TXT record is a TXT record with the name "_mta-sts" at 171 the Policy Domain. For the domain "example.com", this record would 172 be "_mta-sts.example.com". MTA-STS TXT records MUST be US-ASCII, 173 semicolon-separated key/value pairs containing the following fields: 175 o "v": (plain-text, required). Currently only "STSv1" is supported. 177 o "id": (plain-text, required). A short string used to track policy 178 updates. This string MUST uniquely identify a given instance of a 179 policy, such that senders can determine when the policy has been 180 updated by comparing to the "id" of a previously seen policy. 181 There is no implied ordering of "id" fields between revisions. 183 An example TXT record is as below: 185 "_mta-sts.example.com. IN TXT "v=STSv1; id=20160831085700Z;"" 187 The formal definition of the "_mta-sts" TXT record, defined using 188 [RFC7405], is as follows: 190 sts-text-record = sts-version field-delim sts-id 191 *(field-delim sts-extension) [field-delim] 193 field-delim = *WSP ";" *WSP 195 sts-version = %s"v=STSv1" 197 sts-id = %s"id=" 1*32(ALPHA / DIGIT) ; id=... 199 sts-extension = sts-ext-name "=" sts-ext-value ; name=value 201 sts-ext-name = (ALPHA / DIGIT) *31(ALPHA / DIGIT / "_" / "-" / ".") 203 sts-ext-value = 1*(%x21-3A / %x3C / %x3E-7E) ; chars excluding 204 ; "=", ";", SP, and 205 ; control chars 207 If multiple TXT records for "_mta-sts" are returned by the resolver, 208 records which do not begin with "v=STSv1;" are discarded. If the 209 number of resulting records is not one, senders MUST assume the 210 recipient domain does not implement MTA-STS and skip the remaining 211 steps of policy discovery. 213 3.2. MTA-STS Policies 215 The policy itself is a set of key/value pairs served via the HTTPS 216 GET method from the fixed [RFC5785] "well-known" path of ".well- 217 known/mta-sts.txt" served by the "mta-sts" host at the Policy Domain; 218 the [RFC2616] "Content-Type" header MUST be "text/plain". Thus for 219 "example.com" the path is "https://mta-sts.example.com/.well-known/ 220 mta-sts.txt". 222 This resource contains the following line-separated key/value pairs: 224 o "version": (plain-text, required). Currently only "STSv1" is 225 supported. 227 o "mode": (plain-text, required). Either "enforce" or "report", 228 indicating the expected behavior of a sending MTA in the case of a 229 policy validation failure. 231 o "max_age": Max lifetime of the policy (plain-text non-negative 232 integer seconds, required). Well-behaved clients SHOULD cache a 233 policy for up to this value from last policy fetch time. To 234 mitigate the risks of attacks at policy refresh time, it is 235 expected that this value typically be in the range of weeks or 236 greater. 238 o "mx": MX identity patterns (list of plain-text strings, required). 239 One or more patterns matching a Common Name ([RFC6125]) or Subject 240 Alternative Name ([RFC5280]) DNS-ID present in the X.509 241 certificate presented by any MX receiving mail for this domain. 242 For example: "mx: mail.example.com mx: .example.net" indicates 243 that mail for this domain might be handled by any MX with a 244 certificate valid for a host at "mail.example.com" or 245 "example.net". Valid patterns can be either fully specified names 246 ("example.com") or suffixes (".example.net") matching the right- 247 hand parts of a server's identity; the latter case are 248 distinguished by a leading period. If there are more than one MX 249 specified by the policy, they MUST be on separate lines within the 250 policy file. In the case of Internationalized Domain Names 251 ([RFC5891]), the MX MUST specify the Punycode-encoded A-label 252 [RFC3492] and not the Unicode-encoded U-label. The full semantics 253 of certificate validation are described in Section 4.1, "MX 254 Certificate Validation." 256 An example policy is as below: 258 version: STSv1 259 mode: enforce 260 mx: mail.example.com 261 mx: .example.net 262 mx: backupmx.example.com 263 max_age: 123456 265 The formal definition of the policy resource, defined using 266 [RFC7405], is as follows: 268 sts-policy-record = sts-policy-version CRLF 269 sts-policy-mode CRLF 270 1*(sts-policy-mx CRLF) 271 sts-policy-max-age 273 field-delim = ":" *WSP 275 sts-policy-version = sts-policy-version-field field-delim 276 sts-policy-version-value 278 sts-policy-version-field = %s"version" 280 sts-policy-version-value = %s"STSv1" 282 sts-policy-mode = sts-policy-mode-field field-delim 283 sts-policy-mode-value 285 sts-policy-mode-field = %s"mode" 287 sts-policy-model-value = %s"report" / %s"enforce" 289 sts-policy-mx = sts-policy-mx-field field-delim 290 sts-policy-mx-value 292 sts-policy-mx-field = %s"mx" 294 sts-policy-mx-value = 1*(ALPHA / DIGIT / "_" / "-" / ".") 296 sts-policy-max-age = sts-policy-max-age-field field-delim 297 sts-policy-max-age-value 299 sts-policy-max-age-field = %s"max_age" 301 sts-policy-max-age-value = 1*10(DIGIT) 303 Parsers MUST accept TXT records and policy files which are 304 syntactically valid (i.e. valid key/value pairs separated by semi- 305 colons for TXT records) and implementing a superset of this 306 specification, in which case unknown fields SHALL be ignored. If any 307 field other than "mx" is duplicated, the first entry will be honored, 308 the rest should be ignored. For the "mx" field, all valid entries 309 will be utilized when enforcing the stated policy. 311 3.3. HTTPS Policy Fetching 313 When fetching a new policy or updating a policy, the HTTPS endpoint 314 MUST present a X.509 certificate which is valid for the "mta-sts" 315 host (as described below), chain to a root CA that is trusted by the 316 sending MTA, and be non-expired. It is expected that sending MTAs 317 use a set of trusted CAs similar to those in widely deployed Web 318 browsers and operating systems. 320 The certificate is valid for the "mta-sts" host with respect to the 321 rules described in [RFC6125], with the following application-specific 322 considerations: 324 o Matching is performed only against the DNS-ID and CN-ID 325 identifiers. 327 o DNS domain names in server certificates MAY contain the wildcard 328 character '*' as the complete left-most label within the 329 identifier. 331 The certificate MAY be checked for revocation via the Online 332 Certificate Status Protocol (OCSP) [RFC2560], certificate revocation 333 lists (CRLs), or some other mechanism. 335 HTTP 3xx redirects MUST NOT be followed. 337 Senders may wish to rate-limit the frequency of attempts to fetch the 338 HTTPS endpoint even if a valid TXT record for the recipient domain 339 exists. In the case that the HTTPS GET fails, we suggest 340 implementions may limit further attempts to a period of five minutes 341 or longer per version ID, to avoid overwhelming resource-constrained 342 recipients with cascading failures. 344 Senders MAY impose a timeout on the HTTPS GET and/or a limit on the 345 maximum size of the response body to avoid long delays or resource 346 exhaustion during attempted policy updates. A suggested timeout is 347 one minute, and a suggested maximum policy size 64 kilobytes; policy 348 hosts SHOULD respond to requests with a complete policy body within 349 that timeout and size limit. 351 If a valid TXT record is found but no policy can be fetched via HTTPS 352 (for any reason), and there is no valid (non-expired) previously- 353 cached policy, senders MUST continue with delivery as though the 354 domain has not implemented MTA-STS. Senders who implement TLSRPT 355 (TODO: add ref) should, however, report this failure to the recipient 356 domain if the domain implements TLSRPT as well. 358 Conversely, if no "live" policy can be discovered via DNS or fetched 359 via HTTPS, but a valid (non-expired) policy exists in the sender's 360 cache, the sender MUST apply that cached policy. 362 3.4. Policy Selection for Smart Hosts and Subdomains 364 When sending mail via a "smart host"--an intermediate SMTP relay 365 rather than the message recipient's server--compliant senders MUST 366 treat the smart host domain as the policy domain for the purposes of 367 policy discovery and application. 369 When sending mail to a mailbox at a subdomain, compliant senders MUST 370 NOT attempt to fetch a policy from the parent zone. Thus for mail 371 sent to "user@mail.example.com", the policy can be fetched only from 372 "mail.example.com", not "example.com". 374 4. Policy Validation 376 When sending to an MX at a domain for which the sender has a valid 377 and non-expired MTA-STS policy, a sending MTA honoring MTA-STS MUST 378 validate: 380 1. That the recipient MX supports STARTTLS and offers a valid PKIX- 381 based TLS certificate. 383 2. That at least one of the policy's "mx" patterns matches at least 384 one of the identities presented in the MX's X.509 certificate, as 385 described in "MX Certificate Validation". 387 This section does not dictate the behavior of sending MTAs when 388 policies fail to validate; in particular, validation failures of 389 policies which specify "report" mode MUST NOT be interpreted as 390 delivery failures, as described in Section 5, "Policy Application". 392 4.1. MX Certificate Validation 394 The certificate presented by the receiving MX MUST chain to a root CA 395 that is trusted by the sending MTA and be non-expired. The 396 certificate MUST have a CN-ID ([RFC6125]) or SAN ([RFC5280]) with a 397 DNS-ID matching the "mx" pattern. The MX's certificate MAY also be 398 checked for revocation via OCSP [RFC2560], certificate revocation 399 lists (CRLs), or some other mechanism. 401 Because the "mx" patterns are not hostnames, however, matching is not 402 identical to other common cases of X.509 certificate authentication 403 (as described, for example, in [RFC6125]). Consider the example 404 policy given above, with an "mx" pattern containing ".example.net". 405 In this case, if the MX server's X.509 certificate contains a SAN 406 matching "*.example.net", we are required to implement "wildcard-to- 407 wildcard" matching. 409 To simplify this case, we impose the following constraints on 410 wildcard certificates, identical to those in [RFC7672] section 3.2.3 411 and [@!RFC6125 section 6.4.3: wildcards are valid in DNS-IDs or CN- 412 IDs, but must be the entire first label of the identifier (that is, 413 "*.example.com", not "mail*.example.com"). Senders who are comparing 414 a "suffix" MX pattern with a wildcard identifier should thus strip 415 the wildcard and ensure that the two sides match label-by-label, 416 until all labels of the shorter side (if unequal length) are 417 consumed. 419 A simple pseudocode implementation of this algorithm is presented in 420 the Appendix. 422 5. Policy Application 424 When sending to an MX at a domain for which the sender has a valid, 425 non-expired MTA-STS policy, a sending MTA honoring MTA-STS applies 426 the result of a policy validation failure one of two ways, depending 427 on the value of the policy "mode" field: 429 1. "report": In this mode, sending MTAs which also implement the 430 TLSRPT specification (TODO: add ref) merely send a report 431 indicating policy application failures (so long as TLSRPT is also 432 implemented by the recipient domain). 434 2. "enforce": In this mode, sending MTAs MUST NOT deliver the 435 message to hosts which fail MX matching or certificate 436 validation. 438 When a message fails to deliver due to an "enforce" policy, a 439 compliant MTA MUST NOT permanently fail to deliver messages before 440 checking for the presence of an updated policy at the Policy Domain. 441 (In all cases, MTAs SHOULD treat such failures as transient errors 442 and retry delivery later.) This allows implementing domains to 443 update long-lived policies on the fly. 445 Finally, in both "enforce" and "report" modes, failures to deliver in 446 compliance with the applied policy result in failure reports to the 447 policy domain, as described in the TLSRPT specification (TODO: add 448 ref). 450 5.1. Policy Application Control Flow 452 An example control flow for a compliant sender consists of the 453 following steps: 455 1. Check for a cached policy whose time-since-fetch has not exceeded 456 its "max_age". If none exists, attempt to fetch a new policy 457 (perhaps asynchronously, so as not to block message delivery). 458 Optionally, sending MTAs may unconditionally check for a new 459 policy at this step. 461 2. For each candidate MX, in order of MX priority, attempt to 462 deliver the message, enforcing STARTTLS and, assuming a policy is 463 present, PKIX certificate validation as described in Section 4.1, 464 "MX Certificate Validation." 466 3. A message delivery MUST NOT be permanently failed until the 467 sender has first checked for the presence of a new policy (as 468 indicated by the "id" field in the "_mta-sts" TXT record). If a 469 new policy is not found, existing rules for the case of temporary 470 message delivery failures apply (as discussed in [RFC5321] 471 section 4.5.4.1). 473 6. Operational Considerations 475 6.1. Policy Updates 477 Updating the policy requires that the owner make changes in two 478 places: the "_mta-sts" TXT record in the Policy Domain's DNS zone and 479 at the corresponding HTTPS endpoint. As a result, recipients should 480 expect a policy will continue to be used by senders until both the 481 HTTPS and TXT endpoints are updated and the TXT record's TTL has 482 passed. 484 In other words, a sender who is unable to successfully deliver a 485 message while applying a cache of the recipient's now-outdated policy 486 may be unable to discover that a new policy exists until the DNS TTL 487 has passed. Recipients should therefore ensure that old policies 488 continue to work for message delivery during this period of time, or 489 risk message delays. 491 Recipients should also prefer to update the HTTPS policy body before 492 updating the TXT record; this ordering avoids the risk that senders, 493 seeing a new TXT record, mistakenly cache the old policy from HTTPS. 495 7. IANA Considerations 497 7.1. Well-Known URIs Registry 499 A new .well-known URI will be registered in the Well-Known URIs 500 registry as described below: 502 URI Suffix: mta-sts.txt Change Controller: IETF 504 7.2. MTA-STS TXT Record Fields 506 IANA is requested to create a new registry titled "MTA-STS TXT Record 507 Fields". The initial entries in the registry are: 509 +------------+--------------------+------------------------+ 510 | Field Name | Description | Reference | 511 +------------+--------------------+------------------------+ 512 | v | Record version | Section 3.1 of RFC XXX | 513 | id | Policy instance ID | Section 3.1 of RFC XXX | 514 +------------+--------------------+------------------------+ 516 New fields are added to this registry using IANA's "Expert Review" 517 policy. 519 7.3. MTA-STS Policy Fields 521 IANA is requested to create a new registry titled "MTA-STS Policy 522 Fields". The initial entries in the registry are: 524 +------------+----------------------+------------------------+ 525 | Field Name | Description | Reference | 526 +------------+----------------------+------------------------+ 527 | version | Policy version | Section 3.2 of RFC XXX | 528 | mode | Enforcement behavior | Section 3.2 of RFC XXX | 529 | max_age | Policy lifetime | Section 3.2 of RFC XXX | 530 | mx | MX identities | Section 3.2 of RFC XXX | 531 +------------+----------------------+------------------------+ 533 New fields are added to this registry using IANA's "Expert Review" 534 policy. 536 8. Security Considerations 538 SMTP MTA Strict Transport Security attempts to protect against an 539 active attacker who wishes to intercept or tamper with mail between 540 hosts who support STARTTLS. There are two classes of attacks 541 considered: 543 o Foiling TLS negotiation, for example by deleting the "250 544 STARTTLS" response from a server or altering TLS session 545 negotiation. This would result in the SMTP session occurring over 546 plaintext, despite both parties supporting TLS. 548 o Impersonating the destination mail server, whereby the sender 549 might deliver the message to an impostor, who could then monitor 550 and/or modify messages despite opportunistic TLS. This 551 impersonation could be accomplished by spoofing the DNS MX record 552 for the recipient domain, or by redirecting client connections 553 intended for the legitimate recipient server (for example, by 554 altering BGP routing tables). 556 MTA-STS can thwart such attacks only if the sender is able to 557 previously obtain and cache a policy for the recipient domain, and 558 only if the attacker is unable to obtain a valid certificate that 559 complies with that policy. Below, we consider specific attacks on 560 this model. 562 8.1. Obtaining a Signed Certificate 564 SMTP MTA-STS relies on certificate validation via PKIX based TLS 565 identity checking [RFC6125]. Attackers who are able to obtain a 566 valid certificate for the targeted recipient mail service (e.g. by 567 compromising a certificate authority) are thus able to circumvent STS 568 authentication. 570 8.2. Preventing Policy Discovery 572 Since MTA-STS uses DNS TXT records for policy discovery, an attacker 573 who is able to block DNS responses can suppress the discovery of an 574 MTA-STS Policy, making the Policy Domain appear not to have an MTA- 575 STS Policy. The sender policy cache is designed to resist this 576 attack by decreasing the frequency of policy discovery and thus 577 reducing the window of vulnerability; it is nonetheless a risk that 578 attackers who can predict or induce policy discovery--for example, by 579 inducing a victim sending domain to send mail to a never-before- 580 contacted recipient while carrying out a man-in-the-middle attack-- 581 may be able to foil policy discovery and effectively downgrade the 582 security of the message delivery. 584 Since this attack depends upon intercepting initial policy discovery, 585 we strongly recommend implementors to prefer policy "max_age" values 586 to be as long as is practical. 588 Because this attack is also possible upon refresh of a cached policy, 589 we suggest implementors do not wait until a cached policy has expired 590 before checking for an update; if senders attempt to refresh the 591 cache regularly (for instance, by checking their cached version 592 string against the TXT record on each successful send, or in a 593 background task that runs daily or weekly), an attacker would have to 594 foil policy discovery consistently over the lifetime of a cached 595 policy to prevent a successful refresh. 597 Resistence to downgrade attacks of this nature--due to the ability to 598 authoritatively determine "lack of a record" even for non- 599 participating recipients--is a feature of DANE, due to its use of 600 DNSSEC for policy discovery. 602 8.3. Denial of Service 604 We additionally consider the Denial of Service risk posed by an 605 attacker who can modify the DNS records for a victim domain. Absent 606 MTA-STS, such an attacker can cause a sending MTA to cache invalid MX 607 records, but only for however long the sending resolver caches those 608 records. With MTA-STS, the attacker can additionally advertise a 609 new, long-"max_age" MTA-STS policy with "mx" constraints that 610 validate the malicious MX record, causing senders to cache the policy 611 and refuse to deliver messages once the victim has resecured the MX 612 records. 614 This attack is mitigated in part by the ability of a victim domain to 615 (at any time) publish a new policy updating the cached, malicious 616 policy, though this does require the victim domain to both obtain a 617 valid CA-signed certificate and to understand and properly configure 618 MTA-STS. 620 Similarly, we consider the possibility of domains that deliberately 621 allow untrusted users to serve untrusted content on user-specified 622 subdomains. In some cases (e.g. the service Tumblr.com) this takes 623 the form of providing HTTPS hosting of user-registered subdomains; in 624 other cases (e.g. dynamic DNS providers) this takes the form of 625 allowing untrusted users to register custom DNS records at the 626 provider's domain. 628 In these cases, there is a risk that untrusted users would be able to 629 serve custom content at the "mta-sts" host, including serving an 630 illegitimate MTA-STS policy. We believe this attack is rendered more 631 difficult by the need for the attacker to also serve the "_mta-sts" 632 TXT record on the same domain--something not, to our knowledge, 633 widely provided to untrusted users. This attack is additionally 634 mitigated by the aforementioned ability for a victim domain to update 635 an invalid policy at any future date. 637 8.4. Weak Policy Constraints 639 Even if an attacker cannot modify a served policy, the potential 640 exists for configurations that allow attackers on the same domain to 641 receive mail for that domain. For example, an easy configuration 642 option when authoring an MTA-STS Policy for "example.com" is to set 643 the "mx" equal to ".example.com"; recipient domains must consider in 644 this case the risk that any user possessing a valid hostname and CA- 645 signed certificate (for example, "dhcp-123.example.com") will, from 646 the perspective of MTA-STS Policy validation, be a valid MX host for 647 that domain. 649 9. Contributors 651 Nicolas Lidzborski Google, Inc nlidz (at) google (dot com) 653 Wei Chuang Google, Inc weihaw (at) google (dot com) 655 Brandon Long Google, Inc blong (at) google (dot com) 657 Franck Martin LinkedIn, Inc fmartin (at) linkedin (dot com) 659 Klaus Umbach 1&1 Mail & Media Development & Technology GmbH 660 klaus.umbach (at) 1und1 (dot de) 662 Markus Laber 1&1 Mail & Media Development & Technology GmbH 663 markus.laber (at) 1und1 (dot de) 665 10. Appendix 1: MTA-STS example record & policy 667 The owner of "example.com" wishes to begin using MTA-STS with a 668 policy that will solicit reports from senders without affecting how 669 the messages are processed, in order to verify the identity of MXs 670 that handle mail for "example.com", confirm that TLS is correctly 671 used, and ensure that certificates presented by the recipient MX 672 validate. 674 MTA-STS policy indicator TXT RR: 676 _mta-sts.example.com. IN TXT "v=STSv1; id=20160831085700Z;" 678 MTA-STS Policy file served as the response body at [1] 680 version: STSv1 681 mode: report 682 mx: mx1.example.com 683 mx: mx2.example.com 684 mx: mx.backup-example.com 685 max_age: 12345678 687 11. Appendix 2: Message delivery pseudocode 689 Below is pseudocode demonstrating the logic of a compliant sending 690 MTA. 692 While this pseudocode implementation suggests synchronous policy 693 retrieval in the delivery path, in a working implementation that may 694 be undesirable, and we expect some implementors to instead prefer a 695 background fetch that does not block delivery if no cached policy is 696 present. 698 func isEnforce(policy) { 699 // Return true if the policy mode is "enforce". 700 } 702 func isNonExpired(policy) { 703 // Return true if the policy is not expired. 704 } 706 func tryStartTls(connection) { 707 // Attempt to open an SMTP connection with STARTTLS with the MX. 708 } 710 func certMatches(connection, policy) { 711 // Assume a handy function to return CN and DNS-ID SANs. 712 for san in getDnsIdSansAndCnFromCert(connection) { 713 for mx in policy.mx { 714 // Return if the server certificate from "connection" matches the "mx" host. 715 if san[0] == '*' { 716 // Invalid wildcard! 717 if san[1] != '.' continue 718 san = san[1:] 719 } 720 if san[0] == '.' && HasSuffix(mx, san) { 721 return true 722 } 723 if mx[0] == '.' && HasSuffix(san, mx) { 724 return true 725 } 726 if mx == san { 727 return true 728 } 729 } 730 } 731 return false 732 } 734 func tryDeliverMail(connection, message) { 735 // Attempt to deliver "message" via "connection". 736 } 738 func tryGetNewPolicy(domain) { 739 // Check for an MTA-STS TXT record for "domain" in DNS, and return the 740 // indicated policy. 742 } 744 func cachePolicy(domain, policy) { 745 // Store "policy" as the cached policy for "domain". 746 } 748 func tryGetCachedPolicy(domain) { 749 // Return a cached policy for "domain". 750 } 752 func reportError(error) { 753 // Report an error via TLSRPT. 754 } 756 func tryMxAccordingTo(message, mx, policy) { 757 connection := connect(mx) 758 if !connection { 759 return false // Can't connect to the MX so it's not an MTA-STS error. 760 } 761 secure := true 762 if !tryStartTls(connection) { 763 secure = false 764 reportError(E_NO_VALID_TLS) 765 } else if !certMatches(connection, policy) { 766 secure = false 767 reportError(E_CERT_MISMATCH) 768 } 769 if secure || !isEnforce(policy) { 770 return tryDeliverMail(connection, message) 771 } 772 return false 773 } 775 func tryWithPolicy(message, domain, policy) { 776 mxes := getMxForDomain(domain) 777 for mx in mxes { 778 if tryMxAccordingTo(message, mx, policy) { 779 return true 780 } 781 } 782 return false 783 } 785 func handleMessage(message) { 786 domain := ... // domain part after '@' from recipient 787 policy := tryGetNewPolicy(domain) 788 if policy { 789 cachePolicy(domain, policy) 791 } else { 792 policy = tryGetCachedPolicy(domain) 793 } 794 if policy { 795 return tryWithPolicy(message, domain, policy) 796 } 797 // Try to deliver the message normally (i.e. without MTA-STS). 798 } 800 12. References 802 12.1. Normative References 804 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 805 Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/ 806 RFC2119, March 1997, 807 . 809 [RFC2560] Myers, M., Ankney, R., Malpani, A., Galperin, S., and C. 810 Adams, "X.509 Internet Public Key Infrastructure Online 811 Certificate Status Protocol - OCSP", RFC 2560, DOI 10 812 .17487/RFC2560, June 1999, 813 . 815 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 816 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 817 Transfer Protocol -- HTTP/1.1", RFC 2616, DOI 10.17487/ 818 RFC2616, June 1999, 819 . 821 [RFC3207] Hoffman, P., "SMTP Service Extension for Secure SMTP over 822 Transport Layer Security", RFC 3207, DOI 10.17487/RFC3207, 823 February 2002, . 825 [RFC3492] Costello, A., "Punycode: A Bootstring encoding of Unicode 826 for Internationalized Domain Names in Applications 827 (IDNA)", RFC 3492, DOI 10.17487/RFC3492, March 2003, 828 . 830 [RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., and S. 831 Rose, "DNS Security Introduction and Requirements", RFC 832 4033, DOI 10.17487/RFC4033, March 2005, 833 . 835 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 836 Housley, R., and W. Polk, "Internet X.509 Public Key 837 Infrastructure Certificate and Certificate Revocation List 838 (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008, 839 . 841 [RFC5321] Klensin, J., "Simple Mail Transfer Protocol", RFC 5321, 842 DOI 10.17487/RFC5321, October 2008, 843 . 845 [RFC5785] Nottingham, M. and E. Hammer-Lahav, "Defining Well-Known 846 Uniform Resource Identifiers (URIs)", RFC 5785, DOI 10 847 .17487/RFC5785, April 2010, 848 . 850 [RFC5891] Klensin, J., "Internationalized Domain Names in 851 Applications (IDNA): Protocol", RFC 5891, DOI 10.17487/ 852 RFC5891, August 2010, 853 . 855 [RFC6125] Saint-Andre, P. and J. Hodges, "Representation and 856 Verification of Domain-Based Application Service Identity 857 within Internet Public Key Infrastructure Using X.509 858 (PKIX) Certificates in the Context of Transport Layer 859 Security (TLS)", RFC 6125, DOI 10.17487/RFC6125, March 860 2011, . 862 [RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF", RFC 863 7405, DOI 10.17487/RFC7405, December 2014, 864 . 866 [RFC7672] Dukhovni, V. and W. Hardaker, "SMTP Security via 867 Opportunistic DNS-Based Authentication of Named Entities 868 (DANE) Transport Layer Security (TLS)", RFC 7672, DOI 10 869 .17487/RFC7672, October 2015, 870 . 872 12.2. URIs 874 [1] https://mta-sts.example.com/.well-known/mta-sts.txt: 876 Authors' Addresses 878 Daniel Margolis 879 Google, Inc 881 Email: dmargolis (at) google.com 882 Mark Risher 883 Google, Inc 885 Email: risher (at) google (dot com) 887 Binu Ramakrishnan 888 Yahoo!, Inc 890 Email: rbinu (at) yahoo-inc (dot com) 892 Alexander Brotman 893 Comcast, Inc 895 Email: alex_brotman (at) comcast.com 897 Janet Jones 898 Microsoft, Inc 900 Email: janet.jones (at) microsoft (dot com)