841
Use products or modules that conform to FIPS 140-2 [REF-267] to avoid obvious entropy
problems, or use the more recent FIPS 140-3 [REF-1192] if possible.
Demonstrative Examples
Example 1:
This code grabs some random bytes and uses them for a seed in a PRNG, in order to generate a
new cryptographic key.
Example Language: Python (Bad)
# getting 2 bytes of randomness for the seeding the PRNG
seed = os.urandom(2)
random.seed(a=seed)
key = random.getrandbits(128)
Since only 2 bytes are used as a seed, an attacker will only need to guess 2^16 (65,536) values
before being able to replicate the state of the PRNG.
Observed Examples
Reference Description
CVE-2019-10908 product generates passwords via
org.apache.commons.lang.RandomStringUtils, which uses java.util.Random
internally. This PRNG has only a 48-bit seed.
https://www.cve.org/CVERecord?id=CVE-2019-10908
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 905 SFP Primary Cluster: Predictability 888 2388
MemberOf 1414 Comprehensive Categorization: Randomness 1400 2543
Notes
Maintenance
This entry may have a chaining relationship with predictable from observable state (CWE-341).
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
PLOVER Small Seed Space in PRNG
References
[REF-267]Information Technology Laboratory, National Institute of Standards and Technology.
"SECURITY REQUIREMENTS FOR CRYPTOGRAPHIC MODULES". 2001 May 5. < https://
csrc.nist.gov/csrc/media/publications/fips/140/2/final/documents/fips1402.pdf >.2023-04-07.
CWE Version 4.14
CWE-340: Generation of Predictable Numbers or Identifiers
CWE-340: Generation of Predictable Numbers or Identifiers