Cryptography / Insufficient Entropy

Web and API


Insufficient entropy, also known as CWE-330, is an IT vulnerability in the cryptography domain. It is classified as a weakness in the CWE directory and is also discussed in the OWASP Testing Guide. This vulnerability occurs when a system generates cryptographic keys with insufficient entropy. This means that the keys generated by the system will not have enough randomness in them, which can make them easier to guess by an attacker and in turn, lead to the system being compromised.


The risk posed by insufficient entropy is that an attacker can easily guess the cryptographic keys generated by the system, thus gaining access to the system or its data. If the system holds sensitive data, then the risk is even higher.


The solution to this vulnerability is to ensure that the cryptographic keys generated by the system have high entropy. This can be done by using cryptographic algorithms that generate random keys, or by using secure random number generators.


The following code is an example of an insufficient entropy vulnerability taken from the CVE directory (CVE-2019-6703):

// Bad code sample
byte[] key = new byte[16];
Random rng = new Random();

This code creates a new byte array ‘key’ with a length of 16 and then uses the Random class to fill it with random bytes. However, the Random class is not suitable for generating cryptographic keys since it is not cryptographically secure and has low entropy, making the generated keys easy to guess.

Curious? Convinced? Interested?

Arrange a no-obligation consultation with one of our product experts today.