CCyberwiki

MTA-STS and TLS-RPT

MTA-STS and TLS-RPT
TypeMail transport policy and reporting
Defined inRFC 8461 (MTA-STS), RFC 8460 (TLS-RPT), September 2018
DNS names_mta-sts, _smtp._tls, mta-sts
OWASP Top 10A04:2025 Cryptographic Failures
ProtectsMail sent to a domain, on the hop between the sending and receiving servers

When one mail server hands a message to another, the receiving server lists the extensions it supports in a plain-text reply. One line of that reply, 250 STARTTLS, offers to switch the connection to TLS. The offer is not encrypted, so a party on the network path can delete it, and the sending server then delivers the message in plain text.1 MTA-STS (SMTP MTA Strict Transport Security) lets the receiving domain publish a policy stating that its servers always accept TLS with a valid certificate; a sender holding a policy in enforce mode refuses to fall back.2 TLS-RPT (SMTP TLS Reporting) has senders mail or post the domain a daily report on its TLS connections, failed ones included.3

Opportunistic encryption

SMTP was designed without encryption. STARTTLS, defined in RFC 3207 in 2002, added it as an upgrade the two servers agree to inside a connection that is already open.1 A sender using it opportunistically encrypts when the other side offers TLS and expects no particular certificate.2 That leaves two openings for a manipulator in the middle. It can remove the STARTTLS line from the reply, or it can send the whole session to a server it controls, for example by forging the domain's MX record.2

Stripping has been seen on real networks. In 2014 researchers found internet providers in the United States and Thailand removing the STARTTLS flag from their customers' mail traffic. Some firewalls, Cisco's PIX/ASA among them, do this to inspect outgoing mail for spam, and the side effect is mail crossing the public internet unencrypted. It had gone mostly unnoticed because it happened on home connections, where few people run a mail server.1

Policy record and file

A domain announces MTA-STS with a DNS TXT record at _mta-sts. The policy itself is a text file served over HTTPS from a fixed path on the subdomain mta-sts:2

_mta-sts.example.com.  TXT  "v=STSv1; id=20261122000000"

https://mta-sts.example.com/.well-known/mta-sts.txt

version: STSv1
mode: enforce
mx: mail.example.com
mx: *.example.net
max_age: 604800

The id is 1 to 32 letters and digits. Senders cache the policy and, on later deliveries, compare only the id in DNS with the one they stored, so the id is how they learn that the file has changed.2 Senders should accept the file only when it is served as text/plain, which keeps an HTML page or an image uploaded by a site's users from being read as a policy.2

Each mx line names a mail server the domain uses, and a wildcard such as *.example.net stands for one label on the left.4 max_age is how many seconds a sender keeps the policy, at most 31,557,600, about a year.2 Google Workspace requires at least 86,400, one day.4

What senders check

A sender that supports MTA-STS checks three things for each candidate server: that its name matches an mx line, that it offers STARTTLS, and that its certificate is valid for that name and chains to a trusted certificate authority. The mode decides what a failed check does.2

Table 1. Policy modes
ModeWhen a check fails
enforceThe sender does not deliver to that server and tries the next one. Before giving up on a message, it looks for a newer policy id.
testingThe sender delivers anyway. If the sender supports TLS-RPT and the domain publishes a TLS-RPT record, it reports the failure.
noneThe domain is treated as having no policy. Used to withdraw MTA-STS.

Servers that do not implement MTA-STS keep delivering as before. Mail is held back only when both sides support the standard and the check fails, and Exchange Online may then return a bounce to the person who sent it.5

TLS reporting

TLS-RPT is a second TXT record, at _smtp._tls, giving an email address or an HTTPS address for reports:3

_smtp._tls.example.com.  TXT  "v=TLSRPTv1; rua=mailto:tlsrpt@example.com"

Each report is a JSON file, plain or gzipped, covering one full UTC day. It counts successful and failed TLS sessions and labels failures with result types such as starttls-not-supported, certificate-expired and certificate-host-mismatch. A sender mailing a report delivers it even when TLS to the report address fails.3

Trust on first fetch

The policy protects a delivery only after the sender has fetched and cached it, and only if the attacker cannot get a valid certificate for a listed server. If an attacker blocks the first lookup, the sender falls back to opportunistic TLS, which the attacker can strip. The standard answers with long max_age values and a refresh of the cached copy about once a day, well before it expires, so the attacker would have to block every refresh for as long as the copy lives.2

The cache also works against the owner. Someone who takes over a domain's DNS can publish a policy with a long max_age that lists their own server; after the owner restores the records, senders keep refusing the real servers until a new policy replaces the cached one.2 The related standard DANE ties certificates to DNS records signed with DNSSEC, which proves a DNS answer came from the domain's owner. It resists downgrade better than MTA-STS, but only on domains that have deployed DNSSEC.2 Neither hides mail from the providers at each end: STARTTLS protects the hop between servers, and both servers read the message.1

Deployment

  1. Create a mailbox for reports and publish the _smtp._tls record.6
  2. Serve mta-sts.txt with mode: testing, one mx line per mail server and a max_age of one to two weeks. The mta-sts subdomain needs its own HTTPS certificate.45
  3. Publish the _mta-sts record. DNS changes can take up to 24 hours to apply, depending on the record's TTL.6
  4. Read the daily reports for about two weeks and fix what they show.4
  5. Change to mode: enforce, raise max_age and publish a new id.2

Exchange Online checks MTA-STS on outgoing mail without any setting. A domain whose MX points to it lists *.mail.protection.outlook.com and hosts the policy file somewhere else, because Exchange Online does not host it.5 Google Workspace needs a separate file for every domain, up to 64 KB, updated whenever mail servers change.4 To withdraw, the owner publishes mode: none with a max_age of about a day and a new id, waits until every older policy has expired, and then deletes the records.2

In SecFlash

On the Email and domain page, SecFlash reports a domain without MTA-STS as SF-EML-111 and a policy file that senders cannot use (missing, served with the wrong type, missing fields, or not listing the domain's mail servers) as SF-EML-112. A policy left in testing or none mode is SF-EML-113, and a domain with no TLS-RPT record is SF-EML-114.

See also

References

  1. a b c d Hoffman-Andrews, J. (11 November 2014). "ISPs Removing Their Customers' Email Encryption". Deeplinks. Electronic Frontier Foundation.
  2. a b c d e f g h i j k l m Margolis, D. et al. (September 2018). "RFC 8461: SMTP MTA Strict Transport Security (MTA-STS)". RFC Editor. IETF.
  3. a b c Margolis, D. et al. (September 2018). "RFC 8460: SMTP TLS Reporting". RFC Editor. IETF.
  4. a b c d e "Create an MTA-STS policy". Google Workspace Admin Help. Google.
  5. a b c Microsoft. Exchange Online documentation page on MTA-STS mail flow. Microsoft Learn.
  6. a b "Turn on MTA-STS and TLS reporting". Google Workspace Admin Help. Google.