Skip to content

Lesson 5 of 14 · 15m

STARTTLS Is a Suggestion

STARTTLS upgrades are opportunistic and strippable; MTA-STS pins transport encryption with an HTTPS-fetched policy and TLS-RPT closes the visibility loop.

What Actually Happens

SMTP was born plaintext. When a sending MTA connects to your port 25 and gets 250-STARTTLS in the EHLO response, it may issue STARTTLS and upgrade the socket. May. If the capability isn't advertised, it sends in cleartext. If the certificate fails validation — and the baseline MTA does no validation, just opportunistic encryption — it proceeds anyway. This is "opportunistic TLS": better than nothing, indistinguishable from nothing under an active attacker.

The attack is embarrassingly mechanical. A MITM between the two servers proxies the TCP connection, strips STARTTLS from the EHLO advertisement (or answers the STARTTLS command with an error), and both sides fall back to cleartext. Neither MTA logs anything unusual — from each side it looks like the peer simply doesn't do TLS. Measurements published in 2015 ("Neither Snow Nor Rain Nor MITM") found exactly this at scale in the wild, and lazy cleartext fallback remained the dominant inter-MTA behavior for years after.

The Wrong Mental Model

"STARTTLS encrypts mail." It offers encryption. There is a difference between a protocol that allows TLS and one that requires it, and SMTP's requirement is zero. No MTA refuses to deliver because the peer lacks TLS — if it did, a large share of internet mail would stop moving, which is precisely why the fallback exists and precisely why stripping works.

MTA-STS: Pinning for Mail

RFC 8461 borrows the HSTS idea. Two artifacts:

  • A DNS record: _mta-sts.sudosecurity.org → v=STSv1; id=20261103T01. The id is a cache-buster — bump it every time the policy changes.
  • A policy file served over HTTPS from https://mta-sts.sudosecurity.org/.well-known/mta-sts.txt:
version: STSv1
mode: testing
mx: mail.sudosecurity.org
mx: *.sudosecurity.org
max_age: 86400

A sending MTA that supports MTA-STS fetches this policy and caches it for max_age seconds. In mode: enforce, it refuses to deliver to any MX host not matching an mx: pattern, refuses unauthenticated TLS (valid cert covering the MX hostname — matching the MX name, not the domain), and refuses cleartext fallback. In testing, it delivers normally but reports failures. none withdraws the policy.

Because the policy comes over HTTPS, an attacker on the SMTP path can't forge it — they already needed to not-strip TLS to reach the point where they learn the policy exists. The mx: globs must cover every MX hostname exactly as published; *.example.com matches exactly one leading label — mail.example.com yes, foo.bar.example.com no — and example.com matches literally.

TLS-RPT: The Reporting Half

RFC 8460's _smtp._tls.sudosecurity.org → v=TLSRPTv1; rua=mailto:dmarc@sudosecurity.org gives senders somewhere to mail JSON failure reports — which MX host, which certificate chain failed, whether a policy blocked them. Without it, an enforced MTA-STS deployment is flying blind: mail that can't be delivered securely just doesn't arrive, and the first you hear of it is a user complaint a week later.

DANE: The Other Answer

DANE (RFC 7672) publishes certificate fingerprints in DNS: TLSA _25._tcp.mail.example.com, usage 3 1 1 (DANE-EE, SPKI sha256). Stronger than MTA-STS in one way — no web PKI dependency — but requires DNSSEC end to end, and DNSSEC deployment is its own operational commitment. Postfix supports it (smtp_dns_support_level = dnssec, smtp_tls_security_level = dane). Pick one: for most operators MTA-STS + TLS-RPT is the reachable bar.

Correct Practice

Deploy mode: testing plus TLS-RPT first and actually read the reports — they tell you whether your certificate and MX names hold up under real senders. Bump id= on every change. Keep max_age at 86400 until you're confident. Move to enforce only after weeks of clean reports. This is exactly the progression a fresh Stalwart setup follows — and the mailadmin-side HTTPS host is already the natural place to serve mta-sts.txt.

Keep reading

Related articles from the SudoSecurity blog.