Most email between organizations is encrypted in transit, but the encryption is optional, and anyone on the network path can switch it off. A domain without DANE protection depends on a handshake that an attacker can edit. This article walks through that attack, shows why it fails against a domain that publishes a valid TLSA record, and explains how to detect and fix the gap.
Why SMTP encryption is negotiable
SMTP began as a plaintext protocol. TLS was added later through the STARTTLS extension (RFC 3207). The session starts unencrypted, the server advertises what it supports, and the client may then upgrade the connection.
A normal session looks like this:
S: 220 mx.example.com ESMTP
C: EHLO sender.example.net
S: 250-mx.example.com
S: 250-SIZE 52428800
S: 250-STARTTLS
S: 250 8BITMIME
C: STARTTLS
S: 220 2.0.0 Ready to start TLS
... TLS handshake, then the message is sent encrypted ...
Nothing in this exchange is authenticated. Between EHLO and STARTTLS, everything travels in cleartext. Most mail servers use opportunistic TLS: if they see STARTTLS, they use it, and if they don't, they send the message anyway. Delivery wins over protection, because refusing to deliver to a legitimate server that lacks TLS would break email.
The attack: stripping STARTTLS
An attacker who can intercept traffic between two mail servers (a compromised router, a hostile network operator, BGP hijacking, ARP spoofing on a shared segment) rewrites the server's EHLO response. There are two common variants:
- Delete the
250-STARTTLSline entirely. - Overwrite it with same-length garbage such as
250-XXXXXXXA, so TCP sequence numbers and packet sizes stay consistent.
The sending server sees no TLS support and does exactly what opportunistic TLS tells it to do:
S: 250-mx.example.com
S: 250-SIZE 52428800
S: 250-XXXXXXXA <- rewritten in transit
S: 250 8BITMIME
C: MAIL FROM:<[email protected]>
C: RCPT TO:<[email protected]>
C: DATA
C: Subject: Wire instructions ... <- readable by the attacker
The message goes across in plaintext. The attacker can read it, copy it, or modify it, for example by swapping bank details in an invoice. Neither side logs an error. The receiving server never learns a client tried to connect, and the sending server believes it made a normal delivery. Many logs will just record a TLS not used line that no one reads.
The attack needs no cryptographic skill, no stolen keys, and no certificate. The attacker only has to edit one line of one packet.
The same attack against a domain with DANE
DANE for SMTP (RFC 7672) changes the sender's decision. The receiving domain publishes a TLSA record in DNS that pins the certificate or public key its MX host will present:
_25._tcp.mx.example.com. 3600 IN TLSA 3 1 1 (
8cb0fc6c527506a053f4f14c8464bebbd6dede2738d11468dd953d7d6a3021f1 )
The fields mean: usage 3 (DANE-EE, the end-entity key is trusted directly), selector 1 (hash the public key, so the pin survives certificate renewals that reuse the key), matching type 1 (SHA-256). The zone must be signed with DNSSEC, which lets the sender prove the record is genuine and, just as important, prove when a record is present.
A DANE-aware sender follows different logic:
- Look up the MX and confirm the answer is DNSSEC-validated.
- Query
_25._tcp.<mx-host>for TLSA records. - If validated TLSA records exist, TLS is mandatory. The sender must negotiate STARTTLS and verify the presented key against the pinned hash. There is no plaintext fallback.
Now replay the attack. The attacker strips 250-STARTTLS. The sender already knows from DNS that this host must offer TLS, so a missing capability counts as a failure, not a cue to fall back. Delivery is deferred and the message stays in the queue. The attacker could present their own certificate, but it will not match the pinned hash. Forging the TLSA answer fails too, because the DNSSEC signature won't validate. Suppressing the record produces a DNSSEC validation failure (bogus), not a clean "no record" result. The worst the attacker achieves is a delivery delay, which is a denial of service, not a disclosure. Mail never leaves the sender's queue unencrypted.
What the missing record costs
For the unprotected domain, the exposure is concrete:
- Contracts, invoices, HR documents, and legal correspondence can be read in transit.
- Password-reset links and one-time codes sent by email can be harvested, which opens the door to account takeover.
- A modified invoice or payment instruction is hard to tell from the original, which is how business email compromise works.
- GDPR Article 32, HIPAA transmission security, and PCI DSS all expect appropriate protection for data in transit. An auditor who finds mail that can be silently downgraded will record it as a gap.
- Because nothing logs the attack, the breach may never be detected.
How validation and monitoring catch it
A platform like SetEnforce checks each element of the chain, because a broken link at any point turns DANE into a false sense of security:
| Check | What it verifies |
|---|---|
| MX resolution | Which hosts receive mail for the domain |
| DNSSEC on MX and TLSA zones | Chain of trust is valid and unbroken |
| TLSA presence | _25._tcp.<mx> exists for every MX host |
| STARTTLS offered | Server advertises the capability |
| Certificate match | The live key hashes to a published TLSA record |
| Record parameters | Usage 3 1 1 or 2 1 1, not outdated or mismatched combinations |
You can reproduce the core checks manually:
# MX hosts
dig +short MX example.com
# TLSA record, with DNSSEC data
dig +dnssec TLSA _25._tcp.mx.example.com
# Live key hash from the server
openssl s_client -starttls smtp -connect mx.example.com:25 -brief </dev/null
openssl s_client -starttls smtp -connect mx.example.com:25 </dev/null 2>/dev/null \
| openssl x509 -pubkey -noout \
| openssl pkey -pubin -outform DER \
| openssl dgst -sha256 -binary | xxd -p -c 64
The last hash must equal the value in the TLSA record. A mismatch after a certificate renewal is the most common reason DANE-protected mail starts bouncing, so continuous monitoring matters as much as the initial setup. Also enable TLS-RPT (RFC 8460). It gives you daily reports from senders about failed TLS negotiations, which is the closest thing to visibility into attempted downgrades.
Implementation steps
- Sign your zone with DNSSEC and publish the DS record at the registrar. Without this, TLSA records are ignored.
- Make sure every MX host supports STARTTLS with a modern TLS version and a valid certificate.
- Generate the TLSA hash from the public key using the command above, and publish
3 1 1records for each MX host. - Plan rollovers. Publish the TLSA record for the new key before deploying it, keep both records during the transition, then remove the old one after cached TTLs expire. Reusing the same key across renewals avoids the problem entirely.
- Enable DANE on your outbound server so you are protected when sending too. For Postfix:
smtp_dns_support_level = dnssec
smtp_tls_security_level = dane
- Add MTA-STS and TLS-RPT as a complement. MTA-STS (RFC 8461) covers senders that lack DNSSEC validation, though it is weaker because it relies on HTTPS and a first-contact trust window.
- Monitor continuously for expiring certificates, DNSSEC signature expiry, and TLSA drift.
Key takeaways
- Opportunistic STARTTLS can be defeated by deleting one line from the
EHLOresponse, and neither side sees an error. - A DNSSEC-validated TLSA record converts TLS from "preferred" to "required" for that host, so a stripped STARTTLS becomes a failed delivery instead of a plaintext one.
- Under DANE, the attacker's best outcome is delay, not disclosure.
- DANE depends on DNSSEC, and an unsigned zone offers no protection.
- Most DANE outages come from certificate rotation that leaves the TLSA record stale, so automate checks and use key reuse or overlapping records.
- Pair DANE with TLS-RPT and MTA-STS for reporting and broader sender coverage.