CWE-331:熵不足
View customized information:
![]() ![]()
![]() ![]()
![]() ![]()
![]() ![]()
![]()
![]() 语言 班级: Not Language-Specific(不确定的患病率) ![]()
Example 1 This code generates a unique random identifier for a user's session.
(bad code)
Example Language:PHP
函数生成essionsId($ userId){
srand($userID); }返回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. 此示例还显示了一个小的种子空间(CWE-339). Example 2 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 code)
Example Language:爪哇
字符串GenerateCeipturl(字符串baseurl){
Random Rangen = new Random(); }rangen.setseed(((new Date())。getTime()); return(baseUrl + ranGen.nextInt(400000000) + ".html"); 该代码使用Random.nextint()函数来生成其生成的收据页面的“唯一”标识符。因为Random.nextint()是统计PRNG,所以攻击者很容易猜测其生成的字符串。尽管收据系统的基础设计也有故障,但如果使用随机数生成器,它不会产生可预测的接收标识符,例如加密PRNG,它将更加安全。
![]()
维护
As of CWE 4.5, terminology related to randomness, entropy, and predictability can vary widely. Within the developer and other communities, "randomness" is used heavily. However, within cryptography, "entropy" is distinct, typically implied as a measurement. There are no commonly-used definitions, even within standards documents and cryptography papers. Future versions of CWE will attempt to define these terms and, if necessary, distinguish between them in ways that are appropriate for different communities but do not reduce the usability of CWE for mapping, understanding, or other scenarios.
More information is available — Please select a different filter.
|
Use of the Common Weakness Enumeration (CWE) and the associated references from this website are subject to the使用条款. CWE is sponsored by theU.S. Department of Homeland Security(DHS)Cybersecurity and Infrastructure Security Agency(CISA),由Homeland Security Systems Engineering and Development Institute(HSSEDI) which is operated bymanbetx客户端首页(MITRE). Copyright © 2006–2023, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. |