CWE-336: Same Seed in Pseudo-Random Number Generator (PRNG)
A Pseudo-Random Number Generator (PRNG) uses the same seed each time the product is initialized.
View on MITREExtended Description
Given the deterministic nature of PRNGs, using the same seed for each initialization will lead to the same output in the same order. If an attacker can guess (or knows) the seed, then the attacker may be able to determine the random numbers that will be produced from the PRNG.
Technical Details
- Structure
- Simple
Applicable To
Security Consequences
Scope
Impact
Mitigation Strategies
Phase
Description
Do not reuse PRNG seeds. Consider a PRNG that periodically re-seeds itself as needed from a high quality pseudo-random output, such as hardware devices.
Detection Methods
No detection method information available for this CWE.
Code Examples & CVEs
Demonstrative Examples
The following code uses a statistical PRNG to generate account IDs.
Because the program uses the same seed value for every invocation of the PRNG, its values are predictable, making the system vulnerable to attack.
This code attempts to generate a unique random identifier for a user's session.
Because the seed for the PRNG is always the user's ID, the session ID will always be the same. An attacker could thus predict any user's session ID and potentially hijack the session.
Observed CVE Examples (1)
SDK for JavaScript app builder for serverless code uses the same fixed seed for a PRNG, allowing cryptography bypass
View DetailsCWE Relationships
No relationship information available for this CWE.
Frequently Asked Questions
What is CWE-336: Same Seed in Pseudo-Random Number Generator (PRNG)?+
CWE-336: Same Seed in Pseudo-Random Number Generator (PRNG) is a Common Weakness Enumeration (CWE) entry maintained by MITRE. A Pseudo-Random Number Generator (PRNG) uses the same seed each time the product is initialized. Given the deterministic nature of PRNGs, using the same seed for each initialization will lead to the same output in the same order. If an attacker can guess (or knows) the seed, then the attacker may be able to determine the random numbers that will be produced from the PRNG.
What are the security consequences of Same Seed in Pseudo-Random Number Generator (PRNG)?+
If exploited, CWE-336 (Same Seed in Pseudo-Random Number Generator (PRNG)) it can compromise Other and Access Control, leading to outcomes such as Other and Bypass Protection Mechanism.
How do you prevent or mitigate Same Seed in Pseudo-Random Number Generator (PRNG)?+
Recommended mitigations for CWE-336 include: Do not reuse PRNG seeds. Consider a PRNG that periodically re-seeds itself as needed from a high quality pseudo-random output, such as hardware devices.
Which programming languages are affected by Same Seed in Pseudo-Random Number Generator (PRNG)?+
CWE-336 commonly affects Not Language-Specific. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.
What are real-world examples of Same Seed in Pseudo-Random Number Generator (PRNG)?+
MITRE documents real CVEs mapped to CWE-336, including CVE-2022-39218. You can look up the full details of each CVE, including CVSS scores and remediation guidance, on our CVE Lookup tool.
What is the difference between a CWE and a CVE?+
A CWE (Common Weakness Enumeration) like CWE-336 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.