CWE-331 信息熵不充分

Insufficient Entropy

结构: Simple

Abstraction: Base

状态: Draft

被利用可能性: unkown


The software uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.


  • cwe_Nature: ChildOf cwe_CWE_ID: 330 cwe_View_ID: 1000 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 330 cwe_View_ID: 1003 cwe_Ordinal: Primary

  • cwe_Nature: ChildOf cwe_CWE_ID: 330 cwe_View_ID: 699 cwe_Ordinal: Primary


Language: {'cwe_Class': 'Language-Independent', 'cwe_Prevalence': 'Undetermined'}


范围 影响 注释
['Access Control', 'Other'] ['Bypass Protection Mechanism', 'Other'] An attacker could guess the random numbers generated and could gain unauthorized access to a system if the random numbers are used for authentication and authorization.




Determine the necessary entropy to adequately provide for randomness and predictability. This can be achieved by increasing the number of bits of objects such as keys and seeds.


This code generates a unique random identifier for a user's session.

bad PHP

function generateSessionID($userID){
return rand();

Because the seed for the PRNG is always the user's ID, the session ID will always be the same. An attacker could thus predict any user's session ID and potentially hijack the session.

This example also exhibits a Small Seed Space (CWE-339).

The following code uses a statistical PRNG to create a URL for a receipt that remains active for some period of time after a purchase.

bad Java

String GenerateReceiptURL(String baseUrl) {
Random ranGen = new Random();
ranGen.setSeed((new Date()).getTime());
return(baseUrl + ranGen.nextInt(400000000) + ".html");

This code uses the Random.nextInt() function to generate "unique" identifiers for the receipt pages it generates. Because Random.nextInt() is a statistical PRNG, it is easy for an attacker to guess the strings it generates. Although the underlying design of the receipt system is also faulty, it would be more secure if it used a random number generator that did not produce predictable receipt identifiers, such as a cryptographic PRNG.


标识 说明 链接


映射的分类名 ImNode ID Fit Mapped Node Name
PLOVER Insufficient Entropy
WASC 11 Brute Force
CERT C Secure Coding MSC32-C Exact Properly seed pseudorandom number generators


  • CAPEC-59