836
int accountID = random.nextInt();
Example Language: C (Bad)
srand(time());
int randNum = rand();
An attacker can easily predict the seed used by these PRNGs, and so also predict the stream of
random numbers generated. Note these examples also exhibit CWE-338 (Use of Cryptographically
Weak PRNG).
Observed Examples
Reference Description
CVE-2020-7010 Cloud application on Kubernetes generates passwords using a weak random
number generator based on deployment time.
https://www.cve.org/CVERecord?id=CVE-2020-7010
CVE-2019-11495 server uses erlang:now() to seed the PRNG, which results in a small search
space for potential random seeds
https://www.cve.org/CVERecord?id=CVE-2019-11495
CVE-2008-0166 The removal of a couple lines of code caused Debian's OpenSSL Package to
only use the current process ID for seeding a PRNG
https://www.cve.org/CVERecord?id=CVE-2008-0166
CVE-2016-10180 Router's PIN generation is based on rand(time(0)) seeding.
https://www.cve.org/CVERecord?id=CVE-2016-10180
CVE-2018-9057 cloud provider product uses a non-cryptographically secure PRNG and seeds
it with the current time
https://www.cve.org/CVERecord?id=CVE-2018-9057
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 861 The CERT Oracle Secure Coding Standard for Java
(2011) Chapter 18 - Miscellaneous (MSC)
844 2370
MemberOf 905 SFP Primary Cluster: Predictability 888 2388
MemberOf 1152 SEI CERT Oracle Secure Coding Standard for Java -
Guidelines 49. Miscellaneous (MSC)
1133 2453
MemberOf 1346 OWASP Top Ten 2021 Category A02:2021 -
Cryptographic Failures
1344 2488
MemberOf 1366 ICS Communications: Frail Security in Protocols 1358 2503
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
CWE Version 4.14
CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
CWE-338: Use of Cryptographically Weak
Pseudo-Random Number Generator (PRNG)