Skip to content

CWE-330 in the wild, breaches caused by weak randomness

CWE-330, "Use of Insufficiently Random Values", is the class covering every failure where predictable values were used where unpredictable ones were required. It is the root of a family that reaches key generation, session tokens, initialisation vectors, nonces and password resets.

One weakness, many symptoms

CWE-330 sits above a group of related entries — predictable seeds, insufficient entropy, use of a cryptographically weak PRNG, reuse of a nonce. They describe different symptoms of the same underlying condition: a value that had to be unpredictable was not.

Grouping them matters because the fixes look unrelated while the cause is identical. Patching each symptom individually leaves the condition in place.

Where it appears

  • Key generation. The most severe case: a predictable key is a compromised key for as long as it is in service, discoverable years later.
  • Session tokens. Predictable identifiers let an attacker guess another user's session, and this remains one of the most common real-world instances.
  • Nonces and IVs. Many modes fail catastrophically on reuse. ECDSA with a repeated nonce leaks the private key outright, from two signatures.
  • Password reset tokens. Frequently generated with a general-purpose PRNG because the code was written where randomness was not the concern.
  • Anything hedging with a timestamp. Seeding from the clock is the classic, because the clock is public.

Why it persists

A weak random value never announces itself. Everything works, tests pass, and the defect is invisible until someone attacks it deliberately. There is no crash, no error and no log line.

The failure is also usually not where the mistake was. The mistake is the source; the symptom is a signature, a token or a key — which is why the case histories are the most persuasive teaching material available.

What actually prevents it

Using the operating system's cryptographic generator instead of a general-purpose PRNG prevents most instances. Beyond that, the questions are whether the OS generator is well seeded on your platform, whether it is seeded at first boot on an embedded device, and whether anyone would know if the underlying source degraded — the boot and virtualisation cases are where this bites hardest.