CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong.
Last updated
The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong.
Last updated
When a non-cryptographic PRNG is used in a cryptographic context, it can expose the cryptography to certain types of attacks.
Often a pseudo-random number generator (PRNG) is not designed for cryptography. Sometimes a mediocre source of randomness is sufficient or preferable for algorithms that use random numbers. Weak generators generally take less processing power and/or do not use the precious, finite, entropy sources on a system. While such PRNGs might have very useful features, these same features could be used to break the cryptography.
198 recorded CVEs are caused by CWE-338 (Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)). The highest-severity and most recent are shown first. 68 new CWE-338 CVEs have been recorded so far in 2026 (33 in 2025).
Predictable Active Directory service-account passwords in BoKS Manager
Langflow is affected by weaknesses in secret handling and sensitive configuration access
Crypt::Password versions through 0.28 for Perl generate insecure random values for salts
Cloudreve is vulnerable to Account Takeover via Weak Cryptographic Token Generation (Insecure PRNG Seeding)
Maypole versions from 2.10 through 2.13 for Perl generates session ids insecurely
Apache Druid: Kerberos authenticaton chooses a cryptographically unsecure secret if not configured explicitly.
COMMGR - Insufficient Randomization Authentication Bypass
SonicWALL NSv Cryptographically Weak PRNG Authentication Bypass Vulnerability
Insecure Randomness in CBOT's Chatbot
Showing 12 of 198 recorded CWE-338 CVEs. Get an alert for each new one, with AI-written analysis and fixes.
Monitor these CVEsWhat can happen when CWE-338 is exploited.
Bypass Protection Mechanism
Affects: Access Control
If a PRNG is used for authentication and authorization, such as a session ID or a seed for generating a cryptographic key, then an attacker may be able to easily guess the ID or cryptographic key and gain access to restricted functionality.
Typically introduced during these phases of the software lifecycle.
Practical mitigations for CWE-338, grouped by where in the lifecycle they apply.
Use functions or hardware which use a hardware-based random number generation for all crypto. This is the recommended solution. Use CyptGenRandom on Windows, or hw_rand() on Linux.
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Effectiveness: High
MITRE examples of the weakness in code.
Both of these examples use a statistical PRNG seeded with the current value of the system clock to generate a random number:
Vulnerable example
Random random = new Random(System.currentTimeMillis());
int accountID = random.nextInt();Vulnerable example
srand(time());
int randNum = rand();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).
Real CVEs that MITRE cites as examples of this weakness.
Common questions about CWE-338.
Weakness data is sourced from the MITRE CWE catalog (v4.21). CVE associations are aggregated and kept current by RadicalNotion.AI.
Get an alert when a new CWE-338 CVE affects your products, with AI-written analysis and remediation steps.