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.
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.
Consequences
- Access Control: Bypass Protection Mechanism
How to prevent it
- 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.
Recent advisories
- GHSA-mfj3-87qq-382v — AsyncHttpClient: Digest authentication cnonce generated with a non-cryptographic random source
- PYSEC-2026-3745 — openssl_encrypt before 1.4.0 imports Python's non-cryptographic 'random' module (Mersenne Twister PRNG) at line 15 of openssl_encrypt/modules/pqc.py.
- GHSA-jxw3-mjmx-3pqm — Langflow: Weak Fernet Key via random.seed()
- GHSA-vfgx-5q85-58q3 — openssl-encrypt has non-cryptographic PRNG used for steganography pixel selection
- GHSA-82vr-5769-6358 — Ethyca Fides Cryptographically Weak Generation of One-Time Codes for Identity Verification
- GHSA-c4r2-3f9r-rwp8 — Magento 2 Community Weak PRNG
- GHSA-8v9h-m7pj-hx7c — Magento 2 Community Edition Weak PRNG
- GHSA-2w26-gmqm-mc5p — Magento 2 Community Cryptographic Flaw
- GHSA-vrgh-5w3c-ggf8 — showdoc is vulnerable to Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
- GHSA-j85q-whc9-g4p9 — Use of Cryptographically Weak Pseudo-Random Number Generator in showdoc
- GHSA-rmw5-xpg9-jr29 — Use of Cryptographically Weak Pseudo-Random Number Generator in Rclone
- GHSA-gwf7-vfjf-wf6x — matrix-sydent and matrix-synapse Use Cryptographically Weak PRNG
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor