---
title: "CWE-336: Same Seed in Pseudo-Random Number Generator (PRNG)"
url: https://radicalnotion.ai/cwe/cwe-336
type: cwe
description: "The product uses a Pseudo-Random Number Generator (PRNG) that uses the same seed each time the product is initialized."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-336: Same Seed in Pseudo-Random Number Generator (PRNG)

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 3
- **Of those, in CISA KEV:** 0
- **New in 2026:** 2
- **CWE catalog version:** 4.21

## Description

The product uses a Pseudo-Random Number Generator (PRNG) that uses the same seed each time the product is initialized.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | REALIZATION: This weakness is caused during implementation of an architectural security tactic. |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other, Access Control | Varies by Context, Bypass Protection Mechanism | 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 they may be able to determine the random numbers that will be produced from the PRNG. |

## Potential mitigations

### Architecture and Design

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.

### Architecture and Design, Requirements (Libraries or Frameworks)

Use products or modules that conform to FIPS 140-2 \[REF-267\] to avoid obvious entropy problems, or use the more recent FIPS 140-3 \[REF-1192\] if possible.

## 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

## Demonstrative examples

### Example 1

The following code uses a statistical PRNG to generate account IDs.

Bad code:

```java
private static final long SEED = 1234567890;
public int generateAccountID() {
    Random random = new Random(SEED);
    return random.nextInt();
}
```

Because the program uses the same seed value for every invocation of the PRNG, its values are predictable, making the system vulnerable to attack.

### Example 2

This code attempts to generate a unique random identifier for a user's session.

Bad code:

```php
function generateSessionID($userID){
    srand($userID);
    return rand();
}
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2022-39218 | SDK for JavaScript app builder for serverless code uses the same fixed seed for a PRNG, allowing cryptography bypass |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-24044 | ESS Community Helm Chart has a weak server key generation method | critical | 9.2 | - | No | 2026-02-12 |
| CVE-2026-6924 | Weak entropy initialization in Silicon Labs Matter SiWx917 TinyCrypt path | high | 8.7 | - | No | 2026-07-23 |
| CVE-2021-42810 | Safenet Authentication Service Remote Desktop Gateway prior to 2.0.3 may allow privilege escilation to authenticated users | high | 7.8 | - | No | 2022-01-19 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-335](https://radicalnotion.ai/cwe/cwe-335) | Incorrect Usage of Seeds in Pseudo-Random Number Generator (PRNG) |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Same Seed in PRNG | - | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Generate strong random numbers | MSC02-J | - |

## Frequently asked questions

### What is CWE-336?

The product uses a Pseudo-Random Number Generator (PRNG) that uses the same seed each time the product is initialized.

### What CVEs are caused by CWE-336?

3 recorded CVEs are attributed to CWE-336, including CVE-2026-24044, CVE-2026-6924 and CVE-2021-42810.

### How do you prevent CWE-336?

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.

### How is CWE-336 detected?

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.)

### What are the consequences of CWE-336?

Exploiting CWE-336 can lead to: Varies by Context, Bypass Protection Mechanism.

### Is CWE-336 actively exploited?

3 recorded CVEs are caused by CWE-336; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/336.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-336). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
