Skip to content
de
Ein Laptop in grüner Farbe mit einer Grafik, die eine E-Mail durch einen geöffneten Briefumschlag symbolisiert | SPIRIT/21
Von Matthias Bonn am 12.03.2024 IT Security

DKIM: A comprehensive guide for email system administrators

DKIM (DomainKeys Identified Mail) is an email authentication process that aims to verify the identity of the sender and thus ensure the integrity of the message sent. For email system administrators, implementing DKIM is a crucial step in improving the security and deliverability of emails. In this article, we dive deep into the requirements, configuration, pros and cons of DKIM, specifically geared towards a readership with a deep technical understanding.

Before we dive into the deep technical details of DKIM, it is important to understand the process of DKIM validation as it occurs when an email is received:

  1. email receipt: the recipient server receives an email that has a DKIM signature header.
  2. extract DKIM signature
  3. retrieve the public key
  4. validate signature
  5. result of the validation
    This validation process is central to the functioning of DKIM and the security of email communication, as it helps to identify forged or manipulated emails.

The structure of a DKIM signature header and its security aspects

A DKIM signature header is a complex element that contains a lot of information that is essential for the authentication and integrity assurance of an email. The header is generated by the outgoing mail server when an email is sent and is added to the message. Here is an overview of the most important components of a DKIM header:

  • v=Version: The version of the DKIM specification used for the signature.
  • a=Signature algorithm: The algorithm used to create the signature, typically rsa-sha256.
  • d=Domain of the sender: The domain that generated the DKIM signature.
  • s=selector: A specific string used in combination with the domain to locate the public key in the DNS.
  • bh=Body hash value: A hash value of the email content (body) that ensures that the content has not been altered after signing.
  • h=Signed header fields: A list of email header fields that have been included in the signature. This can include fields such as From, To, Date and Subject.
  • b=Signature: The actual digital signature of the signed data.

The DKIM signature secures the following security aspects of an email:

  1. Authenticity: The DKIM signature confirms that the email actually originates from the specified domain. This helps to verify the identity of the sender and prevent phishing attempts.
  2. Integrity of the content
  3. Integrity of the header information

In summary, by signing specific parts of the email and publishing the public key in the DNS, DKIM provides a robust method for ensuring the authenticity and integrity of email communications. These mechanisms are crucial for trust in digital correspondence and protect against various forms of email-based attacks and fraud.

Now that we understand the validation process, let’s dive deeper into the requirements, configuration, pros and cons of DKIM.

Requirements for the implementation of DKIM

Before you set up DKIM for your email system, you must ensure that your infrastructure fulfils certain requirements:

  • DNS access: DKIM uses DNS records to publish public keys. You therefore need the ability to create and edit DNS records for your domain(s).

  • Email server configuration: Your email server must support the DKIM signature. Most modern email servers such as Postfix, Exim or Microsoft Exchange have integrated support for DKIM.

  • Key management: You must be able to generate and securely manage key pairs (public and private keys). The private key is used for signing emails and must be stored securely.

Configuration of DKIM

Setting up DKIM essentially involves generating a key pair, configuring your email server and publishing the public key in the DNS. Here is a step-by-step guide:

  1. Generate key pair: Use a tool such as openssl to generate an RSA key pair. The private key is stored on your email server, while the public key is published in the DNS.

  2. Configure email server: Configure your email server to sign outgoing messages with the private key. The exact configuration varies depending on the e-mail system used.

  3. Create DNS entry: Publish the public key as a TXT entry in the DNS of your domain. The entry typically looks like this: selector._domainkey.yourdomain.com. IN TXT “v=DKIM1; k=rsa; p=MIGfMA0GCSqGSI…”

  4. Test: Use DKIM validation tools to verify that your configuration is correct and the signatures are valid.

Advantages and disadvantages of DKIM

Advantages:

  • Improved authenticity: DKIM helps to confirm the authenticity of email senders, which counteracts phishing and spoofing.

  • Better deliverability: Emails that use DKIM signatures often have a better chance of bypassing spam filters and reaching the recipient’s inbox.

  • Reputation Management: Domains that use DKIM consistently can improve their credibility and reputation with email service providers.

Disadvantages:

  • Complexity: DKIM can be complex to set up and manage, especially in large organizations with multiple domains and email servers.

  • Error susceptibility: Incorrectly configured DKIM signatures can cause legitimate emails to be classified as spam or rejected.

  • No encryption: DKIM does not offer encryption of the content. It only guarantees that the message has not been altered and that the sender is authentic.

Risks and challenges when using DKIM

In addition to the basic advantages and disadvantages, there are specific risks associated with the implementation and operation of DKIM, particularly in connection with email processing mechanisms such as automatic forwarding and the appending of footers:

  • Auto-forwarding: When an email is auto-forwarded by a server, the process can alter the headers of the original message. Since DKIM also signs certain header fields, these changes can mean that the DKIM signature can no longer be validated by the final recipient. This problem occurs particularly with so-called “indirect mail flows”, where emails are routed through several servers before they reach the final recipient.

  • Appending footers or disclaimers: Many companies automatically add footers or disclaimers to outgoing emails for legal or branding purposes. If this change is made after the email was originally signed, the body hash value will no longer match the actual content of the email. As a result, the DKIM signature is considered invalid because the content of the message was changed after it was signed.

  • Modification of email content by intermediaries: In addition to footers and disclaimers, security appliances or email gateways that use spam filters, virus scanners or other security mechanisms can also modify the content or headers of emails. Such modifications can affect the validation of the DKIM signature, even if they are made for legitimate reasons.

How can the risks of using DKIM be minimized?

To minimize the risks and increase the reliability of DKIM, administrators can take the following measures:

  • Flexible Signature Policies: Some email servers offer the ability to use more flexible signature policies that tolerate certain changes to emails without deeming the DKIM signature invalid.
  • Customize the email processing rules: Adjust the order of email processing so that changes such as adding footers occur before DKIM signing.
  • Education and coordination with partners: In scenarios where email is frequently forwarded between organizations, coordinating DKIM policies and practices can help minimize compatibility issues.
  • Use of DMARC: The implementation of DMARC (Domain-based Message Authentication, Reporting, and Conformance) in combination with DKIM and SPF (Sender Policy Framework) can help to strengthen email authentication and improve the handling of authentication failures.

These measures help to maintain the integrity and authenticity of emails, even in complex email delivery scenarios, and help to maximize the effectiveness of DKIM as a security measure.

Conclusion

DKIM is a powerful tool in the fight against email-based threats and for improving email deliverability. Implementation requires careful planning and configuration, but offers significant benefits in terms of security and reputation. It is important to perform regular checks and adapt the configuration to new security requirements to maintain the protection of your email communications. Administrators should also consider other email authentication standards such as SPF and DMARC to develop a comprehensive security concept.

Matthias Bonn

Senior IT Consultant

Matthias successfully guides companies over the “mountain” when migrating mail and Active Directory environments. Like a mountain guide, he ensures that projects are safely completed together on the planned route and within the scheduled time.

Matthias Bonn