DKIM Replay Attacks: Anatomy, Workflow, and Real-World Case Studies
- Akshay Jain
- May 5
- 3 min read
“Even the strongest locks can be picked if you have the original key.” - Unknown
Email authentication protocols like DKIM (DomainKeys Identified Mail) are designed to guarantee a message's integrity and origin. Yet, attackers have devised a workaround: the DKIM replay attack. By capturing and resending a legitimately signed email, they can trick mail servers and users into trusting malicious or out-of-context messages. This blog explores the technical mechanics of DKIM replay, walks through a detailed attack workflow, reviews real-world incidents, and lays out robust defenses.
Understanding DKIM Foundations
DKIM cryptographically signs select portions of an email (headers and body) using the sender's private key. Recipients retrieve the matching public key from DNS to verify:
Signature Header
Canonicalized Headers (From, Subject, Date, etc.)
Canonicalized Body Hash
If the hash matches, the message is deemed untampered and genuinely from the stated domain.
Key DKIM Concepts
Canonicalization (c=): Defines how whitespace, header order, and line breaks are normalized.
Header Fields Signed (h=): Which headers are included in the signature.
Body Length Limit (l=): Optional parameter limiting the body bytes covered.
Selector (s=): Chooses the DNS record containing the public key.
What Makes DKIM Replay Attacks Possible?
At its core, DKIM replay abuses two properties:
Signature Validity Window: A DKIM signature remains valid until the email's DKIM key is rotated or expires.
Lax Header Coverage: If critical headers (like To: or Date:) aren't signed, an attacker can modify them without invalidating the signature.
By capturing a signed email and resending it (unaltered or with permissible header tweaks), the attacker bypasses DKIM checks, making the message appear legitimate.

Detailed Attack Workflow
Below is a step-by-step technical breakdown:
Capture a Signed Email
Man-in-the-Middle (Optional): On insecure networks, the attacker intercepts someone's incoming mail.
At this stage, the attacker has a fully signed email
Analyze the DKIM Signature
Extract the h= header list to see which fields are protected.
Check for l= (body length) and c= (canonicalization) settings.
Tools like dkimverify.py or MTA logs can display signed headers and hashing details.
Modify Unsigned Headers (Optional)
If To: or Date: aren't in h=, attacker can change the recipient or timestamp. Since this header wasn't signed, the DKIM check still passes.
Replay the Email
The attacker uses any SMTP client or automation.
Because the DKIM signature is intact and valid, many MTAs and spam filters accept the message without further scrutiny.
Payload Execution
Phish Credentials: Embed a malicious link or attachment.
Spread Disinformation: Resend old confidential correspondence.
Bypass Spam Filters: Exploit the trust in authenticated senders.
Real-World Case Study: ProtonMail's Reputation Hit
In April 2021, ProtonMail suffered a DKIM replay incident:
Initial Discovery: Attackers subscribed a disposable address and received a legitimate newsletter signed by ProtonMail.
Replay Campaign: They replayed the email to thousands of Gmail and Yahoo accounts, flooding inboxes with benign but unsolicited content.
Impact: ProtonMail's domain reputation dipped, causing some legitimate emails to land in spam.
ProtonMail's response included:
Key Rotation: Immediate generation of new DKIM keys.
Oversigning: Adding To: and Date: to the signed header list.
TTL Reduction: Lowering DNS TTL for faster public key updates.
Mitigation and Best Practices
Oversign Critical Headers
Add To, Date, Message-ID, and Subject to your DKIM signature. This prevents attackers from altering recipients or timestamps without invalidating the signature.
Use body length limits
Set an l= tag to cover only the first N bytes of the body. Even if the attacker appends content, the signature covers enough of the original body to detect changes
Key Rotation and Short TTL
Rotate DKIM keys every 30–90 days.
Set DNS TTL to a low value (e.g., 300 seconds) for swift revocation.
DMARC Enforcement
Publish a strict DMARC policy to instruct receivers how to handle DKIM failures. A reject policy ensures replayed or modified emails are discarded.
Replay Detection
Tracking identical Message-ID and signature combos.
Alerting on unusually high volumes of the same signed email.
Rate-limiting inbound messages from the same sender/domain.
DKIM replay attacks exploit the very mechanism designed to secure email. By understanding the technical underpinnings such as canonicalization, header coverage, and signature validation, organizations can fortify their email pipelines. Oversigning, key rotation, and strict DMARC policies convert DKIM from a potential liability into a robust defense.
“Security is not a product but a process.” – Bruce Schneier
Stay proactive: review your DKIM setup today, tighten oversigning, and monitor for anomalous replays. Your domain's reputation, and your users trust, depend on it.
Note: Feel free to drop your thoughts in the comments below - whether it's feedback, a topic you'd love to see covered, or just to say hi! Don't forget to join the forum for more engaging discussions and stay updated with the latest blog posts. Let's keep the conversation going and make cybersecurity a community effort!
-AJ
Comentários