CWE-338
Weakness AllowedUse of Cryptographically Weak Pseudo-Random Number Generator (PRNG)
Abstraction: Base · Status: Draft
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.
Mapping guidance
This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.
Modes of introduction
REALIZATION: This weakness is caused during implementation of an architectural security tactic.
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.)
Effectiveness: High
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 commonly-used 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.
Content history
updated Time_of_Introduction
updated Common_Consequences, Relationships, Other_Notes, Taxonomy_Mappings
updated Common_Consequences
updated Common_Consequences, Observed_Examples, References, Relationships
updated Demonstrative_Examples, Potential_Mitigations
updated Applicable_Platforms, Description, Name, Other_Notes
updated Relationships
updated Demonstrative_Examples, Description, Modes_of_Introduction, Relationships, Taxonomy_Mappings
updated Relationships
updated References, Relationships
updated Demonstrative_Examples
updated Maintenance_Notes
updated Relationships
updated Detection_Factors, Relationships
updated Mapping_Notes
updated Observed_Examples
updated Applicable_Platforms, Relationships, Weakness_Ordinalities
384 vulnerabilities reference this CWE, most recent first.
GHSA-W287-9Q69-3HX9
Vulnerability from github – Published: 2025-01-04 00:33 – Updated: 2025-01-21 18:31In Net::OAuth::Client in the Net::OAuth package before 0.29 for Perl, the default nonce is a 32-bit integer generated from the built-in rand() function, which is not cryptographically strong.
{
"affected": [],
"aliases": [
"CVE-2025-22376"
],
"database_specific": {
"cwe_ids": [
"CWE-338"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-01-03T22:15:07Z",
"severity": "CRITICAL"
},
"details": "In Net::OAuth::Client in the Net::OAuth package before 0.29 for Perl, the default nonce is a 32-bit integer generated from the built-in rand() function, which is not cryptographically strong.",
"id": "GHSA-w287-9q69-3hx9",
"modified": "2025-01-21T18:31:04Z",
"published": "2025-01-04T00:33:40Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-22376"
},
{
"type": "WEB",
"url": "https://github.com/keeth/Net-OAuth/commit/2aa25e04aadab247ae4063363fcee177161e1f42"
},
{
"type": "WEB",
"url": "https://datatracker.ietf.org/doc/html/rfc5849#section-3.3"
},
{
"type": "WEB",
"url": "https://datatracker.ietf.org/doc/html/rfc5849#section-4.10"
},
{
"type": "WEB",
"url": "https://metacpan.org/release/KGRENNAN/Net-OAuth-0.28/source/lib/Net/OAuth/Client.pm#L260"
},
{
"type": "WEB",
"url": "https://metacpan.org/release/RRWO/Net-OAuth-0.29/changes"
},
{
"type": "WEB",
"url": "https://metacpan.org/release/RRWO/Net-OAuth-0.29/diff/KGRENNAN/Net-OAuth-0.28#lib/Net/OAuth/Client.pm"
},
{
"type": "WEB",
"url": "https://www.vulnarium.com/blogpost-2025-01-05"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-W5V5-5VPM-87MX
Vulnerability from github – Published: 2022-02-10 00:00 – Updated: 2022-02-10 00:00Z-Wave devices from Sierra Designs (circa 2013) and Silicon Labs (using S0 security) may use a known, shared network key of all zeros, allowing an attacker within radio range to spoof Z-Wave traffic.
{
"affected": [],
"aliases": [
"CVE-2013-20003"
],
"database_specific": {
"cwe_ids": [
"CWE-338"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2022-02-04T23:15:00Z",
"severity": "HIGH"
},
"details": "Z-Wave devices from Sierra Designs (circa 2013) and Silicon Labs (using S0 security) may use a known, shared network key of all zeros, allowing an attacker within radio range to spoof Z-Wave traffic.",
"id": "GHSA-w5v5-5vpm-87mx",
"modified": "2022-02-10T00:00:50Z",
"published": "2022-02-10T00:00:50Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2013-20003"
},
{
"type": "WEB",
"url": "https://orangecyberdefense.com/global/blog/sensepost/blackhat-conference-z-wave-security"
},
{
"type": "WEB",
"url": "https://sensepost.com/cms/resources/conferences/2013/bh_zwave/Security%20Evaluation%20of%20Z-Wave_WP.pdf"
},
{
"type": "WEB",
"url": "https://www.pentestpartners.com/security-blog/z-shave-exploiting-z-wave-downgrade-attacks"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-W67G-5RQW-F597
Vulnerability from github – Published: 2026-08-24 21:00 – Updated: 2026-08-24 21:00gorilla/websocket used math/rand (cryptographically weak pseudo-random number generator) to generate WebSocket frame mask keys prior to commit d67f4185. WebSocket masking keys MUST be unpredictable to prevent frame content injection attacks. math/rand produces deterministic output when seeded with a known value, enabling an attacker to predict or recover mask keys and inject content into WebSocket connections.
Type: Use of Cryptographically Weak Pseudo-Random Number Generator Fix: Replaced math/rand with crypto/rand (commit d67f4185, released in v1.5.3) Credit: bounty-hunter v6.0 silent-fix detection
{
"affected": [
{
"package": {
"ecosystem": "Go",
"name": "github.com/gorilla/websocket"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.5.3"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [],
"database_specific": {
"cwe_ids": [
"CWE-338"
],
"github_reviewed": true,
"github_reviewed_at": "2026-08-24T21:00:54Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "gorilla/websocket used `math/rand` (cryptographically weak pseudo-random number generator) to generate WebSocket frame mask keys prior to commit d67f4185. WebSocket masking keys MUST be unpredictable to prevent frame content injection attacks. math/rand produces deterministic output when seeded with a known value, enabling an attacker to predict or recover mask keys and inject content into WebSocket connections.\n\n**Type:** Use of Cryptographically Weak Pseudo-Random Number Generator\n**Fix:** Replaced math/rand with crypto/rand (commit d67f4185, released in v1.5.3)\n**Credit:** bounty-hunter v6.0 silent-fix detection",
"id": "GHSA-w67g-5rqw-f597",
"modified": "2026-08-24T21:00:54Z",
"published": "2026-08-24T21:00:54Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/canolgun-commits/websocket/security/advisories/GHSA-w67g-5rqw-f597"
},
{
"type": "WEB",
"url": "https://github.com/gorilla/websocket/commit/d67f41855da42d7bccd9ef050c49f7e54e783b95"
},
{
"type": "PACKAGE",
"url": "https://github.com/canolgun-commits/websocket"
},
{
"type": "WEB",
"url": "https://github.com/gorilla/websocket/releases/tag/v1.5.3"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "Gorilla WebSocket Uses Cryptographically Weak PRNG for WebSocket Mask Key"
}
GHSA-W6W2-2WXG-GGWX
Vulnerability from github – Published: 2025-06-16 12:30 – Updated: 2025-06-16 15:32Mojolicious::Plugin::CaptchaPNG version 1.05 for Perl uses a weak random number source for generating the captcha.
That version uses the built-in rand() function for generating the captcha text as well as image noise, which is insecure.
{
"affected": [],
"aliases": [
"CVE-2025-40916"
],
"database_specific": {
"cwe_ids": [
"CWE-338"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-06-16T11:15:17Z",
"severity": "CRITICAL"
},
"details": "Mojolicious::Plugin::CaptchaPNG version 1.05 for Perl uses a weak random number source for generating the captcha.\n\nThat version uses the built-in rand() function for generating the captcha text as well as image noise, which is insecure.",
"id": "GHSA-w6w2-2wxg-ggwx",
"modified": "2025-06-16T15:32:26Z",
"published": "2025-06-16T12:30:26Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-40916"
},
{
"type": "WEB",
"url": "https://metacpan.org/pod/perlfunc#rand"
},
{
"type": "WEB",
"url": "https://metacpan.org/release/GRYPHON/Mojolicious-Plugin-CaptchaPNG-1.04/diff/GRYPHON/Mojolicious-Plugin-CaptchaPNG-1.05/lib/Mojolicious/Plugin/CaptchaPNG.pm"
},
{
"type": "WEB",
"url": "https://metacpan.org/release/GRYPHON/Mojolicious-Plugin-CaptchaPNG-1.06/changes"
},
{
"type": "WEB",
"url": "https://security.metacpan.org/docs/guides/random-data-for-security.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-W6XH-RJX5-X9M5
Vulnerability from github – Published: 2023-06-06 18:30 – Updated: 2024-04-04 04:36Landscape cryptographic keys were insecurely generated with a weak pseudo-random generator.
{
"affected": [],
"aliases": [
"CVE-2023-32549"
],
"database_specific": {
"cwe_ids": [
"CWE-338"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-06-06T16:15:10Z",
"severity": "HIGH"
},
"details": "Landscape cryptographic keys were insecurely generated with a weak pseudo-random generator.",
"id": "GHSA-w6xh-rjx5-x9m5",
"modified": "2024-04-04T04:36:05Z",
"published": "2023-06-06T18:30:20Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-32549"
},
{
"type": "WEB",
"url": "https://bugs.launchpad.net/landscape/+bug/1929034"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:N/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-W88F-4875-99C8
Vulnerability from github – Published: 2025-11-26 09:31 – Updated: 2025-11-26 23:19Apache Druid’s Kerberos authenticator uses a weak fallback secret when the druid.auth.authenticator.kerberos.cookieSignatureSecret configuration is not explicitly set. In this case, the secret is generated using ThreadLocalRandom, which is not a crypto-graphically secure random number generator. This may allow an attacker to predict or brute force the secret used to sign authentication cookies, potentially enabling token forgery or authentication bypass. Additionally, each process generates its own fallback secret, resulting in inconsistent secrets across nodes. This causes authentication failures in distributed or multi-broker deployments, effectively leading to a incorrectly configured clusters. Users are advised to configure a strong druid.auth.authenticator.kerberos.cookieSignatureSecret
This issue affects Apache Druid: through 34.0.0.
Users are recommended to upgrade to version 35.0.0, which fixes the issue making it mandatory to set druid.auth.authenticator.kerberos.cookieSignatureSecret when using the Kerberos authenticator. Services will fail to come up if the secret is not set.
{
"affected": [
{
"package": {
"ecosystem": "Maven",
"name": "org.apache.druid:druid"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "35.0.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2025-59390"
],
"database_specific": {
"cwe_ids": [
"CWE-338"
],
"github_reviewed": true,
"github_reviewed_at": "2025-11-26T23:19:18Z",
"nvd_published_at": "2025-11-26T09:15:46Z",
"severity": "CRITICAL"
},
"details": "Apache Druid\u2019s Kerberos authenticator uses a weak fallback secret when the `druid.auth.authenticator.kerberos.cookieSignatureSecret` configuration is not explicitly set. In this case, the secret is generated using `ThreadLocalRandom`, which is not a crypto-graphically secure random number generator. This may allow an attacker to predict or brute force the secret used to sign authentication cookies, potentially enabling token forgery or authentication bypass. Additionally, each process generates its own fallback secret, resulting in inconsistent secrets across nodes. This causes authentication failures in distributed or multi-broker deployments, effectively leading to a incorrectly configured clusters. Users are advised to configure a strong\u00a0`druid.auth.authenticator.kerberos.cookieSignatureSecret`\n\nThis issue affects Apache Druid: through 34.0.0.\n\nUsers are recommended to upgrade to version 35.0.0, which fixes the issue making it mandatory to set `druid.auth.authenticator.kerberos.cookieSignatureSecret` when using the\u00a0Kerberos authenticator. Services will fail to come up if the secret is not set.",
"id": "GHSA-w88f-4875-99c8",
"modified": "2025-11-26T23:19:18Z",
"published": "2025-11-26T09:31:21Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-59390"
},
{
"type": "WEB",
"url": "https://github.com/apache/druid/pull/18368"
},
{
"type": "PACKAGE",
"url": "https://github.com/apache/druid"
},
{
"type": "WEB",
"url": "https://lists.apache.org/thread/jwjltllnntgj1sb9wzsjmvwm9f8rlhg8"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2025/11/26/1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "Apache Druid\u2019s Kerberos authenticator uses a weak fallback secret"
}
GHSA-WCW3-C785-7Q5X
Vulnerability from github – Published: 2025-12-22 15:30 – Updated: 2025-12-22 15:30Use of a weak pseudo-random number generator, which may allow an attacker to read or inject encrypted PowerG packets.
{
"affected": [],
"aliases": [
"CVE-2025-26379"
],
"database_specific": {
"cwe_ids": [
"CWE-338"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-12-22T15:16:00Z",
"severity": "HIGH"
},
"details": "Use of a weak pseudo-random number generator, which may allow an attacker to read or inject encrypted PowerG packets.",
"id": "GHSA-wcw3-c785-7q5x",
"modified": "2025-12-22T15:30:21Z",
"published": "2025-12-22T15:30:21Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-26379"
},
{
"type": "WEB",
"url": "https://www.cisa.gov/news-events/ics-advisories/icsa-25-350-02"
},
{
"type": "WEB",
"url": "https://www.johnsoncontrols.com/trust-center/cybersecurity/security-advisories"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:A/AC:L/AT:N/PR:N/UI:N/VC:L/VI:H/VA:L/SC:L/SI:L/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
"type": "CVSS_V4"
}
]
}
GHSA-WR3G-2HMF-PGF3
Vulnerability from github – Published: 2022-05-24 17:12 – Updated: 2022-05-24 17:12An issue was discovered in iNextrix ASTPP before 4.0.1. web_interface/astpp/application/config/config.php does not have strong random keys, as demonstrated by use of the 8YSDaBtDHAB3EQkxPAyTz2I5DttzA9uR private key and the r)fddEw232f encryption key.
{
"affected": [],
"aliases": [
"CVE-2019-15075"
],
"database_specific": {
"cwe_ids": [
"CWE-338"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2020-03-20T18:15:00Z",
"severity": "MODERATE"
},
"details": "An issue was discovered in iNextrix ASTPP before 4.0.1. web_interface/astpp/application/config/config.php does not have strong random keys, as demonstrated by use of the 8YSDaBtDHAB3EQkxPAyTz2I5DttzA9uR private key and the r)fddEw232f encryption key.",
"id": "GHSA-wr3g-2hmf-pgf3",
"modified": "2022-05-24T17:12:00Z",
"published": "2022-05-24T17:12:00Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2019-15075"
},
{
"type": "WEB",
"url": "https://github.com/iNextrix/ASTPP/commit/9877ec62556f0470030acd306b24bc94fdcbe2ae"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-WWVV-X5MQ-H3JJ
Vulnerability from github – Published: 2021-09-01 18:35 – Updated: 2021-08-30 20:28yii2 is vulnerable to Use of Predictable Algorithm in Random Number Generator
{
"affected": [
{
"package": {
"ecosystem": "Packagist",
"name": "yiisoft/yii2-dev"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2.0.43"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2021-3692"
],
"database_specific": {
"cwe_ids": [
"CWE-330",
"CWE-338"
],
"github_reviewed": true,
"github_reviewed_at": "2021-08-30T20:28:42Z",
"nvd_published_at": "2021-08-10T17:15:00Z",
"severity": "MODERATE"
},
"details": "yii2 is vulnerable to Use of Predictable Algorithm in Random Number Generator",
"id": "GHSA-wwvv-x5mq-h3jj",
"modified": "2021-08-30T20:28:42Z",
"published": "2021-09-01T18:35:26Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-3692"
},
{
"type": "WEB",
"url": "https://github.com/yiisoft/yii2/commit/13f27e4d920a05d53236139e8b07007acd046a46"
},
{
"type": "PACKAGE",
"url": "https://github.com/yiisoft/yii2"
},
{
"type": "WEB",
"url": "https://huntr.dev/bounties/55517f19-5c28-4db2-8b00-f78f841e8aba"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N",
"type": "CVSS_V3"
}
],
"summary": "Use of Cryptographically Weak Pseudo-Random Number Generator in yiisoft/yii2-dev"
}
GHSA-X2HV-FJV4-Q826
Vulnerability from github – Published: 2026-11-17 15:33 – Updated: 2026-11-17 15:33pretixSCAN Proxy does not use a secure random generator to generate initialization tokens and API keys for the connection between pretixSCAN devices and the pretixSCAN Proxy. This could allow a skilled attacker with access to at least some of the tokens to predict the value of other tokens more easily.
pretixSCAN is usually used on local networks and the level of exposure heavily depends on the structure of that network. If you want to be extra careful, it might make sense to reconnect your devices to the proxy after the update.
{
"affected": [],
"aliases": [
"CVE-2026-127139"
],
"database_specific": {
"cwe_ids": [
"CWE-338"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-11-17T13:17:33Z",
"severity": "MODERATE"
},
"details": "pretixSCAN Proxy does not use a secure random generator to generate initialization tokens and API keys for the connection between pretixSCAN devices and the pretixSCAN Proxy. This could allow a skilled attacker with access to at least some of the tokens to predict the value of other tokens more easily.\n\n\n\n\npretixSCAN is usually used on local networks and the level of exposure heavily depends on the structure of that network. If you want to be extra careful, it might make sense to reconnect your devices to the proxy after the update.",
"id": "GHSA-x2hv-fjv4-q826",
"modified": "2026-11-17T15:33:39Z",
"published": "2026-11-17T15:33:39Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-127139"
},
{
"type": "WEB",
"url": "https://pretix.eu/about/en/blog/20261117-release-2026-9-2-pretixscan-wordpress-widget"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:L/AC:H/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:U/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
"type": "CVSS_V4"
}
]
}
Mitigation
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.
No CAPEC attack patterns related to this CWE.