Join our Newsletter — 33% off our NHI Course

How does DKIM signature work?

A DKIM signature is a cryptographic header added to email that lets the receiver verify the message was signed by an authorised domain and was not altered in transit. Defenders check whether signatures validate and match the sending domain. Attackers exploit weak key handling or unsigned mail to impersonate trusted senders.

How DKIM signs a message in practice

DKIM works by adding a cryptographic signature to selected email headers before the message leaves the sender’s mail system. The signature is created with a private key controlled by the sending domain, while receivers use the matching public key published in DNS to verify that the message came through an authorised signer and that the protected headers were not changed in transit.

The important practical detail is that DKIM does not sign the whole email blindly. It signs a defined set of headers and a hash of the message body, so the receiver checks both authenticity and integrity against the version that was actually transmitted. If the headers or body fragment covered by the signature change, validation can fail.

Because DKIM is tied to domain-controlled keys and DNS publication, the operational quality of the signature depends on how carefully selectors, key rotation and signing scope are managed. A valid signature is evidence that a domain key signed the mail, but it is not by itself proof that the message is safe, wanted, or free of fraud.

What receivers actually verify when they see DKIM

On receipt, the mail server looks for the DKIM-Signature header, extracts the selector and signing domain, then retrieves the corresponding public key from DNS. It recomputes the hash over the signed components and compares that result with the value in the signature. If the values match, the receiver can confirm the message was signed by the holder of the matching private key and was not altered in the covered parts.

This verification step matters because the signature is only as trustworthy as the alignment between the signed domain and the visible sender identity. In practice, defenders inspect whether the signature validates and whether it aligns with the domain the recipient expects to see. That is why DKIM is usually evaluated alongside SPF and DMARC rather than in isolation, as shown in DMARC, SPF and DKIM Guide.

Mail systems also need to handle real-world complications such as forwarding, mailing lists, and body or header rewriting. Those changes can break a valid signature even when the original sender was legitimate, so validation is a useful signal, not a complete trust decision.

Why DKIM is useful for anti-spoofing and where it fails

DKIM helps prevent simple domain impersonation because an attacker who cannot access the private key cannot create a valid signature for that domain. That makes it harder to forge mail that appears to come from a trusted organisation, especially when the recipient’s controls use DKIM as one input to policy enforcement.

The weak points are usually operational rather than mathematical. Poor key handling, reused keys, long-lived selectors, unsigned traffic, or inconsistent signing across mail paths all reduce assurance. Attackers tend to exploit those gaps by sending unsigned messages, abusing misconfigured infrastructure, or reusing compromised credentials and mail systems to produce mail that looks legitimate.

Real attacker behaviour often shows that DKIM is strongest when it is part of a complete sender-authentication posture. In one campaign, stolen cloud keys were used to validate access and support email abuse, which is why email authentication has to be treated as part of a broader access-control problem, not just a mail formatting issue. The same operational lesson is covered in TruffleNet stolen AWS keys campaign 2025.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5, NIST SP 800-57 and CIS Controls v8 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
NIST SP 800-53 Rev 5 IA-5 — Authenticator Management DKIM relies on key lifecycle and controlled credential handling.
IA-9 — Service Identification and Authentication DKIM authenticates a mail-sending service/domain to the receiver.
Recommendation — Manage DKIM keys with rotation, revocation, and protection controls. Authenticate mail services with controlled signing keys and validation.
NIST SP 800-57 Key Management DKIM depends on private-key protection, rotation, and retirement.
Recommendation — Set cryptoperiods and rotate DKIM keys before exposure grows.
CIS Controls v8 CIS-5 — Account Management Sender and signing access need controlled ownership and review.
Recommendation — Review and remove signing access when mail systems or owners change.
OWASP Non-Human Identity Top 10 NHI-07 — Long-Lived Secrets DKIM private keys are long-lived signing material if not rotated.
Recommendation — Rotate DKIM signing keys and eliminate unnecessarily long-lived secrets.

Practitioner Guidance

What to verify: Check that the signing domain, selector, and DNS-published public key all match the sender path you expect. A DKIM pass is only meaningful if the mail is actually signed by the domain you intend to trust, and if the message has not been rewritten in a way that invalidates the result.

Common mistake: Treating DKIM as a standalone anti-phishing control. In practice, you need to pair it with domain alignment and policy enforcement, otherwise an attacker can still exploit unsigned mail, weak sender infrastructure, or lookalike domains.

What practitioners underestimate: Key lifecycle discipline is the difference between a useful trust signal and a brittle one. If selectors and keys are not rotated, monitored, and retired cleanly, a compromised or stale signing path can quietly preserve trust for far longer than it should.

Practitioner takeaway: Use DKIM as an integrity and domain-authentication signal, then judge it in the context of alignment, policy, and key hygiene rather than as proof that a message is inherently trustworthy.