{"id":417024,"date":"2024-06-30T01:18:31","date_gmt":"2024-06-30T01:18:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=417024"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=417024","title":{"rendered":"<span>Dive into Email Security: MTA-STS Policies<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/eu\/he\/ty\/euhetyj14ttejehqbyy6vljuagq.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/eu\/he\/ty\/euhetyj14ttejehqbyy6vljuagq.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  In a nutshell: MTA-STS is a way to protect emails against interception (man-in-the-middle aka MitM attacks) between email servers. It partially resolves architectural issues in email protocols and is described in a recent RFC 8461 standard.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>What is the issue MTA-STS resolves?<\/h2>\n<p>  Historically, email protocols (SMTP, POP3, IMAP) transfer information in plaintext, making it possible to intercept, e.g. by accessing a communication link. This is how email delivery works:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/74\/0b\/yj\/740byjoorfuxqprn23kcnwwq8py.png\" data-src=\"https:\/\/habrastorage.org\/webt\/74\/0b\/yj\/740byjoorfuxqprn23kcnwwq8py.png\"\/><\/p>\n<p>  Historically, Man-in-the-Middle attack was possible everywhere.<\/p>\n<p>  RFC 8314 standard requires using TLS between a mail user agent (MUA) and an email server. If your server and MUA match to RFC 8314, this mostly means elimination of Man-in-the-Middle attacks between MUA and mail servers:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/am\/ju\/mh\/amjumhnp2_kq6e3ywtmlmjvbfqa.png\" data-src=\"https:\/\/habrastorage.org\/webt\/am\/ju\/mh\/amjumhnp2_kq6e3ywtmlmjvbfqa.png\"\/><\/p>\n<p>  Our Mail.ru email servers had already matched to RFC 8314 before the standard was adopted; it just reinforces best practices, so we had nothing to adjust. But if your email server still connects through unsecure protocols, you have to implement the standard. Because part of your users still has no encryption using email.<\/p>\n<p>  The mail client always works with one and the same mail server. So we can force all users to connect securely and then make unsecure connections technically impossible (as specified by RFC 8314). Sometimes it is hard to do, but still possible. Things get more complicated when it comes to traffic between mail servers. Servers are owned by different organizations and are often used like \u00abinstall and forget\u00bb. So we can\u2019t quickly switch over to a secure protocol without loss of connectivity. STARTTLS extension, provided in SMTP, allows servers with encryption switch to TLS.<\/p>\n<p>  However, the attacker can know about using STARTTLS and make servers communicate over standard text protocol (so-called downgrade attack). For the same reason, certificate validity is not usually verified for STARTTLS. So an untrusted certificate can protect from passive attacks, which is no worse than sending an mail in plaintext. Thus, STARTTLS protects only from passive traffic sniffing.<\/p>\n<p>  MTA-STS partially resolves the mail interception issue between mail servers when the attacker can spoof traffic. If the recipient&#8217;s domain publishes MTA-STS policy, and the sender&#8217;s server supports MTA-STS, mail will be sent only through TLS connection. This applies only to servers specified by the policy, and only with the server&#8217;s certificate validation.<\/p>\n<p>  Why partially? MTA-STS operates only when both parties have implemented this standard. MTA-STS does not protect if the attacker has obtained a valid domain certificate from a public CA.<\/p>\n<h2>How MTA-STS works<\/h2>\n<p>  <strong>Recipient<\/strong><\/p>\n<ol>\n<li>Implements support for STARTTLS with a valid certificate.\u00a0<\/li>\n<li>Publishes MTA-STS policy through HTTPS; special mta-sts domain and special well-known path are used, for example, <code>https:\/\/mta-sts.mail.ru\/.well-known\/mta-sts.txt<\/code>. The policy contains a list of mail servers (mx) to receive mail for this domain.<\/li>\n<li>Publishes special TXT record <code>_mta-sts<\/code> in DNS with policy version. Whenever the policy is modified, this record should be updated (this prompts the sender to request it again). For example, <code>_mta-sts.mail.ru. TXT \"v=STSv1; id=20200303T120000;\"<\/code><\/li>\n<\/ol>\n<p>  <strong>Sender<\/strong><\/p>\n<p>  The sender requests DNS record <code>_mta-sts<\/code> and policy through HTTPS (verifying the certificate). The obtained policy is cached (for the case if an attacker blocks access to it or spoofs DNS record).<\/p>\n<p>  When mail is sent, it is verified that:<\/p>\n<ul>\n<li>the destination server is listed in the policy;<\/li>\n<li>the server receives mail using TLS (STARTTLS) and has a valid certificate.<\/li>\n<\/ul>\n<h2>Benefits of MTA-STS<\/h2>\n<p>  MTA-STS uses technologies that have already been used by most organizations (SMTP+STARTTLS, HTTPS, DNS). Implementation by the recipient does not require special software support for the standard.<\/p>\n<h2>Disadvantages of MTA-STS<\/h2>\n<p>  You have to be sure that web and mail server certificates are valid, names are consistent, and updates are made on time. A problem with the certificate will make mail delivery impossible.<\/p>\n<p>  The sender is required MTA with support for MTA-STS policies; currently, there is no out-of-the-box support for MTA-STS in MTA.<\/p>\n<p>  MTA-STS uses a list of trusted root CA.<\/p>\n<p>  MTA-STS does not protect from attacks where a valid certificate is used. Generally, near-server Man-in-the-Middle attacks require that a certificate can be issued. Such an attack can be detected through Certificate Transparency. Generally, MTA-STS mitigates the risk of traffic interception but does not eliminate it.<\/p>\n<p>  The last two points make MTA-STS less protected than the standard DANE for SMTP (RFC 7672), but more technically reliable. For MTA-STS it is less probable that a mail will not be delivered due to implementation problems.<\/p>\n<h2>Competitive standard \u2014 DANE<\/h2>\n<p>  DANE uses DNSSEC to publish certificates and does not require any external CA, which makes it much safer. However, the use of DNSSEC will result in more technical issues, according to statistics. But the reliability of DNSSEC and its technical support is progressing. Using of DANE in SMTP by recipient requires the availability of DNSSEC for the DNS zone. Proper support for NSEC\/NSEC3 is significant for DANE, but DNSSEC has problems with it.<\/p>\n<p>  DNSSEC misconfiguration can lead to mail delivery failures if the sender supports DANE, even if the recipient knows nothing about it. So, despite DANE is an older and more secure standard, and it is supported by some sender&#8217;s server software, many organizations don\u2019t want to use it because of DNSSEC. This has significantly slowed down the adoption of DANE.<\/p>\n<p>  DANE and MTA-STS can be used together.<\/p>\n<h2>What about support for MTA-STS in Mail.ru service<\/h2>\n<p>  Mail.ru has been publishing MTA-STS policy for all major domains since this year. Now we are implementing the client part of the standard. At the time of this publication, policies are used in non-blocking mode (when delivery is blocked by policy, an email will be delivered through a \u00abspare\u00bb server without policy application). Later blocking mode will be forced for a small portion of SMTP traffic, and later we\u2019ll apply the policy for all the traffic.<\/p>\n<h2>Who else supports the standard<\/h2>\n<p>  MTA-STS policies are published by approximately 0.05% of active domains that protect a large amount of mail traffic: Google, Comcast, and, partially, Verizon (AOL, Yahoo). Many other email services are going to implement the standard in the nearest future.<\/p>\n<h2>How this will affect me?<\/h2>\n<p>  In no way, if your domain does not publish MTA-STS policy. If you do publish the policy, then emails for your users will be better protected from interception.<\/p>\n<h2>How should I implement MTA-STS?<\/h2>\n<p>  <strong>Support for MTA-STS on recipient&#8217;s side<\/strong><\/p>\n<p>  It is enough to publish policy through HTTPS and make a record in DNS, configure a valid certificate from a trusted CA (it can be \u00abLet\u2019s encrypt\u00bb) for STARTTLS in MTA (STARTTLS is supported in all modern MTA); no special support from MTA will be required.<\/p>\n<p>  Stepwise, it looks as follows:<\/p>\n<ol>\n<li>Configure STARTTLS in your MTA (postfix, exim, sendmail, Microsoft Exchange, etc.).<\/li>\n<li>Use valid certificate (issued by a trusted CA, not expired, subject of the certificate matches the MX record used for mail delivery for your domain).<\/li>\n<li>Configure TLS-RPT record for reports delivery of policies using (by services that support sending of TLS reports). For instance (for domain example.com):\n<pre><code class=\"plaintext\">smtp._tls.example.com. 300 IN TXT \"v=TLSRPTv1;rua=mailto:tlsrpt@example.com\" <\/code><\/pre>\n<p>  This record instructs to send statistical reports on the use of TLS in SMTP to address <code>tlsrpt@exmple.com<\/code>.<\/p>\n<p>  Monitor the reports for several days to ensure that there are no errors.<\/li>\n<li>Publish MTA-STS policy through HTTPS. The policy is published as a text file with string terminators CRLF according to location.\n<pre><code class=\"plaintext\">https:\/\/mta-sts.example.com\/.well-known\/mta-sts.txt <\/code><\/pre>\n<p>  Policy example:<\/p>\n<pre><code class=\"plaintext\">version: STSv1 mode: enforce mx: mxs.mail.ru mx: emx.mail.ru mx: mx2.corp.mail.ru max_age: 86400 <\/code><\/pre>\n<p>  The <code>version<\/code> field contains the policy version (now it is <code>STSv1<\/code>).<code>mode<\/code> sets the mode of policy application, <code>testing<\/code> means test mode (policy is not applied), and <code>enforce<\/code> stands for <code>operational<\/code> mode.\u00a0<\/p>\n<p>  First, publish the policy with <code>mode: testing<\/code>, and if no policy problems arise, you can switch to <code>mode: enforce<\/code>.<\/p>\n<p>  All email servers which can receive mail for your domain are listed in <code>mx<\/code> (for each server, configure a certificate matching the name specified in <code>mx<\/code>). <code>Max_age<\/code> specifies a time of policy caching (once saved, the policy will be applied even if the attacker blocks its delivery or spoofs DNS records during the caching; modify mta-sts record in DNS if you need to request policy again).<\/li>\n<li>Publish TXT record in DNS:\u00a0\n<pre><code class=\"plaintext\">_mta-sts.example.com. TXT \"v=STSv1; id=someid;\" <\/code><\/pre>\n<p>  An arbitrary identifier can be used in <code>id<\/code> field (timestamp); it should change with policy modification\u00a0\u2014\u00a0this lets the sender know that a cached policy needs to be requested again (if the identifier differs from the cached one).<\/li>\n<\/ol>\n<p>  <strong>Support for MTA-STS on the sender&#8217;s side<\/strong><\/p>\n<p>  It is limited as yet since the standard is new:<\/p>\n<ul>\n<li>Exim \u2014 no internal support, but there is a <a href=\"https:\/\/github.com\/Bobberty\/MTASTS-EXIM-PERL\">third-party script<\/a>;<\/li>\n<li>Postfix \u2014 no internal support, but there is a third-party script described in detail on <a href=\"https:\/\/pypi.org\/project\/postfix-mta-sts-resolver\/&amp;sa=D&amp;ust=1598966988564000&amp;usg=AFQjCNFCwb4rXqzf_aGZ8Ti1XYaBqJPm0w\">pypi.org<\/a>.<\/li>\n<\/ul>\n<p>  <\/p>\n<h2>End title: about \u00abmandatory TLS\u00bb<\/h2>\n<p>  Regulators have been increasingly focusing on email security (which is good news). For example, DMARC is mandatory for all government agencies in the U.S. and is increasingly required in the financial sector, adoption in regulated sectors reaching 90%. Some regulators now require using \u00abmandatory TLS\u00bb with well-known domains. However, the way for supporting \u00abmandatory TLS\u00bb is not defined, and implementing this setting often does not protect from actual attacks, which have already been accounted for in DANE or MTA-STS.<\/p>\n<p>  If the regulator requires the implementation of \u00abmandatory TLS\u00bb with separate domains, we recommend using MTA-STS or its partial equivalent as it doesn\u2019t require to make safe settings for each domain individually. If you have difficulties with the implementation of the client part of MTA-STS (you probably will until the protocol is widely supported), here is a recommendation:<\/p>\n<ol>\n<li>Publish MTA-STS policy and\/or DANE records (better to add DANE only when DNSSEC is already enabled for your domain, and MTA-STS\u00a0in any case), this will protect your inbound traffic and you don\u2019t need to request other email services to set up mandatory TLS for your domain when the email service already supports MTA-STS and\/or DANE.<\/li>\n<li>For major email services, implement an \u00abequivalent\u00bb of MTA-STS through separate transport settings for each domain which will configure MX used for relaying mail and will require verification of TLS certificate for it. If domains already publish MTA-STS policy, this, most probably, can be done smoothly. The enabling of mandatory TLS without configuring a relay and verifying a certificate doesn\u2019t protect you and doesn\u2019t improve STARTTLS protection.<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/517544\/\"> https:\/\/habr.com\/ru\/articles\/517544\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/eu\/he\/ty\/euhetyj14ttejehqbyy6vljuagq.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/eu\/he\/ty\/euhetyj14ttejehqbyy6vljuagq.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  In a nutshell: MTA-STS is a way to protect emails against interception (man-in-the-middle aka MitM attacks) between email servers. It partially resolves architectural issues in email protocols and is described in a recent RFC 8461 standard.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-417024","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/417024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=417024"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/417024\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=417024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=417024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=417024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}