📜 ⬆️ ⬇️

Implementing DMARC to protect your corporate domain from spoofing

A Thief on the Run by Manweri
A Thief on the Run by Manweri

Hi, Habr! In this post we will again talk about the problem of the fake sender (or the so-called spoofing). Recently, such cases have become very frequent: everything is forged: letters with bills for housing and communal services, from the tax inspectorate, banks, and so on. Configuring a strict DMARC policy helps solve this problem. We, as a postal service, check all incoming letters to DMARC since February 2013. We were the first mail service in runet that supported the DMARC standards. However, to minimize the number of fake letters, this, unfortunately, is not enough. The main thing is that strict DMARC is supported on the sender's side. That is why we do not get tired to download this topic, we are actively engaged in explanatory work and strongly urge everyone to include strict DMARC.

Positive shifts are already there: every month we see a 10 percent increase in the number of corporate senders who have registered DMARC. However, of course, there is still something to work on. Practice shows that IT culture is at a very different level. Someone heard vaguely about DMARC, but is not going to introduce it yet. There are those for whom the fact that there is no verification and protection of the sender's address in the transport protocols of e-mail is still a real revelation. In addition, support for DMARC is not an easy task. Only at first glance it seems that it is enough to publish the record in the DNS, and no additional software or hardware is required (for more details, see our DMARC article : protect your mailing from fakes ). In practice, in a large company with numerous e-mail flows and a spreading structure of e-mail domains, everything is much more complicated. And there are moments that should be foreseen and thought out in advance. For such difficult cases, we wrote this article, trying to collect all the nuances in it.

We want to share our own experience of implementing DMARC and all the rakes we stepped on (crossed out) with the recommendations that we developed in cooperation with large companies and government agencies. We will consider only the implementation of the DMARC policy to protect a domain name. Implementing the server part of DMARC to protect corporate mail server users from fake emails is a separate, completely independent and independent process.
')
DMARC is a policy of actions with incoming letters that have a policy publishing domain in the From field. DMARC allows you not only to specify how to deal with such letters, but also to collect statistics from all recipients who support the server part of DMARC.

The main problem is that DMARC requires the authorization of all legitimate emails. And for this, it is necessary not only to implement authorization methods (SPF and DKIM are used as basic protocols), but also to ensure that for all legitimate emails with return addresses of the domain to pass, the authorization takes place. Therefore, the introduction of DMARC should begin with the following paragraph.

1. Audit legitimate emails from your domain and its subdomains


Typical omissions in this process:


For each category of letters, it is necessary to implement SPF and find out whether it is possible or impossible to sign letters using DKIM.

2. Implement SPF for the main domain and its subdomains


You can often hear that SPF protects the sender's address from being fake. This is not true. SPF only controls the address of the SMTP envelope that the user does not see. However, a large number of domains have not yet implemented it, and many parties do not support SPF-compatible mail forwarding. For this reason, neutral SPF (neutral ? ) Or soft blocking (soft reject, ~ ) is most often used. For sharing with DMARC, it does not matter which default policy (neutral ? Soft reject ~ or reject - ) SPF will be used. We do not recommend using the reject ( - ) policy with the exception of highly security-sensitive domains, as this may adversely affect the delivery of legitimate emails in indirect ways, such as through mailing lists or mailing lists. Although most recipients do not block SPF emails even when they publish strict policies, they use SPFs as part of weight classifiers. Contrary to popular belief, it is this SPF regime that is most often used in practice, and it fully complies with the recommendations of the standard.

You can make the following recommendations for the implementation of SPF:


3. Publish a DMARC record with a policy of none for the main domain and subdomains.


An example of such a record:

 _dmarc.example.com. TXT "v=DMARC1;p=none;rua=mailto:rua@example.com;ruf=mailto:ruf@example.com;fo=s" 

The record instructs the recipient to send daily statistical reports to rua@example.com . From the reports you will see all the IP addresses from which mailings were sent from your domain name, and the authorization status of SPF, DKIM and DMARC for these letters. Especially carefully follow the letters from your IP-addresses. Check the reports to see if you have missed any categories of letters or their sources in your audit. Adjust the SPF if necessary. Some recipients may send reports on individual cases of problems with SPF ( fo=s ) to the address ruf , these reports will be useful for identifying problem mailings.

Typical problems and recommendations:


4. Implement DKIM


Recommendations:


5. Start switching to strict policies.


Do not use the quarantine policy for a long time, as it may mask the existing problems. You are guaranteed to learn about the existence of problems only from aggregated reports, which may take more than a day to get.

You can start by turning on the reject policy at 10% ( p=reject; pct=10 ) to track potential problems with delivery errors. But it is not recommended to keep such a policy for a long time: the quarantine policy will be applied for the remaining 90% of the operations, and you can skip isolated problems

Be sure to follow the server logs and reports about the inability to deliver letters for errors related to DMARC. The standard recommends that recipients implementing the server part of DMARC be sure to include it as the cause in the error message, so you can use “DMARC” as the key word in the error message to identify the problem. According to the server logs, you will see the problem much earlier than the reports and you will know exactly which addresses which emails were not delivered.

You can implement a policy that is different from the policy of the main domain on separate subdomains by publishing separate policies for them or specifying the policy of the main domain ( p=none; sp=reject ): the sp policy will affect subdomains that do not publish their own policies.

When all subdomains are transferred to a strict policy, you can remove the policy of subdomains - or leave, at your discretion. This only affects the generation of reports in accordance with established practice (in the standard, this point is not negotiated). If a subdomain publishes its policy, separate reports will come to it; if there is no separate policy, then reports on the subdomain will be included in the report of the parent domain.

6. Tuning DMARC policy


Below is an analysis of some optional DMARC entry fields, examples and recommendations for their use.

p ( p=reject ) - DMARC policy. Tells the recipient how to deal with unauthenticated emails. It can be none (deliver letters to the recipient), quarantine (deliver letters to the Spam folder) and reject (not accept letters).

sp ( sp=quarantine ) is a policy for subdomains that do not publish independent policies. If the subdomain has its own DMARC policy, then sp does not affect it. If there is no sp field in the DMARC entry for subdomains that do not have their own policy, the policy from the p field is applied.

pct ( pct=20 ) - the percentage of emails that this policy applies to. For example, if you set a reject policy with pct=20 reject policy will be applied to the received letter with a probability of 20% and a quarantine policy with a probability of 80%.

rua ( rua=mailto:ruamailbox@example.com ) - the address to which recipients will send an aggregated (statistical) report. The address must belong to the same organizational domain. We recommend that you always publish an address for aggregated reports and monitor them at least during the implementation phase of the DMARC policy.

ruf ( ruf=mailto:rufmailbox@example.com ) is the address to which forensic reports (that is, research reports) will be sent by individual letters. By default, forensic reports are sent only for DMARC violations. You can use the fo option to regulate behavior. Currently, a relatively small number of recipients send forensic reports.

fo ( fo=1 ) - for what violations to send notifications. fo=0 (default behavior) sends reports only when both authentication fails: SPF and DKIM. fo=1 - when any of the authentication fails, even if an alternative method passes. fo=s sends forensic reports on problems with SPF authentication. fo=d - for DKIM problems.

adkim ( adkim=r ) - mode for checking compliance with the DKIM domain. The default mode is r (relaxed) and only the organizational domain should match. In strict ( s ) mode, a complete match of the domain from the sender's address to the domain from the DKIM signature is required. It makes sense to use strict domain matching, if part of your subdomains are delegated to untrusted parties.

aspf ( aspf=r ) - similarly for the domain from envelope-from, for which SPF and From is checked. For aspf=s these domains must be exactly the same in order to pass SPF authentication.

ri ( ri=86400 ) - the desired interval for receiving aggregated reports (in seconds). By default, reports are sent once a day, but some recipients (not all, because the server does not support this parameter) support sending reports at shorter intervals. At the stage of policy implementation, you can try using smaller ri, for example ri=3600 .

We are very pleased that domain owners have begun to think about protecting their domain name in electronic correspondence. Help on setting up DMARC is available here . If you have questions or need advice or help with setting up SPF, DKIM, DMARC, contact dmarc_support@corp.mail.ru or ask a question here. We hope that together we can make email safer for all users.

Source: https://habr.com/ru/post/315778/


All Articles