Skip to main content
MediumEmailOWASP A02:2021CWE-326

How to fix: DKIM Public Key Uses a Weak RSA Key Size

A DKIM selector was found publishing an RSA public key below 2048 bits. Keys under 1024 bits are treated as a high-severity finding since they are within range of practical factoring attacks; keys from 1024 up to 2047 bits are deprecated but not immediately breakable.

Why it matters

A factored DKIM private key lets an attacker forge a valid DKIM signature for the domain, defeating DKIM-based spoofing protection and, depending on the DMARC alignment mode in use, potentially DMARC as well.

DKIM (RFC 6376) signatures are only as strong as the RSA key behind them. NIST deprecated RSA keys below 2048 bits for new use starting in 2013; keys below 1024 bits have been publicly factored by researchers using commodity cloud compute. This check parses the k=rsa public key published in the p= tag and measures its actual modulus size; ed25519 (k=ed25519) keys are a fixed 256 bits by design and are not evaluated by this check.

How to fix it

  1. 1Generate a new DKIM key pair at 2048 bits (or 3072 for extra margin).
  2. 2Publish the new public key under the same selector, or a new selector during rotation.
  3. 3Remove the old key from DNS once mail flow has switched to the new key.

Code examples

Generate a 2048-bit DKIM key

bash
opendkim-genkey -b 2048 -d example.com -s mail -t
# Publishes the new public key at mail._domainkey.example.com

References

Detected automatically by VulnRadar. The check id is email-dkim-weak-key, stable across every scan so you can filter or diff on it.

See every email check

Questions

How severe is DKIM Public Key Uses a Weak RSA Key Size?
VulnRadar rates this medium severity in the email category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id email-dkim-weak-key, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does DKIM Public Key Uses a Weak RSA Key Size map to?
It maps to CWE-326. In the OWASP Top 10 it falls under A02:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for dkim public key uses a weak rsa key size

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

DKIM Public Key Uses a Weak RSA Key Size fix | VulnRadar