CWE-331 信息熵不充分

admin 2022年1月2日04:08:43评论218 views字数 2120阅读7分4秒阅读模式

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.

可能的缓解方案

Implementation

策略:

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){

srand($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

引用

文章来源于互联网:scap中文网

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年1月2日04:08:43
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CWE-331 信息熵不充分http://cn-sec.com/archives/612916.html

发表评论

匿名网友 填写信息