What is a DKIM Replay Attack?

How to strengthen your email authentication and protect against domain abuse

Malicious actors are always exploring new ways to access email inboxes. Over the past few years, cyber criminals have been using a method known as a ‘DKIM Replay Attack’, in which high reputation mailboxes are used to generate a legitimate message signature, which can then be amplified (or replayed) multiple times to send spam messages. Recipients using Gmail are particularly at risk to this type of attack since they give a lot of weight to domain reputation.

What is a DKIM replay attack?

To understand DKIM replay attacks, we first need to understand what DKIM does. DKIM, or “DomainKeys Identified Mail” (defined in RFC 6376), is a mechanism to sign and authenticate an email with public/private key pairs by signing one or more headers in an email. 

However, the flexibility of the technology allows a DKIM signature domain to be different to the domain in the from header. If the DKIM signature is verified, this only confirms that the message went through the signing domain’s mail servers and has not been modified since, despite the message not originating from where it claims to. 

If an attacker can create or otherwise gain access to a mailbox using a domain with a high reputation, that attacker only needs to send a single email from that high reputation domain to another mailbox they control. This message can then be used to re-broadcast a message to recipients not originally intended by the original author.

How can you strengthen your signing to prevent being a victim?

There are multiple ways to leverage mechanisms within the DKIM specification to make sure you are not vulnerable to DKIM replay attacks. It’s worth noting that most, if not all, of these methods will depend on your email provider’s DKIM signing settings, if you do not host your own. You are encouraged to ask your ESP (Email Service Provider) whether they perform any of the strategies within this blog post.

The first mitigation strategy, and possibly the easiest for ESPs to implement, is to oversign headers. This is particularly important for headers that, if modified, would cause the message to fail DKIM authentication.

Consider the key snippet below, in which you can see that only three headers are included in the signature: message-id, date and from

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=20210112;
h=message-id:date:from; bh=1Gi...6+FidE=; b=Qpozy...4qMw==

This means the attacker just needs to keep those fields the same to keep the DKIM signature intact, and they can change all the other headers (including the subject!).

Let’s take the following signature from Google, where you can see that they sign nearly every header:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=redsift.io; s=google; t=1692646848; x=1693251648; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject:date:message-id:reply-to;bh=nfCPN8ZH96qE7/cjuGo1YMrjN7ITuZjKcbvBaUe8zp4=;

By oversigning headers, you make it much harder to add or change headers, making this attack less attractive to malicious actors.

Another mitigation strategy is to use key timestamps and expiration dates. There are two tags in the DKIM specification; one indicating the time that a signature was added, and the other indicating the expiration for that signature. 

Take the example below:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=20210112; t=1665514330; x=1665812312;
  • The tag t= represents the signature’s creation time as a Unix epoch timestamp
  • The tag x= represents the signature’s expiration time as a Unix epoch timestamp

You could also use reputation-based indicators and use different selectors for different kinds of accounts. For example, high-risk accounts have DKIM signatures that expire 10 minutes after signing, while low-risk accounts have DKIM signatures that expire in 24 hours. 

On a similar note, rotating your keys will also help mitigate DKIM replay attacks, for which you can find out more information in this blog post.

Lastly, you can use selectors as feedback mechanisms. To achieve this, you’ll need to tag high risk or trial accounts with a different DKIM selector and track excessive usage of the selector via DMARC reports. DMARC reporting software such as OnDMARC can support you if you decide to use this method.

What are the consequences of DKIM replay attacks?

If a cyber criminal successfully replays a message and replaces the content with spam or other malicious content, spam filters would start picking up the signals and would catch up with the influx of replayed spam messages. If it’s a large or sustained enough campaign, the reputation of the signing domain will be negatively impacted, and legitimate, clean messages will be sent to spam (or even possibly outright blocked).

If you’re still skeptical about DKIM practices and management, then head out to our investigate tool to know about errors and ways to fix them.

check email dmarc setup

PUBLISHED BY

Faisal Misle

1 Sep. 2023

SHARE ARTICLE:

Categories

Recent Posts

VIEW ALL
News

Introducing DNS Guardian: Stop impersonation and spam caused by domain takeovers 

Rahul Powar

tl;dr: We’re thrilled to announce DNS Guardian — a new feature in Red Sift OnDMARC that can swiftly identify and stop domain takeovers that lead to malicious mail. Back in February, we shared updates with the community about SubdoMailing – an attack discovered by Guardio Labs. The attack was a form of subdomain takeover,…

Read more
Email

“What’s Next for DMARC”: Red Sift & Inbox Monster Webinar Recap

Red Sift

The recent webinar hosted by Inbox Monster, “What’s Next for DMARC: Data & Predictions for a New Era in Email Authentication,” featured insights from Red Sift and examined the significant changes brought by Yahoo and Google’s bulk sender requirements earlier this year.  It also offered a forward-looking perspective on the future of email authentication.…

Read more
Security

Navigating the Information Security Landscape: ISO 27001 vs. SOC 2

Red Sift

As cyber threats evolve, so do the standards and frameworks designed to combat them. Two of the most recognized standards in information security are ISO 27001 and SOC 2. What sets them apart, and which one is right for your organization? Let’s delve into the key differences. Purpose and Scope: Global Framework vs. Client-Centric…

Read more
News

G2 Summer 2024 Report: Red Sift OnDMARC’s Winning Streak Continues

Francesca Rünger-Field

We’re delighted to announce that Red Sift OnDMARC has again been named a Leader in G2’s DMARC category for Summer 2024. This recognition is based on our high Customer Satisfaction scores and strong market presence. Red Sift appeared in 11 reports – 5 new ones since Spring 2024! – earning 5 badges: A few…

Read more
News

Google will no longer trust Entrust certificates from October 2024

Red Sift

Tl;dr: Google has announced that as of October 31, 2024, Chrome will no longer trust certificates signed by Entrust root certificates. While there is no immediate impact on existing certificates or those issued before 31st October 2024, organizations should start reviewing their estate now. On Thursday 27th June 2024, Google announced that it had…

Read more