Email Authentication Protocols: Advanced Security

Advanced security implementations for email authentication protocols.

Email authentication protocols are a critical component of advanced email security. They help prevent email spoofing, phishing attacks, and domain forgery by verifying the identity of the sender and ensuring the integrity of the message. In this comprehensive guide, we'll dive deep into the most widely used email authentication protocols, including SPF, DKIM, and DMARC, and provide step-by-step implementation guides, and best practices.

Understanding Email Authentication Protocols

Sender Policy Framework (SPF)

SPF is an email authentication protocol that allows domain owners to specify which mail servers are authorized to send emails on behalf of their domain. By publishing an SPF record in the domain's DNS, the receiving mail server can verify if the incoming email originated from an authorized source.

When an email is received, the receiving mail server performs an SPF check by:

  1. Taking the domain from the envelope sender (the SMTP MAIL FROM address, which becomes the Return-Path), not the visible "From" header; if that is empty, the HELO name is used
  2. Querying the domain's DNS for the SPF record
  3. Comparing the IP address of the sending mail server with the authorized IP addresses listed in the SPF record

If the IP address matches one of the authorized sources, the email passes SPF authentication. Otherwise, the email fails SPF and may be marked as spam or rejected.

Implementing SPF

To implement SPF for your domain, follow these steps:

  1. Identify all mail servers that are authorized to send emails on behalf of your domain.
  2. Create an SPF record for your domain. Example:
    v=spf1 ip4:192.0.2.0/24 ip6:2001:db8::/32 include:_spf.example.com -all
  3. Publish the SPF record in your domain's DNS as a TXT record.
  4. Test your SPF configuration using tools like the SPF Record Validator.
Best Practice: Use the "-all" directive in your SPF record to indicate a hard fail for unauthorized sources, or "~all" (soft fail) while you are still confirming every sending source. Keep the record within SPF's limit of 10 DNS lookups.

DomainKeys Identified Mail (DKIM)

DKIM is an email authentication protocol that uses cryptographic signatures to verify the authenticity and integrity of an email message. It ensures that the email content hasn't been tampered with during transit and that the sender is authorized to send emails on behalf of the domain.

The DKIM authentication process involves:

  1. The sending mail server generates a unique DKIM signature for the email using a private key.
  2. The DKIM signature is added to the email headers.
  3. The receiving mail server extracts the DKIM signature from the email headers.
  4. The receiving mail server retrieves the sender's public key from the domain's DNS.
  5. The receiving mail server verifies the DKIM signature using the public key. If the signature is valid, the email passes DKIM authentication.

Implementing DKIM

To set up DKIM for your domain:

  1. Generate a public-private key pair for your domain.
  2. Publish the public key in your domain's DNS as a TXT record. Example:
    default._domainkey.example.com IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
  3. Configure your mail server to sign outgoing emails using the private key.
  4. Test your DKIM setup by sending a message to SpamBarometer's email test, which checks DKIM, SPF and DMARC.
Common Pitfall: Ensure that your DKIM signature covers the appropriate email headers and body. Failure to include the correct headers can result in DKIM validation failures.

Domain-based Message Authentication, Reporting, and Conformance (DMARC)

DMARC is an email authentication protocol that builds upon SPF and DKIM. It allows domain owners to specify how receiving mail servers should handle emails that fail DMARC, meaning neither SPF nor DKIM passes with a domain that aligns with the "From" domain. One aligned pass is enough. DMARC also provides a mechanism for domain owners to receive reports on the email authentication status of their domain.

The following diagram illustrates the DMARC policy evaluation process:

The receiver runs SPF and DKIM, checks that a passing domain aligns with the From domain, then looks up the DMARC policy. Aligned mail is delivered; failing mail is quarantined or rejected depending on the policy.
How a receiving server applies your DMARC policy

When an email is received, the receiving mail server:

  1. Performs SPF and DKIM checks on the email.
  2. Queries the sender's domain for the DMARC policy.
  3. Checks whether SPF or DKIM passed with a domain aligned to the "From" domain; either one is enough for DMARC to pass.
  4. Takes the appropriate action (e.g., deliver, quarantine, or reject) based on the DMARC policy.
  5. Generates DMARC reports and sends them to the specified email addresses.

Implementing DMARC

To set up DMARC for your domain:

  1. Ensure that you have SPF and DKIM properly configured for your domain.
  2. Create a DMARC policy record. Example:
    _dmarc.example.com IN TXT "v=DMARC1; p=reject; rua=mailto:dmarc-reports@example.com; ruf=mailto:dmarc-forensics@example.com; fo=1"
  3. Publish the DMARC policy record in your domain's DNS as a TXT record.
  4. Monitor DMARC reports to identify and address any email authentication issues.

The example uses p=reject, but most domains should start at p=none while they review reports, then move to quarantine and reject. Note that many mailbox providers do not send forensic (ruf) reports.

DMARC Policy Options

DMARC policies allow you to specify how receiving mail servers should handle emails that fail DMARC (no aligned SPF or DKIM pass):

  • none: No action is taken on failed emails, but reports are generated.
  • quarantine: Failed emails are marked as suspicious and may be sent to the spam folder.
  • reject: Failed emails are rejected outright.

Advanced Email Authentication Techniques

Aligned DKIM Signatures

Aligned DKIM signatures ensure that the signing domain (the d= value in the DKIM signature) matches the domain in the "From" header of the email. Under relaxed alignment (the default) the organisational domain must match, so a signature from mail.example.com aligns with a From address at example.com; under strict alignment the domains must be identical. This helps prevent domain spoofing and enhances the effectiveness of DMARC.

To implement aligned DKIM signatures:

  1. Configure your mail server to use the same domain in the DKIM signature as the one used in the "From" header.
  2. Ensure that the DKIM signature covers the "From" header.
  3. Choose the alignment mode with the DMARC "adkim" tag: "r" (relaxed, the default) or "s" (strict).

Strict SPF Alignment

Strict SPF alignment requires that the domain in the "From" header exactly matches the domain that passed SPF authentication (the envelope sender, or Return-Path, domain). Relaxed alignment, the default, only requires the same organisational domain. Strict alignment narrows what can pass, but it will break legitimate mail from services that use a subdomain of yours as the Return-Path, so check your reports before switching.

To enforce strict SPF alignment:

  1. Ensure that your SPF record includes all authorized mail servers for your domain.
  2. Configure your DMARC policy to use strict SPF alignment by setting the "aspf" tag to "s". Example:
    _dmarc.example.com IN TXT "v=DMARC1; p=reject; aspf=s; rua=mailto:dmarc-reports@example.com"

Subdomain DMARC Policies

Subdomain DMARC policies allow you to specify different DMARC settings for your subdomains. This is useful when you have different email authentication requirements for various parts of your organization.

Subdomains without their own record inherit the parent domain's policy, or the policy set with the "sp" tag in the parent record. To set up separate subdomain DMARC policies:

  1. Create separate DMARC policy records for each subdomain. Example:
    _dmarc.subdomain.example.com IN TXT "v=DMARC1; p=quarantine; rua=mailto:subdomain-reports@example.com"
  2. Publish the subdomain DMARC policy records in the respective subdomain's DNS.
  3. Monitor DMARC reports for each subdomain to identify and address email authentication issues.

Best Practices for Email Authentication

  • Implement SPF, DKIM, and DMARC for your domain to establish a strong email authentication foundation.
  • Make sure SPF and DKIM align with your "From" domain. Relaxed alignment is enough for most senders; use strict alignment only where every sending service supports it.
  • Start with a "none" DMARC policy and gradually progress to "quarantine" and "reject" as you gain confidence in your email authentication setup.
  • Regularly monitor DMARC reports to identify and address any email authentication issues promptly.
  • Keep your SPF, DKIM, and DMARC records up to date as your email infrastructure evolves.
  • Educate your organization about email authentication best practices and the importance of maintaining a secure email ecosystem.

Conclusion and Next Steps

Email authentication protocols like SPF, DKIM, and DMARC are essential components of a comprehensive email security strategy. By implementing these protocols and following best practices, organizations can effectively combat email spoofing, phishing, and domain forgery.

To further enhance your email authentication setup, consider the following next steps:

  1. Conduct a thorough audit of your current email authentication implementation to identify any gaps or weaknesses.
  2. Implement aligned DKIM signatures and SPF alignment to strengthen your DMARC enforcement.
  3. Establish a regular process for monitoring DMARC reports and addressing any email authentication issues promptly.
  4. Educate your employees about email security best practices and the importance of reporting suspicious emails.
  5. Stay informed about the latest developments in email authentication standards and adapt your implementation accordingly.

By following the guidance provided in this comprehensive guide and remaining vigilant in your email authentication efforts, you can significantly enhance your organization's email security posture and protect your stakeholders from email-based threats.

The following diagram summarizes the key components and best practices of advanced email authentication:

Comparison of SPF, DKIM and DMARC: what each one checks, where its record lives and how it behaves.
SPF, DKIM and DMARC side by side

Remember, email authentication is an ongoing process that requires continuous monitoring, adjustment, and improvement. By staying proactive and adapting to the ever-evolving email security landscape, you can maintain a robust and secure email ecosystem for your organization.

Check your own email in a minute. Send one email to a test address and see your SPF, DKIM, DMARC and spam score.
Test your email
Was this guide helpful?

Topics: Deliverability, Authentication, Best Practices, Technical