PROPOSED STANDARD

Errata Exist

Internet Engineering Task Force (IETF) D. Margolis Request for Comments: 8461 M. Risher Category: Standards Track Google, Inc. ISSN: 2070-1721 B. Ramakrishnan Oath, Inc. A. Brotman Comcast, Inc. J. Jones Microsoft, Inc. September 2018 SMTP MTA Strict Transport Security (MTA-STS) Abstract SMTP MTA Strict Transport Security (MTA-STS) is a mechanism enabling mail service providers (SPs) to declare their ability to receive Transport Layer Security (TLS) secure SMTP connections and to specify whether sending SMTP servers should refuse to deliver to MX hosts that do not offer TLS with a trusted server certificate. Status of This Memo This is an Internet Standards Track document. This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841. Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at https://www.rfc-editor.org/info/rfc8461. Margolis, et al. Standards Track [Page 1]

RFC 8461 MTA-STS September 2018 BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. Margolis, et al. Standards Track [Page 2]

RFC 8461 MTA-STS September 2018 1 . Introduction RFC3207] allows SMTP clients and hosts to negotiate the use of a TLS channel for encrypted mail transmission. While this opportunistic encryption protocol by itself provides a high barrier against passive man-in-the-middle traffic interception, any attacker who can delete parts of the SMTP session (such as the "250 STARTTLS" response) or who can redirect the entire SMTP session (perhaps by overwriting the resolved MX record of the delivery domain) can perform downgrade or interception attacks. This document defines a mechanism for recipient domains to publish policies, via a combination of DNS and HTTPS, specifying: o whether MTAs sending mail to this domain can expect PKIX- authenticated TLS support o what a conforming client should do with messages when TLS cannot be successfully negotiated 1.1 . Terminology BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here. We also define the following terms for further use in this document: o MTA-STS Policy: A commitment by the Policy Domain to support TLS authenticated with PKIX [RFC5280] for the specified MX hosts. o Policy Domain: The domain for which an MTA-STS Policy is defined. This is the next-hop domain; when sending mail to "alice@example.com", this would ordinarily be "example.com", but this may be overridden by explicit routing rules (as described in Section 3.4, "Policy Selection for Smart Hosts and Subdomains"). o Policy Host: The HTTPS host that serves the MTA-STS Policy for a Policy Domain. Rules for constructing the hostname are described in Section 3.2, "MTA-STS Policies". o Sender or Sending MTA: The SMTP MTA sending an email message. Margolis, et al. Standards Track [Page 4]

RFC 8461 MTA-STS September 2018 RFC5234] and [RFC7405]. 2 . Related Technologies RFC7672] is similar, in that DANE is also designed to upgrade unauthenticated encryption or plaintext transmission into authenticated, downgrade-resistant encrypted transmission. DANE requires DNSSEC [RFC4033] for authentication; the mechanism described here instead relies on certification authorities (CAs) and does not require DNSSEC, at a cost of risking malicious downgrades. For a thorough discussion of this trade-off, see Section 10, "Security Considerations". In addition, MTA-STS provides an optional testing-only mode, enabling soft deployments to detect policy failures; partial deployments can be achieved in DANE by deploying TLSA records only for some of a domain's MXes, but such a mechanism is not possible for the per- domain policies used by MTA-STS. The primary motivation of MTA-STS is to provide a mechanism for domains to ensure transport security even when deploying DNSSEC is undesirable or impractical. However, MTA-STS is designed not to interfere with DANE deployments when the two overlap; in particular, senders who implement MTA-STS validation MUST NOT allow MTA-STS Policy validation to override a failing DANE validation. 3 . Policy Discovery RFC5785] path served within the Policy Domain, and their presence and current version are indicated by a TXT record at the Policy Domain. These TXT records additionally contain a policy "id" field, allowing Sending MTAs to check that a cached policy is still current without performing an HTTPS request. To discover if a recipient domain implements MTA-STS, a sender need only resolve a single TXT record. To see if an updated policy is available for a domain for which the sender has a previously cached policy, the sender need only check the TXT record's version "id" against the cached value. Margolis, et al. Standards Track [Page 5]

RFC 8461 MTA-STS September 2018 3.1 . MTA-STS TXT Records RFC7405], is as follows: sts-text-record = sts-version 1*(sts-field-delim sts-field) [sts-field-delim] sts-field = sts-id / ; Note that sts-id record sts-extension ; is required. sts-field-delim = *WSP ";" *WSP sts-version = %s"v=STSv1" sts-id = %s"id=" 1*32(ALPHA / DIGIT) ; id=... sts-extension = sts-ext-name "=" sts-ext-value ; name=value sts-ext-name = (ALPHA / DIGIT) *31(ALPHA / DIGIT / "_" / "-" / ".") sts-ext-value = 1*(%x21-3A / %x3C / %x3E-7E) ; chars excluding "=", ";", SP, and CTLs The TXT record MUST begin with the sts-version field; the order of other fields is not significant. If multiple TXT records for "_mta-sts" are returned by the resolver, records that do not begin with "v=STSv1;" are discarded. If the number of resulting records is not one, or if the resulting record is syntactically invalid, senders MUST assume the recipient domain does not have an available MTA-STS Margolis, et al. Standards Track [Page 6]

RFC 8461 MTA-STS September 2018 Section 5.1, "Policy Application Control Flow".) If the resulting TXT record contains multiple strings, then the record MUST be treated as if those strings are concatenated without adding spaces. The "_mta-sts" record MAY return a CNAME that points (directly or via other CNAMEs) to a TXT record, in which case senders MUST follow the CNAME pointers. This can be used for policy delegation, as described in Section 8.2. 3.2 . MTA-STS Policies RFC5322]) served via the HTTPS GET method from the fixed "well-known" [RFC5785] path of ".well-known/mta-sts.txt" served by the Policy Host. The Policy Host DNS name is constructed by prepending "mta-sts" to the Policy Domain. Thus, for a Policy Domain of "example.com", the full URL is "https://mta-sts.example.com/.well-known/mta-sts.txt". When fetching a policy, senders SHOULD validate that the media type is "text/plain" to guard against cases where web servers allow untrusted users to host non-text content (typically, HTML or images) at a user-defined path. All parameters other than charset=utf-8 or charset=us-ascii are ignored. Additional "Content-Type" parameters are also ignored. This resource contains the following CRLF-separated key/value pairs: o "version": Currently, only "STSv1" is supported. o "mode": One of "enforce", "testing", or "none", indicating the expected behavior of a Sending MTA in the case of a policy validation failure. See Section 5, "Policy Application", for more details about the three modes. o "max_age": Max lifetime of the policy (plaintext non-negative integer seconds, maximum value of 31557600). Well-behaved clients SHOULD cache a policy for up to this value from the last policy fetch time. To mitigate the risks of attacks at policy refresh time, it is expected that this value typically be in the range of weeks or greater. Margolis, et al. Standards Track [Page 7]

RFC 8461 MTA-STS September 2018 RFC5891], the "mx" value MUST specify the Punycode-encoded A-label [RFC3492] to match against, and not the Unicode-encoded U-label. The full semantics of certificate validation (including the use of wildcard patterns) are described in Section 4.1, "MX Host Validation". An example policy is as below: version: STSv1 mode: enforce mx: mail.example.com mx: *.example.net mx: backupmx.example.com max_age: 604800 The formal definition of the policy resource, defined using ABNF [RFC7405], is as follows: sts-policy-record = sts-policy-field *WSP *(sts-policy-term sts-policy-field *WSP) [sts-policy-term] sts-policy-field = sts-policy-version / ; required once sts-policy-mode / ; required once sts-policy-max-age / ; required once sts-policy-mx / ; required at least once, except when ; mode is "none" sts-policy-extension ; other fields sts-policy-field-delim = ":" *WSP sts-policy-version = sts-policy-version-field sts-policy-field-delim sts-policy-version-value sts-policy-version-field = %s"version" Margolis, et al. Standards Track [Page 8]

RFC 8461 MTA-STS September 2018 Section 4.1.2 of [RFC5321]> Parsers MUST accept TXT records and policy files that are syntactically valid (i.e., valid key/value pairs separated by semicolons for TXT records), possibly containing additional key/value pairs not specified in this document, in which case unknown fields SHALL be ignored. If any non-repeated field -- i.e., all fields excepting "mx" -- is duplicated, all entries except for the first SHALL be ignored. 3.3 . HTTPS Policy Fetching RFC2818]. During the TLS handshake initiated to fetch a new or updated policy from the Policy Host, the Policy Host HTTPS server MUST present an X.509 certificate that is valid for the "mta-sts" DNS-ID [RFC6125] (e.g., "mta-sts.example.com") as described below, chain to a root CA that is trusted by the Sending MTA, and be non- expired. It is expected that Sending MTAs use a set of trusted CAs similar to those in widely deployed web browsers and operating systems. See [RFC5280] for more details about certificate verification. The certificate is valid for the Policy Host (i.e., "mta-sts" prepended to the Policy Domain) with respect to the rules described in [RFC6125], with the following application-specific considerations: o Matching is performed only against the DNS-ID identifiers. o DNS domain names in server certificates MAY contain the wildcard character '*' as the complete left-most label within the identifier. The certificate MAY be checked for revocation via the Online Certificate Status Protocol (OCSP) [RFC6960], certificate revocation lists (CRLs), or some other mechanism. Policies fetched via HTTPS are only valid if the HTTP response code is 200 (OK). HTTP 3xx redirects MUST NOT be followed, and HTTP caching (as specified in [RFC7234]) MUST NOT be used. Senders may wish to rate-limit the frequency of attempts to fetch the HTTPS endpoint even if a valid TXT record for the recipient domain exists. In the case where the HTTPS GET fails, implementers SHOULD limit further attempts to a period of five minutes or longer per version ID, to avoid overwhelming resource-constrained recipients with cascading failures. Margolis, et al. Standards Track [Page 10]

RFC 8461 MTA-STS September 2018 Section 10, MTAs SHOULD proactively refresh cached policies before they expire; a suggested refresh frequency is once per day. To enable administrators to discover problems with policy refresh, MTAs SHOULD alert administrators (through the use of logs or similar) when such attempts fail, unless the cached policy mode is "none". 3.4 . Policy Selection for Smart Hosts and Subdomains RFC5321]. When sending mail to a mailbox at a subdomain, compliant senders MUST NOT attempt to fetch a policy from the parent zone. Thus, for mail sent to "user@mail.example.com", the policy can be fetched only from "mail.example.com", not "example.com". 4 . Policy Validation Section 4.1, "MX Host Validation". Margolis, et al. Standards Track [Page 11]

RFC 8461 MTA-STS September 2018 Section 4.2, "Recipient MTA Certificate Validation". When these conditions are not met, a policy is said to fail to validate. This section does not dictate the behavior of Sending MTAs when the above conditions are not met; see Section 5, "Policy Application", for a description of Sending MTA behavior when policy validation fails. 4.1 . MX Host Validation RFC6125], with the restriction that the wildcard character '*' may only be used to match the entire left-most label in the presented identifier. Thus, the mx pattern "*.example.com" matches "mail.example.com" but not "example.com" or "foo.bar.example.com". 4.2 . Recipient MTA Certificate Validation RFC5280] with a DNS-ID [RFC6125] matching the hostname, per the rules given in [RFC6125]. The MX's certificate MAY also be checked for revocation via OCSP [RFC6960], CRLs [RFC6818], or some other mechanism. 5 . Policy Application RFC8460] send a report indicating policy application failures (as long as TLSRPT is also implemented by the recipient domain); in any case, messages may be delivered as though there were no MTA-STS validation failure. Margolis, et al. Standards Track [Page 12]

RFC 8461 MTA-STS September 2018 Section 8.3, "Removing MTA-STS", for use of this mode value. When a message fails to deliver due to an "enforce" policy, a compliant MTA MUST NOT permanently fail to deliver messages before checking, via DNS, for the presence of an updated policy at the Policy Domain. (In all cases, MTAs SHOULD treat such failures as transient errors and retry delivery later.) This allows implementing domains to update long-lived policies on the fly. 5.1 . Policy Application Control Flow Section 4, "Policy Validation". If a candidate fails validation, continue to the next candidate (if there is one). 3. A message delivery attempt MUST NOT be permanently failed until the sender has first checked for the presence of a new policy (as indicated by the "id" field in the "_mta-sts" TXT record). If a new policy is not found, existing rules for the case of temporary message delivery failures apply (as discussed in [RFC5321], Section 4.5.4.1). 6 . Reporting Failures RFC8460] in order to ensure that implementing domains can detect cases of both benign and malicious failures and to ensure that failures that indicate an active attack are discoverable. As such, senders that also implement TLSRPT SHOULD treat the following events as reportable failures: o HTTPS policy fetch failures when a valid TXT record is present. o Policy fetch failures of any kind when a valid policy exists in the policy cache, except if that policy's mode is "none". Margolis, et al. Standards Track [Page 13]

RFC 8461 MTA-STS September 2018 7 . Interoperability Considerations 7.1 . SNI Support RFC6066]. When connecting to an HTTP server to retrieve the MTA-STS Policy, the SNI extension MUST contain the name of the Policy Host (e.g., "mta-sts.example.com"). When connecting to an SMTP server, the SNI extension MUST contain the MX hostname. HTTP servers used to deliver MTA-STS policies MAY rely on SNI to determine which certificate chain to present to the client. HTTP servers MUST respond with a certificate chain that matches the policy hostname or abort the TLS handshake if unable to do so. Clients that do not send SNI information may not see the expected certificate chain. SMTP servers MAY rely on SNI to determine which certificate chain to present to the client. However, servers that have one identity and a single matching certificate do not require SNI support. Servers MUST NOT enforce the use of SNI by clients, as the client may be using unauthenticated opportunistic TLS and may not expect any particular certificate from the server. If the client sends no SNI extension or sends an SNI extension for an unsupported server name, the server MUST simply send a fallback certificate chain of its choice. The reason for not enforcing strict matching of the requested SNI hostname is that MTA-STS TLS clients may be typically willing to accept multiple server names but can only send one name in the SNI extension. The server's fallback certificate may match a different name that is acceptable to the client, e.g., the original next-hop domain. 7.2 . Minimum TLS Version Support RFC5246] or TLS 1.3 [RFC8446] or higher. The general TLS usage guidance in [RFC7525] SHOULD be followed. Margolis, et al. Standards Track [Page 14]

RFC 8461 MTA-STS September 2018 https://mta-sts.provider.example Note that in all such cases, the policy endpoint ("https://mta-sts.user.example/.well-known/mta-sts.txt" in this example) must still present a certificate valid for the Policy Host ("mta-sts.user.example"), and not for that host at the provider's domain ("mta-sts.provider.example"). Note that while Sending MTAs MUST NOT use HTTP caching when fetching policies via HTTPS, such caching may nonetheless be useful to a reverse proxy configured as described in this section. An HTTPS policy endpoint expecting to be proxied for multiple hosted domains -- as with a large mail hosting provider or similar -- may wish to indicate an HTTP Cache-Control "max-age" response directive (as specified in [RFC7234]) of 60 seconds as a reasonable value to save reverse proxies an unnecessarily high-rate of proxied policy fetching. 8.3 . Removing MTA-STS Margolis, et al. Standards Track [Page 16]

RFC 8461 MTA-STS September 2018 10.2 . Preventing Policy Discovery Section 8.3.) Resistance to downgrade attacks of this nature -- due to the ability to authoritatively determine "lack of a record" even for non- participating recipients -- is a feature of DANE, due to its use of DNSSEC for policy discovery. 10.3 . Denial of Service Margolis, et al. Standards Track [Page 19]

RFC 8461 MTA-STS September 2018 10.4 . Weak Policy Constraints 10.5 . Compromise of the Web PKI System Margolis, et al. Standards Track [Page 20]

RFC 8461 MTA-STS September 2018 Margolis, et al. Standards Track [Page 26]

RFC 8461 MTA-STS September 2018 Margolis, et al. Standards Track [Page 27]

RFC 8461 MTA-STS September 2018 Margolis, et al. Standards Track [Page 28]