MTA-STS (Strict Transport Security)

MTA-STS (Mail Transfer Agent-Strict Transport Security, STS for short) is a fairly new tool for making sending and receiving mail more secure. MTA-STS has meanwhile been recognized as RFC-8461 and can therefore be used. Similar to DANE, information is stored in the DNS for STS. The big difference, however, is that no DNSSEC is required for STS. Many hosters do not currently support DNSSEC, which means that DANE cannot be used either. STS is intended to provide a remedy here (at least temporarily until DNSSEC and DANE have become established across the board).

Functionality

MTA-STS is intended to prevent mails from being exchanged unencrypted between mail servers; this explicitly concerns communication from mail server to mail server, not communication between mail server and client. The receiving mail server can inform the sending server via DNS that it explicitly supports TLS for transport encryption. Before sending an email, the sending mail server can retrieve an MTA-STS policy from a web server that defines which mail servers accept emails via TLS. The sending mail server saves the policy for a defined period and only delivers emails via TLS for this period. This is intended to prevent an email from being sent without transport encryption, for example if the StartTLS command is suppressed by a MITM attack. In principle, this is forced StartTLS for mail servers from the first mail. Although STS is not as secure as DANE, it is easier to implement as it does not require DNSSEC. As there are still many domains, including mine, that cannot yet be resolved via DNSSEC, STS can be useful here, at least temporarily, until DNSSEC and therefore DANE are implemented.

This Youtube video explains MTA-STS and DANE quite well:

Furnishings

Setting up STS is very simple. All you need is a mail server that supports TLS (StartTLS), 3 DNS names and a web server that is accessible via HTTPS.

Web server and MTA-STS policy

First, a policy must be created; for the test operation, this could look as follows for the frankysweblab.de domain, for example:

version: STSv1
mode: testing
max_age: 86400
mx: mail.frankysweblab.de
mx: *.frankysweblab.de

The policy contains the STS version (version), currently only STSv1 is available, the mode in which the policy works (mode: testing for tests mode: enforce for productive) and the time span that a mail server may cache the policy (max_age in seconds). In addition, all mail servers that require and support TLS are specified within the policy. These can be specified individually or as a wildcard (mx).

A productive policy for the domain frankysweblab.de would look something like this:

version: STSv1
mode: enforce
max_age: 15552000
mx: mail.frankysweblab.de
mx: *.frankysweblab.de

Compared to the test policy above, only the mode has changed, as well as the maximum cache duration (mode: enforce and max_age: 6 months 15552000 seconds).

The policy is now saved as a simple text file with the name mta-sts.txt The policy must now be transferred to a web server that is accessible via HTTPS, only http is not sufficient at this point.

In addition, the web server must be accessible under the name mta-sts.domain.de. For the domain frankysweblab.de, the web server must therefore be accessible under the domain mta-sts.frankysweblab.de. The policy is now saved in the .well_known directory:

MTA-STS (Strict Transport Security)

The policy for frankysweblab.de can therefore be accessed via the following link: https://mta-sts.frankysweblab.de/.well-known/mta-sts.txt The URL is fixed and cannot be changed; the domain name of the e-mail address (frankysweb.de, gmail.com) and then the prefix mta-sts and the order .well-known with the policy mta-sts.txt are always required. Here are a few examples:

The certificate for the web server must also come from a trustworthy CA. A self-signed certificate will not work here. Free certificates from Let's Encrypt and wildcard certificates are fine.

DNS entries

In addition to the DNS entry for "mta-sts" for the web server, two TXT records are also required:

  • _mta-sts.domain.de
  • _smtp._tls.domain.de (This TXT record is not mandatory, but without it the MTA-STS validator will complain)

The _mta-sts.domain.de entry only contains the STS version (v=STSv1) and an ID for the policy as a timestamp (id=20181230231800Z). This results in the following DNS TXT record for the domain frankysweblab.de:

  • Name: _mta-sts.frankysweblab.de
  • Text: v=STSv1; id=20181230231800Z

MTA-STS (Strict Transport Security)

The ID must then be adjusted accordingly if the policy changes.

The second TXT record is used for error analysis, mail servers can send information about problems to the stored e-mail address, so it can't hurt to enter a corresponding e-mail address. The following entry results for the domain frankysweblab.de (again, only one version and a corresponding e-mail address must be specified):

  • Name: _smtp._tls.frankysweblab.de
  • Text: v=TLSRPTv1; rua=mailto:postmaster@frankysweblab.de

MTA-STS (Strict Transport Security)

Test

First of all, you should check whether all mail servers (MX record) are configured accordingly for TLS; this can be done with the TLS test from CheckTLS check:

MTA-STS (Strict Transport Security)

The mail server must support at least TLS 1.2 for STS.

The STS configuration can be configured with the MTA-STS validator from Ayke van Laëthem. Only the domain needs to be entered for the test. The result will look something like this:

MTA-STS (Strict Transport Security)

In this example, it is still a test policy (see Mode testing), which therefore has a short time span (max_age). If there are no problems in test mode, the policy can be switched to production mode (mode enforce), in which case it is also necessary to significantly increase the time span (e.g. 4 - 6 months for max_age).

The web server that delivers the policy can be configured with the SSLTest from Qualys The web server should also achieve a proper ranking here and the certificate should be displayed as trustworthy.

MTA-STS (Strict Transport Security)

Conclusion

MTA-STS is a good approach in itself, but unfortunately it is still not very widespread. Mail servers and antiSPAM solutions that already support STS are still very rare. As the standard is still very young, this is not very surprising, but you can set it up and help MTA-STS to become established more quickly. However, if the course has already been set for DNSSEC, then the use of DANE should also be considered directly.

A word about Exchange Server: Exchange (incl. Exchange 2019) does not support STS. Here you still have to rely on alternative solutions. However, since Exchange Server is mainly used in internal networks and is usually protected by upstream email security products, the lack of this feature can be ignored.

15 thoughts on “MTA-STS (Strict Transport Security)”

  1. Man sollte nicht jeden Blödsinn mitmachen. Zeitstempel im DNS, Datei auf Webserver, der widerum ein separates Zertifikat braucht… und das nur um eine Art E-Mail-HSTS zu erreichen? Ich habe selten so viel Murks auf einem Haufen gesehen.

    Reply
  2. Es gibt ein Typo:
    Falsch: „Die Policy wird nun im Verzeichnis .well_known gespeichert:“
    Richtig: „Die Policy wird nun im Verzeichnis .well-known gespeichert:“
    Vorsicht also mit Copy & Paste.

    Gruß
    Intercepta

    Reply
  3. @Federick
    mit Lets Encrypt und entsprechenden Skripten lässt sich das eigentlich vollständig automatisieren.

    Es sind zwei DNS-Einträge:
    _mta-sts.kunde1.de
    mta-sts.kunde1.de

    Ein CNAME-Eintag würde bei _mta-sts problemlos umsetzbar sein. Setzt allerdings voraus, dass der Webhoster auch von Kunde1 die E-Mails verwaltet. Hostet er diese wo anders, muss der Eintrag vom Kunde anpassbar sein.

    Ein CNAME Eintrag für mta-sts wird ein SSL-Fehler hervorrufen, da das SSL-Zertikat aller Voraussicht nach nicht die entsprechende Subdomain enthält. Aber auch hier sehe ich eine Möglichkeit dies zu automatisieren. Wobei auch der Inhalt der Datei für den Kunden editierbar sein muss.

    Reply
  4. Erstmal vielen Dank für den super Blog-Beitrag!! Sehr gut beschrieben :)

    Es muss doch eine einfachere Lösung für Provider gehen die einen Shared-Mailserver für viele hunderte Kunden betreiben. Bei allen Kundendomains ein SSL-Zertifikat und dazugehörigen Webserver zu schalten ist unverhältnismäßig hoher Aufwand.

    _mta-sts.user.example. IN CNAME _mta-sts.provider.example.

    ^^ in dem Fall müsse ein SSL Schutz nur am Endpoit (mta-sts.provider.example) geschaltet werden was den Aufwand für Provider erheblich reduziert.

    In der RFC bin ich hierzu auf folgenden Punkt „8.2. Policy Delegation“ gestoßen, demnach ist eine Weiterleitung per CNAME möglich wenn am Endpoint ein valider SSL-Schutz besteht. Sofern ich den Teil nicht missverstehe sollte es also auch mit weniger Aufwand für Provider möglich sein.
    https://datatracker.ietf.org/doc/rfc8461/?include_text=1

    Reply
  5. Hallo Franky,

    erst einmal vielen Dank für diesen ausführlichen Blogbeitrag. Wieder mal sehr ausführlich und sehr aufschlussreich.

    Bei mir stellt sich die Frage, was ich an der Konfiguration falsch eingestellt habe, bzw. wo der Fehler zu suchen ist.
    Der von dir durchgeführte Test über Checktls.com zeigt bei mir an das TLS/Cert/Secure – FAIL ist. Auf die UTM sind die Ports 25 und 465 von extern erreichbar.

    Reply
  6. Wie sieht es eigentlich aus, wenn man viele verschiedene Domains hat, jedoch alle auf die gleichen MX zeigen, muss man dann für alle auch die Eintrage erstellen oder genügt es, nur für diejenige Domain, welche die MX hosted?

    Reply
    • Für die beiden DNS-Einträge _mta-sts.domain.de und _smtp._tls.domain.de kannst du auf DNS CNAME-Einträge zurückgreifen. Bezüglich der Adresse für die Textdatei funktioniert dies nicht. Sprich du brauchst dedizierte Adressen, welche über das jeweilige SSL-Zertifikat verfügen. Daher haben wir uns einen kl. Server mit Administrationspanel zugelegt, gehärtet und dort alle Subdomains entsprechend angelegt und anschließend mit LE versehen. Weil alles andere sprengt den Kostenrahmen auf Dauer.

      Reply
      • Danke für deine Antwort. Eigentlich meinte ich es so rum:
        Provider X betreibt einen Mailserver, welcher unter domain1.de erreichbar ist.
        Domain2.de, domain3.de etc senden über diesen Mailserver:
        domain2.de. 21599 IN MX 10 mx1.domain1.de.
        domain3.de. 21599 IN MX 10 mx1.domain1.de.
        domain4.de. 21599 IN MX 10 mx1.domain1.de.

        Müssen die Domänen domain2, domain3 etc nun auch über ssl erreichbar sein oder nur die Domäne, auf welcher der Mailserver läuft? Weil eigentlich müsste ja nur domain1.de abgesichert werden… (da ist dnssec mit dane logischer und einfacher :) )

        Reply
        • Genau dieses Szenario habe ich beschrieben. Für jede E-Mail muss es diese DNS-Einträge und Subdomain mit der Textdatei geben.

Leave a Comment