Insufficient DKIM record with RSA 512-bit key used on WordPress.com
A DKIM DNS record for WordPress.com used a 512-bit RSA public key, which is weak enough to be factored with modest cloud computing resources. An attacker who recovered the matching private key could sign forged emails that appear to come from the wordpress.com domain, aiding phishing.
Originally disclosed on HackerOne
- Fixed in 18 hours
- Paid in 18 hours
- Disclosed after 31 days
What is DomainKeys Identified Mail (DKIM) ?
DKIM allows the receiver to check that an email claimed to have come from a specific domain was indeed authorized by the owner of that domain. It achieves this by affixing a digital signature, linked to a domain name, to each outgoing email message. The recipient system can verify this by looking up the sender's public key published in the DNS.
Length of the Key
With rapidly increasing processing power of computers, RSA keys with a 512-bit length, previously considered to be secure, can be cracked in a short period of time. Today, a minimum of 1024 bit RSA should be used. Organizations like the American National Institute of Standards and Technology (NIST) go further, and recommend aminimum of 2048 bits.
Short key vulnerability
According to RFC 6376 the receiving party must be able to validate signatures with keys ranging from 512 bits to 2048 bits, thus usage of keys shorter than 512 bits might be incompatible and shall be avoided. The RFC 6376 also states that signers must use keys of at least 1024 bits for long-lived keys, though long-livingness is not specified there.
CWE-326: Inadequate Encryption Strength
I was scanning WordPress.com DNS DKIM records using own wordlist of DKIM selectors. I was able to find one selector "my1" which is using RSA 512 bits key.
vavkamil@desktop:~$ dig txt my1._domainkey.wordpress.com +short
"p=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMXyekdYBZjcTskG1hwEji+J17DI9hPif0RsNF3aDPorKUnOLRN/bxCZ82BRpwXhgmbJ91KNe1fQMdZRs3iOdFcCAwEAAQ=="
More details:
# fqdn: my1._domainkey.wordpress.com
# txt: p=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMXyekdYBZjcTskG1hwEji+J17DI9hPif0RsNF3aDPorKUnOLRN/bxCZ82BRpwXhgmbJ91KNe1fQMdZRs3iOdFcCAwEAAQ==
# key: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMXyekdYBZjcTskG1hwEji+J17DI9hPif0RsNF3aDPorKUnOLRN/bxCZ82BRpwXhgmbJ91KNe1fQMdZRs3iOdFcCAwEAAQ==
# size: 512 bits
# n: 10367334950201306539131289202809840614738220453757190856643449770342237105356400464470413674101052983691492083310061606610679073552649560621665862279918679
# e: 65537
# fp: 1651db71c5ae43c40473dcea2af993ba50c6291c 512 wordpress.com my1 PROD
-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMXyekdYBZjcTskG1hwEji+J17DI9hPi
f0RsNF3aDPorKUnOLRN/bxCZ82BRpwXhgmbJ91KNe1fQMdZRs3iOdFcCAwEAAQ==
-----END PUBLIC KEY-----
Exploitation
A 512-bit RSA key is insecure, as was proved in 1998. Nowadays a 512-bit integers can be factored in only a few hours, for less than $100 of compute time in a public cloud environment: https://github.com/eniac/faas An attacker therefore might be able to obtain private key for said DKIM record and sign any emails for the associated domain (WordPress.com). This can be used to spoof e-mails for example in targeted attacks (phishing/spear-phishing, ...).
Historical reports
I wasn't able to find any related bug bounty reports, but the same problem was reported to Google back in 2012: https://www.wired.com/2012/10/dkim-vulnerability-widespread
Impact
Attacker can obtain 512-bit RSA private key from DKIM record with selector "my1" (my1._domainkey.wordpress.com) and use it to sign spoofed e-mails sent from @wordpress.com. This can lead to more sufficient phishing campaigns against Automattic customers.
Context
DKIM (DomainKeys Identified Mail) lets a receiving mail system check that a message claiming to come from a given domain was actually authorised by that domain's owner. The sender attaches a digital signature, tied to a domain name, to each outgoing message, and the recipient verifies it by looking up the sender's public key, which is published in DNS.
The target here is the DNS zone of WordPress.com, specifically its DKIM selector records. A DKIM public key is published as a TXT record under a selector name of the form <selector>._domainkey.<domain>, and the key material sits in the p= tag of that record. The strength of the key in that record determines how hard it is to recover the matching private key, and therefore how hard it is to forge signatures for the domain.
Setup
The researcher scanned WordPress.com's DKIM records using their own wordlist of DKIM selectors.
Finding it
The reasoning behind the scan is about key length. With the rapidly increasing processing power of computers, RSA keys with a 512-bit length, previously considered secure, can be cracked in a short period of time. A minimum of 1024-bit RSA should be used today, and organisations such as the American National Institute of Standards and Technology (NIST) go further and recommend a minimum of 2048 bits.
RFC 6376 is relevant in two ways. The receiving party must be able to validate signatures with keys ranging from 512 bits to 2048 bits, so keys shorter than 512 bits might be incompatible and should be avoided. The RFC also states that signers must use keys of at least 1024 bits for long-lived keys, though it does not specify what counts as long-lived.
The weakness class is CWE-326: Inadequate Encryption Strength.
Exploitation
Step 1: Enumerate DKIM selectors
The researcher scanned WordPress.com's DNS DKIM records with a personal wordlist of DKIM selectors. This is a brute-force enumeration of selector names, each lookup asking the zone whether a record exists at <selector>._domainkey.wordpress.com.
Step 2: Find a weak selector
The scan found one selector, my1, whose record uses an RSA 512-bit key. The lookup and its result:
vavkamil@desktop:~$ dig txt my1._domainkey.wordpress.com +short
"p=[redacted]+J17DI9hPif0RsNF3aDPorKUnOLRN/[redacted]=="
The dig txt query asks for the TXT record at the selector name, and +short prints only the record data. The returned string is the DKIM key record: the p= tag carries the base64-encoded SubjectPublicKeyInfo of the public key.
Step 3: Inspect the key
The researcher expanded the record into its components:
# fqdn: my1._domainkey.wordpress.com
# txt: p=[redacted]+J17DI9hPif0RsNF3aDPorKUnOLRN/[redacted]==
# key: [redacted]+J17DI9hPif0RsNF3aDPorKUnOLRN/[redacted]==
# size: 512 bits
# n: 10367334950201306539131289202809840614738220453757190856643449770342237105356400464470413674101052983691492083310061606610679073552649560621665862279918679
# e: 65537
# fp: [redacted] 512 wordpress.com my1 PROD
-----BEGIN PUBLIC KEY-----
[redacted]+J17DI9hPif0RsNF3aDPorKUnOLRN/[redacted]==
-----END PUBLIC KEY-----
The decoded key is 512 bits, with modulus n and public exponent e of 65537. The fingerprint line shows the key's fingerprint alongside wordpress.com, selector my1 and PROD. The PEM block is the same key material in standard PUBLIC KEY form.
Step 4: Recover the private key and sign mail
A 512-bit RSA key is insecure, as was proved in 1998. The researcher notes that 512-bit integers can now be factored in only a few hours, for less than $100 of compute time in a public cloud environment, citing https://github.com/eniac/faas. An attacker might therefore be able to obtain the private key for this DKIM record and sign any emails for the associated domain (WordPress.com). That can be used to spoof emails, for example in targeted attacks such as phishing or spear-phishing.
The researcher was not able to find any related bug bounty reports, but the same problem was reported to Google back in 2012: https://www.wired.com/2012/10/dkim-vulnerability-widespread.
Root cause
The zone published a DKIM public key of only 512 bits under the selector my1. Because the modulus is that small, factoring it to recover the private key is feasible with modest resources, which defeats the purpose of the signature: anyone who holds the private key can produce valid signatures for the domain. The record itself is public by design, so nothing else protected the key beyond its length. The report does not describe how the key came to be generated at that size.
Impact
An attacker can obtain the 512-bit RSA private key from the DKIM record with selector my1 (my1._domainkey.wordpress.com) and use it to sign spoofed emails sent from @wordpress.com. This can lead to more effective phishing campaigns against Automattic customers. The report uses hedged wording ("might be able to obtain", "can lead to").
Fix
Variants to test
- Enumerate selectors on other domains with a wordlist of common DKIM selector names and look for any record whose
p=value decodes to a key shorter than 1024 bits. A positive result is a TXT record at<selector>._domainkey.<domain>whose decoded key reports a size of 512 bits or less. - Check for selectors that are guessable or left over from old configurations, since a stale selector with a weak key is just as usable for signing.
- Decode each discovered key and record its modulus size, exponent and fingerprint, so weak keys can be tracked across environments. A positive result is a key whose size falls below 1024 bits.
What happened, in plain words
Email has a trust problem. When a message arrives saying it is from [redacted], the receiving mail server has no built-in way to know whether it really came from WordPress.com or from anyone else who typed that address into their mail client. A system called DKIM was invented to help with this. The owner of a domain puts a digital signature on every outgoing message, and publishes a public key in the domain name system (DNS) so that receivers can check the signature. If the signature checks out, the message really was signed by someone holding the matching private key, which in theory only the domain owner has.
That whole guarantee rests on one thing: the private key must be impossible to work out from the public key. The public key is, by design, public. Anyone can look it up. The only protection is mathematics: recovering the private key from the public key is meant to be so hard that nobody will bother.
In this report, the researcher looked at the public DKIM records of WordPress.com and found one record, under the name my1, that published a very small key: 512 bits. Keys that small are no longer safe. The researcher explains that such a key can be broken in a few hours for under $100 of cloud computing time. If someone breaks it, they get the private key, and with the private key they can sign any email they like as if it came from @wordpress.com. That is the whole finding: a public record that should have protected the domain was too weak to do so.
This is a beginner's walkthrough of that report. It covers what DKIM is, why key length matters, how the researcher found the weak record, what the record contained, and what an attacker could do with it.
Background: what DKIM is and why key length matters
DKIM in one paragraph
DKIM stands for DomainKeys Identified Mail. It lets the receiver of an email check that a message claiming to come from a specific domain was indeed authorised by the owner of that domain. It does this by attaching a digital signature, linked to a domain name, to each outgoing email. The recipient system verifies the signature by looking up the sender's public key, which is published in DNS.
A useful comparison is a wax seal on a letter. The seal proves the letter was closed by whoever holds the stamp, and the recipient can compare the seal against a known example of the stamp. In DKIM, the "stamp" is the private key, kept secret by the domain owner, and the "known example" is the public key, published in DNS for anyone to look up. If the seal matches, the letter really came from the stamp holder.
Why the length of the key matters
A key's length is measured in bits. Longer keys take vastly more computing effort to break. With the rapidly increasing processing power of computers, RSA keys with a 512-bit length, previously considered secure, can be cracked in a short period of time. Today, a minimum of 1024-bit RSA should be used. Organisations such as the American National Institute of Standards and Technology (NIST) go further and recommend a minimum of 2048 bits.
Think of it like a combination lock. A two-digit lock can be tried by hand in minutes. A ten-digit lock cannot. The maths of RSA works the same way: the public key contains a large number, and breaking the key means finding its two prime factors. Small numbers are easy to factor; large ones are not.
What the standards say
RFC 6376 is the document that defines how DKIM works. It matters here in two ways. First, the receiving party must be able to validate signatures with keys ranging from 512 bits to 2048 bits, so keys shorter than 512 bits might be incompatible and should be avoided. Second, the RFC states that signers must use keys of at least 1024 bits for long-lived keys, though it does not specify what counts as long-lived.
The weakness class
The report labels the issue CWE-326: Inadequate Encryption Strength. CWE is a catalogue of common software weakness types, and CWE-326 simply means that a system used a cryptographic key that is too small to be safe. It is not a bug in the code that runs the site; it is a configuration choice that leaves a door less locked than it should be.
How the researcher found it
The setup
The researcher scanned WordPress.com's DKIM records using their own wordlist of DKIM selectors.
Two ideas need unpacking here.
A selector is just a label that lets one domain publish several DKIM keys. The public key for a selector lives in a DNS record whose name has the form <selector>._domainkey.<domain>. So if a domain uses the selector mail, the record is at mail._domainkey.example.com. Domains often use several selectors, for different mail systems or different time periods, and the names are frequently guessable words like default, google, s1 or my1.
A wordlist is a plain text file with one candidate name per line. The researcher took a list of common selector names and asked DNS, one name at a time, whether a record existed. This is a brute-force enumeration: trying many guesses cheaply and keeping whatever answers.
Step 1: Enumerate DKIM selectors
The researcher scanned WordPress.com's DNS DKIM records with a personal wordlist of DKIM selectors. Each lookup asks the zone whether a record exists at <selector>._domainkey.wordpress.com. This step is the equivalent of walking along a street trying every door handle: nothing is broken, the doors are simply public, and the goal is to find one that is not properly locked.
Step 2: Find a weak selector
The scan found one selector, my1, whose record uses an RSA 512-bit key. The lookup and its result:
vavkamil@desktop:~$ dig txt my1._domainkey.wordpress.com +short
"p=[redacted]+J17DI9hPif0RsNF3aDPorKUnOLRN/[redacted]=="
Line by line:
vavkamil@desktop:~$is the shell prompt. It shows the user name, the machine name and the current directory. Everything after it is the command that was typed.digis a standard command-line tool for asking DNS questions. It is the same kind of lookup your browser does behind the scenes when it resolves a website name, but here it is aimed at a specific record type.txttellsdigto ask for a TXT record. TXT records are free-form text records in DNS, and DKIM stores its public key in one.my1._domainkey.wordpress.comis the full record name being queried: the selectormy1, then_domainkey, then the domain.+shorttellsdigto print only the answer data, without the usual headers and timing information.- The quoted string on the next line is the answer. It is the DKIM key record. The
p=tag carries the base64-encoded SubjectPublicKeyInfo of the public key. Base64 is just a way of writing binary data as plain letters and digits so it can travel safely in a text record.
Step 3: Inspect the key
The researcher expanded the record into its components:
# fqdn: my1._domainkey.wordpress.com
# txt: p=[redacted]+J17DI9hPif0RsNF3aDPorKUnOLRN/[redacted]==
# key: [redacted]+J17DI9hPif0RsNF3aDPorKUnOLRN/[redacted]==
# size: 512 bits
# n: 10367334950201306539131289202809840614738220453757190856643449770342237105356400464470413674101052983691492083310061606610679073552649560621665862279918679
# e: 65537
# fp: [redacted] 512 wordpress.com my1 PROD
-----BEGIN PUBLIC KEY-----
[redacted]+J17DI9hPif0RsNF3aDPorKUnOLRN/[redacted]==
-----END PUBLIC KEY-----
Line by line:
# fqdn:is the fully qualified domain name of the record, the complete address that was looked up.# txt:repeats the raw text of the record, including thep=tag.# key:repeats the key material on its own, without thep=prefix.# size: 512 bitsis the important line. It says the key is only 512 bits long, which is the weakness.# n:is the modulus, the large number that the security of an RSA key depends on. Breaking the key means factoring this number into its two prime factors. At 512 bits, that number is short enough to factor with modern hardware.# e: 65537is the public exponent, a standard small number used in almost every RSA key. It is not secret and not a problem.# fp:is a fingerprint, a short hash that identifies this particular key. The line also showswordpress.com, selectormy1andPROD.- The
-----BEGIN PUBLIC KEY-----and-----END PUBLIC KEY-----lines wrap the same key material in PEM format, a standard text format for keys. Anything between them is the key, written in base64.
Step 4: Recover the private key and sign mail
A 512-bit RSA key is insecure, as was proved in 1998. The researcher notes that 512-bit integers can now be factored in only a few hours, for less than $100 of compute time in a public cloud environment, citing https://github.com/eniac/faas. An attacker might therefore be able to obtain the private key for this DKIM record and sign any emails for the associated domain (WordPress.com). That can be used to spoof emails, for example in targeted attacks such as phishing or spear-phishing.
In plain terms: the public key is a locked padlock, and the private key is the only key that opens it. Factoring the modulus is the act of making a copy of that key. Once the copy exists, the attacker might be able to sign spoofed emails as if they came from WordPress.com. Phishing is the practice of sending a fraudulent message that pretends to come from a trusted sender to trick the recipient into handing over information or clicking a malicious link. Spear-phishing is the same thing aimed at a specific person or organisation. A valid DKIM signature makes such a message much more convincing, because automated checks will pass.
The researcher was not able to find any related bug bounty reports, but the same problem was reported to Google back in 2012: https://www.wired.com/2012/10/dkim-vulnerability-widespread.
Why it worked
The zone published a DKIM public key of only 512 bits under the selector my1. Because the modulus is that small, factoring it to recover the private key is feasible with modest resources, which defeats the purpose of the signature: anyone who holds the private key can produce valid signatures for the domain. The record itself is public by design, so nothing else protected the key beyond its length. The report does not describe how the key came to be generated at that size.
A comparison: publishing a public key is like leaving a photocopy of your house key on the doorstep, safe only because you trust that nobody can machine a working copy from the photo. With a 512-bit key, the photo is sharp enough that a copy is practical.
What an attacker could do
An attacker can obtain the 512-bit RSA private key from the DKIM record with selector my1 (my1._domainkey.wordpress.com) and use it to sign spoofed emails sent from @wordpress.com. This can lead to more effective phishing campaigns against Automattic customers. The report uses hedged wording ("might be able to obtain", "can lead to").
What the fix would be
Rotating a selector means generating a new key pair, publishing the new public key under a new selector name, switching outgoing mail to sign with it, and retiring the old record.
Other places to look for the same problem
- Enumerate selectors on other domains with a wordlist of common DKIM selector names and look for any record whose
p=value decodes to a key shorter than 1024 bits. A positive result is a TXT record at<selector>._domainkey.<domain>whose decoded key reports a size of 512 bits or less. - Check for selectors that are guessable or left over from old configurations, since a stale selector with a weak key is just as usable for signing.
- Decode each discovered key and record its modulus size, exponent and fingerprint, so weak keys can be tracked across environments. A positive result is a key whose size falls below 1024 bits.
Glossary
- DKIM (DomainKeys Identified Mail): an email authentication system that attaches a digital signature to outgoing messages so receivers can check the message really came from the claimed domain.
- DNS (Domain Name System): the internet's public directory that maps names like
wordpress.comto records, including the TXT records that hold DKIM public keys. - TXT record: a DNS record type that holds free-form text; DKIM stores its public key in one.
- Selector: a label that lets one domain publish several DKIM keys, used in record names of the form
<selector>._domainkey.<domain>. _domainkey: the fixed part of a DKIM record name that marks it as a DKIM key record.- Public key: the half of a key pair that is published openly and used to verify signatures.
- Private key: the secret half of a key pair, used to create signatures; anyone holding it can sign as the domain.
- Digital signature: a cryptographic value attached to a message that proves it was signed by the holder of a particular private key.
- RSA: a widely used public-key cryptosystem whose security depends on how hard it is to factor a large number.
- Key length (bits): the size of the key, measured in bits; longer keys are exponentially harder to break.
- Modulus (
n): the large number in an RSA public key whose prime factors, if found, reveal the private key. - Public exponent (
e): a small standard number used alongside the modulus in RSA; not secret. - Factoring: finding the prime numbers that multiply together to give a number; for RSA, factoring the modulus breaks the key.
- Base64: a way of encoding binary data as plain text characters so it can be stored in text records.
- SubjectPublicKeyInfo: the standard binary structure that holds a public key, which is what the
p=tag encodes. - PEM: a text format for keys, marked by
-----BEGIN ...-----and-----END ...-----lines. - Fingerprint: a short hash that identifies a specific key.
- FQDN (fully qualified domain name): the complete name of a DNS record.
dig: a command-line tool for querying DNS records.- Wordlist: a plain text file of candidate names, used to guess record names one by one.
- Enumeration: systematically trying many candidate names to discover which ones exist.
- RFC 6376: the standards document that defines DKIM, including minimum key lengths.
- NIST: the American National Institute of Standards and Technology, which publishes cryptographic recommendations.
- CWE-326: a catalogue entry meaning "Inadequate Encryption Strength", used when a key is too small to be safe.
- Phishing: sending a fraudulent message that pretends to come from a trusted sender to trick the recipient.
- Spear-phishing: phishing aimed at a specific person or organisation.
- Spoofing: sending a message that pretends to come from an address or domain the sender does not control.
- Selector rotation: replacing a DKIM key pair with a new one under a new selector name and retiring the old record.
- PROD: production, the live environment used by real users.