CWEweakness

CWE-338 Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)

Medium Official page ↗
Abstraction
Base
Structure
Simple
Status
Draft
Likelihood of exploit
Medium
Languages
Not Language-Specific
CWE version
5.0

Description

The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong.

Extended description

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.

Common consequences

• Access Control: Bypass Protection Mechanism — 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.

Potential mitigations

• [Implementation] 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.

Detection methods

• Automated Static Analysis: 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.)

Observed examples

• CVE-2021-3692: PHP framework uses mt_rand() function (Marsenne Twister) when generating tokens • CVE-2009-3278: Crypto product uses rand() library function to generate a recovery key, making it easier to conduct brute force attacks. • CVE-2009-3238: Random number generator can repeatedly generate the same value. • CVE-2009-2367: Web application generates predictable session IDs, allowing session hijacking. • CVE-2008-0166: SSL library uses a weak random number generator that only generates 65,536 unique keys.

Related

Observed example · CVE (5)

  • CVE-2021-3692 yii2 is vulnerable to Use of Predictable Algorithm in Random Number Generator vulnerability
  • CVE-2009-3278 The QNAP TS-239 Pro and TS-639 Pro with firmware 2.1.7 0613, 3.1.0 0627, and 3.1.1 0815 use the rand library function to generate a certain… vulnerability
  • CVE-2009-3238 The get_random_int function in drivers/char/random.c in the Linux kernel before 2.6.30 produces insufficiently random numbers, which allows… vulnerability
  • CVE-2009-2367 cgi-bin/makecgi-pro in Iomega StorCenter Pro generates predictable session IDs, which allows remote attackers to hijack active sessions and… vulnerability
  • CVE-2008-0166 OpenSSL 0.9.8c-1 up to versions before 0.9.8g-9 on Debian-based operating systems uses a random number generator that generates predictable… vulnerability

Child of · CWE (1)

  • CWE-330 Use of Insufficiently Random Values weakness

Referenced by CVE · weakness (226)

  • CVE-2026-102813 An authentication flaw exists in the password-recovery functionality of TP-Link RE305 V3. vulnerability
  • CVE-2026-19742 The IPv6 stack derived the long-lived secret key used to compute RFC 7217 stable interface identifiers (gen_stable_iid() in… vulnerability
  • CVE-2026-112240 The download link for files uploaded through a form relied on a token that could be predicted. vulnerability
  • CVE-2026-112041 A vulnerability was identified in diem-project diem up to 116974edfb9a5b8bd69cb13586dc62bcdbb485ad. vulnerability
  • CVE-2026-107612 Incorrect permission assignment in GlavSoft TightVNC Server for Windows before 2.8.88 allows a local authenticated user to read or… vulnerability
  • CVE-2026-107283 The AsyncHttpClient (AHC) library allows Java applications to easily execute HTTP requests and asynchronously process HTTP responses. vulnerability
  • CVE-2026-104356 PictShare before version 3.7.1 contains a weak randomness vulnerability where the getRandomString() function uses the non-cryptographic… vulnerability
  • CVE-2026-53953 GetSimple CMS is a content management system (CMS), and GetSimple CMS CE is the community edition of that CMS. vulnerability
  • CVE-2026-79901 In deployments using BoKS keytab management, affected versions of boks_keytabmd generate Active Directory service-account passwords from a… vulnerability
  • CVE-2026-9864 Fortra BoKS Server Agent contains a predictable password generation vulnerability in the adjoin utility. vulnerability
  • CVE-2026-94456 Postiz generates security-sensitive credentials using `Math.random()` instead of a cryptographically secure source. vulnerability
  • CVE-2026-94107 NivoCart through 2.4.0 contains a predictable password reset token vulnerability in the forgotten.php endpoint that generates recovery… vulnerability
  • CVE-2026-93868 Cotonti through 1.0.0 derives password recovery validation tokens from md5(microtime()) in users.passrecover.php, creating a predictable… vulnerability
  • CVE-2026-92298 EspoCRM through 10.0.8 uses PHP's rand() function to generate tokens for lead-capture opt-in, event invitation, and campaign URLs instead… vulnerability
  • CVE-2026-92749 SafeLine through 9.4.1 derives the management console session-signing secret from a time-seeded math/rand generator, allowing attackers to… vulnerability
  • CVE-2026-74874 openssl_encrypt versions before 1.4.0 use Python's non-cryptographic random module for steganographic pixel selection in the… vulnerability
  • CVE-2026-74887 openssl_encrypt before 1.4.0 imports Python's non-cryptographic 'random' module (Mersenne Twister PRNG) at line 15 of… vulnerability
  • CVE-2026-73567 sm-crypto provides JavaScript implementations of the Chinese cryptographic algorithms SM2, SM3, and SM4. vulnerability
  • CVE-2026-18611 A flaw was found in the Data Science Pipelines Operator. vulnerability
  • CVE-2026-71851 crypto-js is a JavaScript library of crypto standards. vulnerability
  • CVE-2026-9205 IBM Langflow OSS contains a weak cryptographic key derivation vulnerability in the ensure_fernet_key() function. vulnerability
  • CVE-2026-47882 When enabling Spring Boot DevTools support for a remote application target (for example a Docker container or Cloud Foundry app) from the… vulnerability
  • CVE-2026-16615 A flaw was found in librest. vulnerability
  • CVE-2026-64798 Joomla Extension - regularlabs.com - Insecure login URL keys in IP login extension - Persistent URL login keys were also generated using a… vulnerability
  • CVE-2026-13577 Dancer2 versions before 2.2.0 for Perl generate insecure session ids when required CSPRNG modules are unavailable. vulnerability
  • CVE-2026-16235 Crypt::Password versions through 0.28 for Perl generate insecure random values for salts. vulnerability
  • CVE-2026-8169 ExtremeXOS (EXOS) uses a challenge-response mechanism to authorize access to the privileged debug-mode function. vulnerability
  • CVE-2026-9323 The urwid web display backend (urwid/display/web.py) generates web session identifiers (urwid_id) in Screen.start() by concatenating two… vulnerability
  • CVE-2026-13082 GD::SecurityImage versions through 1.75 for Perl use rand to generate secrets. vulnerability
  • CVE-2026-63089 WireGuard Easy through 15.3.0, fixed in commit 66b292b, contains a cryptographically weak one-time link token generation vulnerability that… vulnerability
Show all 226 ›

Referenced by CWE · has member (1)

Referenced by OWASP · mapped cwe (2)

  • A04:2025 Cryptographic Failures Top 10 2025
  • A02:2021 Cryptographic Failures Top 10 2021