DKIM was introduced at a unlucky time; or, happy 20 years of CVE-2008-0166
CVE-2008-0166
From 2006 to 2008, the Debian package (and downstream packages like Ubuntu's) of the cryptography library OpenSSL had a very bad bug where most of the entropy that was powering the random number generator was not being fed into the pool.
After the patch, the only varying input into the RNG was the PID, for which there are only 32,768 possible values. As a result, Debian OpenSSL could only generate 32,768 possible keys per architecture per key type. (This isn't solely Debian's fault - the change was seemingly, unclearly OKed by an OpenSSL maintainer in a way that people still argue about.)
Shortly after it became public, every possible key was quickly enumerated, and the space was small enough that attackers could simply try every key on suspected vulnerable systems.
DKIM
Separately, DomainKeys Identified Mail, which is a standard for cryptographically signing outgoing e-mail to prove that that mail was authorized to come from that domain, was emerging around this time.
In 2007, the first DKIM standard compatible with the modern one was introduced as an IETF Proposed Standard, and some early adopters implemented it on their mail servers. Naturally, many of these keys were generated, in 2007, on the popular server OS Debian, using the well-respected cryptography library OpenSSL.
Did I mention that DKIM doesn't require key rotation?
96 of the top million domains still use CVE-2008-0166 keys
A few weeks ago, I scraped the DKIM DNS records for the Tranco top million domains. Without even narrowing it down to domains that send e-mail, 96 of them still ship CVE-2008-0166 keys. (I e-mailed most of them to alert them of this, and that number is down from 101.)
This means that anyone can forge mail validly signed for their domain. This includes a major standards organization, the healthcare department of a government, and several relatively small-time IT companies. I'm not going to name them here, but they're really trivial to find with the process I've described.
Other bad keys
As part of this, I ran everything I scraped through badkeys, which also caught these other issues with DKIM keys (today's numbers, down ~5% from when I e-mailed most of the affected domains):
- 1 public key corresponding to a private key leaked in an unrelated incident
- 18 private keys published in DNS
- 386 keys under 768 bits
- 2,122 keys 768-1023 bits
- 124 malformed keys
Comments
No comments yet. Start the discussion.