Vulnerability13 May 2008

Debian OpenSSL Predictable Keys

Silencing a debugging-tool warning removed OpenSSL's randomness on Debian. For two years every key came from a pool of just 32,768.

Severity
Front-page news
Difficulty
intermediate
Companies
Debian, Ubuntu, OpenSSL
Tech
OpenSSL, Cryptography, Random number generation, SSH
Root cause
latent bug, insecure defaults

The story

Quick (1 min)

On 13 May 2008, Debian announced that encryption keys made on its systems for almost two years could be guessed.

Back in 2006, a Debian maintainer changed OpenSSL, the library that creates encryption keys, to stop a debugging tool called Valgrind from printing warnings. The change accidentally removed most of the randomness OpenSSL relied on. Afterwards, the only real variation left was the process ID, a small number, so only 32,768 different keys could ever be produced.

Anyone could generate all of those keys in advance and try them. SSH logins, VPN keys and website certificate keys made on Debian, Ubuntu and other Debian-based systems were all at risk, and had to be thrown away and regenerated worldwide.

The lesson: be extremely careful "fixing" warnings in security code. Randomness is easy to break and hard to notice.

Keep reading to the end to earn XP.Read. XP earned.

Engineer (2 min)

What changed. In 2006, a Debian developer patched Debian's OpenSSL package in response to warnings about accessing uninitialised memory, reported by tools like Valgrind. The patch "inadvertently broke its random number generator." Per Wikipedia, it "reduced the total entropy to the process id."

Why that's catastrophic. A cryptographic key is only as strong as the randomness used to make it. With the process ID as the only remaining variable, the generator could produce only 32,768 distinct outputs for a given key type and size. An attacker can precompute every possible key and simply try them all, so brute force becomes trivial. NVD's description: OpenSSL "uses a random number generator that generates predictable numbers, which makes it easier for remote attackers to conduct brute force guessing attacks against cryptographic keys."

Scope:

  • Versions: OpenSSL 0.9.8c-1 (released in Debian on 17 Sept 2006) up to before 0.9.8g-9.
  • Distros: Debian and Debian-based systems such as Ubuntu.
  • Key types: SSH keys, OpenVPN keys, DNSSEC keys, X.509 certificate keys, and TLS session keys.
  • Not affected: keys from GnuPG or GnuTLS, and keys made on non-Debian distributions.

Discovery and fix. Security researcher Luciano Bello found the problem. Debian published its advisory on 13 May 2008 (CVE-2008-0166). Fixed packages were 0.9.8c-4etch3 for Debian 4.0 (etch) and 0.9.8g-9 for lenny. Patching the library didn't fix existing keys, so every weak key had to be regenerated. Many tools added blacklists of known weak keys.

Interview takeaway: never change crypto code to silence a tool without understanding why the code is there. Test randomness properties, and remember that a fix doesn't repair keys already generated.

Keep reading to the end to earn XP.Read. XP earned.

Deep dive (2 min)

Timeline

  • 17 September 2006: Debian ships OpenSSL 0.9.8c-1 containing the patch (Wikipedia, OpenSSL article).
  • 2006–2008: every key generated by affected OpenSSL on Debian-based systems comes from a tiny keyspace. Ubuntu and other derivatives inherit it.
  • May 2008: Luciano Bello reports the discovery (Wikipedia, random number generator attack article).
  • 13 May 2008: Debian reports the issue; CVE-2008-0166 is published the same day (NVD).
  • After: "a massive worldwide regeneration of keys." Weak-key blacklists are added to various packages.

Why the change looked reasonable

OpenSSL's random number generator "acquires entropy using complex programming methods," per Wikipedia. Some of that involved memory that tools flagged as uninitialised. Removing the flagged code silenced the warnings, but it also removed most of the entropy feeding the generator.

Why this was so dangerous

  • Silent failure: keys still looked random, worked normally and passed functional tests. Nothing visibly broke.
  • Long exposure: almost two years of keys, many on long-lived servers.
  • Fixing the code isn't enough: "any services still using keys that were generated by the old code remain vulnerable" (Wikipedia). Patching had to be followed by rotating every affected key.
  • Downstream inheritance: a change in one distribution flowed into every distribution built on it.

Severity

NVD rates CVE-2008-0166 at CVSS 3.1 base score 7.5.

Wider lesson for downstream patching

Distribution maintainers often patch upstream software locally. This case is widely used as an example of why security-sensitive changes should be reviewed with, or sent to, the upstream developers who understand why the code is written the way it is.

Keep reading to the end to earn XP.Read. XP earned.

Failure replay

Step by step, what broke and what it hit next.

  1. 2006
    Valgrind warningshealthy

    A debugging tool flags OpenSSL for reading uninitialised memory inside its random number code.

    Affects: Debian OpenSSL patch

  2. 2006
    Debian OpenSSL patchcompromised

    A Debian maintainer removes the flagged code. The warnings go away, and so does most of the randomness.

    Affects: Random number generator

  3. Sep 17, 2006
    Random number generatorcompromised

    Version 0.9.8c-1 ships. The process ID is effectively the only entropy left, so only 32,768 possible keys exist.

    Affects: Keys on Debian and Ubuntu

  4. 2006–2008
    Keys on Debian and Ubuntucompromised

    SSH, VPN, DNSSEC and TLS certificate keys are generated from the tiny pool. They work normally, so nobody notices.

    Affects: Attacker

  5. Any time
    Attackercompromised

    An attacker can precompute every possible key and try them all against servers.

  6. May 13, 2008
    Debian OpenSSL patchrecovering

    After Luciano Bello's discovery, Debian publishes the advisory (CVE-2008-0166) and fixed packages.

    Affects: Keys on Debian and Ubuntu

  7. After
    Keys on Debian and Ubunturecovering

    Admins worldwide must regenerate every affected key, and tools add blacklists of known weak keys.

Impact

Who was affected
Debian and Debian-based systems (including Ubuntu) running OpenSSL 0.9.8c-1 up to before 0.9.8g-9; SSH, OpenVPN, DNSSEC, X.509 and TLS session keys.
How long
Vulnerable keys were generated for about 20 months (Sept 2006 to May 2008); keys stayed weak until regenerated.
Cost
not disclosed

Lessons

  • Don't modify security code to silence a tool without understanding why the code exists.
  • Randomness failures are silent; keys still look and work normally.
  • Patching the generator doesn't fix keys already created; plan for mass key rotation.
  • Downstream patches to security libraries should be reviewed with upstream maintainers.

Quiz

  1. Why did the Debian maintainer change OpenSSL's code in 2006?

    Check answer

    To silence warnings about uninitialised memory reported by debugging tools like Valgrind. The patch responded to warnings about accessing uninitialised memory, and accidentally broke the RNG.

  2. How many possible keys could the broken generator produce?

    Check answer

    32,768. Entropy was effectively reduced to the process ID, limiting keys to 32,768.

  3. Which keys were NOT affected?

    Check answer

    Keys generated with GnuPG or GnuTLS. GnuPG and GnuTLS used different random number methods, and non-Debian distributions were unaffected.

  4. After installing the fixed OpenSSL package, what else did admins have to do?

    Check answer

    Regenerate every key created by the vulnerable version. Patching stopped new weak keys, but existing keys stayed guessable until replaced.

Interview prep

Try answering out loud before you open the model answer.

  1. security

    Why does weak randomness in key generation break cryptography even if the algorithm is perfectly secure? Use the Debian OpenSSL bug as an example.

    Show model answer

    Security assumes the attacker can't guess the key, so the key must come from a huge, unpredictable space. On Debian, the RNG's entropy was effectively reduced to the process ID, so only 32,768 keys of a given type could exist. An attacker can generate all of them and try each one: brute force becomes trivial no matter how strong RSA or the cipher is. The algorithm was fine; the input wasn't. Defences include using the OS's cryptographic RNG, health checks on entropy sources, and never altering RNG code without expert review.

    A strong answer hits:

    • Strength depends on unpredictable key material
    • Keyspace collapsed to 32,768
    • Precompute and try every key
    • Use vetted OS RNGs and get expert review
  2. behavioural

    A static analysis or memory tool flags a warning in security-critical code you don't fully understand. What do you do?

    Show model answer

    Don't just make the warning go away. Find out why the code is written that way. Read the history, ask the upstream maintainers, and check whether the flagged behaviour is intentional. If a suppression is needed, prefer a targeted tool suppression over a code change. For any change, get review from someone with domain expertise and add tests for the property that matters (here, entropy). The Debian maintainer removed code to silence warnings and broke key generation for two years.

    A strong answer hits:

    • Understand intent before changing
    • Consult upstream or domain experts
    • Prefer tool suppression over code changes
    • Test the security property, not just functionality
  3. system design

    You discover that keys across your fleet were generated with a broken RNG. How do you plan the response?

    Show model answer

    Patch the generator first so no new weak keys appear. Inventory every key type and location: SSH host and user keys, TLS certificates, VPN and DNSSEC keys. Prioritise by exposure (internet-facing first). Rotate keys, revoke certificates, and update trust stores and known_hosts. Add detection: block known weak keys (Debian ecosystems shipped blacklists) and scan for them. Communicate clearly with users, who may need to regenerate personal keys. Afterwards, add automated key inventory so the next rotation is faster.

    A strong answer hits:

    • Fix generation first, then rotate existing keys
    • Full key inventory and prioritisation
    • Revoke and replace, update trust
    • Weak-key blacklists and scanning

Go deeper