839
The random number functions used in these examples, rand() and Random.nextInt(), are not
considered cryptographically strong. An attacker may be able to predict the random numbers
generated by these functions. Note that these example also exhibit CWE-337 (Predictable Seed in
PRNG).
Observed Examples
Reference Description
CVE-2021-3692 PHP framework uses mt_rand() function (Marsenne Twister) when generating
tokens
https://www.cve.org/CVERecord?id=CVE-2021-3692
CVE-2009-3278 Crypto product uses rand() library function to generate a recovery key, making
it easier to conduct brute force attacks.
https://www.cve.org/CVERecord?id=CVE-2009-3278
CVE-2009-3238 Random number generator can repeatedly generate the same value.
https://www.cve.org/CVERecord?id=CVE-2009-3238
CVE-2009-2367 Web application generates predictable session IDs, allowing session hijacking.
https://www.cve.org/CVERecord?id=CVE-2009-2367
CVE-2008-0166 SSL library uses a weak random number generator that only generates 65,536
unique keys.
https://www.cve.org/CVERecord?id=CVE-2008-0166
MemberOf Relationships
This MemberOf relationships table shows additional CWE Catgeories and Views that reference this
weakness as a member. This information is often useful in understanding where a weakness fits
within the context of external information sources.
Nature Type ID Name Page
MemberOf 884 CWE Cross-section 884 2567
MemberOf 905 SFP Primary Cluster: Predictability 888 2388
MemberOf 1170 SEI CERT C Coding Standard - Guidelines 48.
Miscellaneous (MSC)
1154 2463
MemberOf 1346 OWASP Top Ten 2021 Category A02:2021 -
Cryptographic Failures
1344 2488
MemberOf 1414 Comprehensive Categorization: Randomness 1400 2543
Notes
Maintenance
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 commonlyused
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.
Taxonomy Mappings
Mapped Taxonomy Name Node ID Fit Mapped Node Name
CLASP Non-cryptographic PRNG
CERT C Secure Coding MSC30-
C
CWE More
Abstract
Do not use the rand() function for
generating pseudorandom numbers
References
[REF-18]Secure Software, Inc.. "The CLASP Application Security Process". 2005. < https://
cwe.mitre.org/documents/sources/TheCLASPApplicationSecurityProcess.pdf >.
CWE Version 4.14
CWE-339: Small Seed Space in PRNG
CWE-339: Small Seed Space in PRNG