---
title: "CWE-335: Incorrect Usage of Seeds in Pseudo-Random Number Generator (PRNG)"
url: https://radicalnotion.ai/cwe/cwe-335
type: cwe
description: "The product uses a Pseudo-Random Number Generator (PRNG) but does not correctly manage seeds."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-335: Incorrect Usage of Seeds in Pseudo-Random Number Generator (PRNG)

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

## Description

The product uses a Pseudo-Random Number Generator (PRNG) but does not correctly manage seeds.

PRNGs are deterministic and, while their output appears random, they cannot actually create entropy. They rely on cryptographically secure and unique seeds for entropy so proper seeding is critical to the secure operation of the PRNG.

Management of seeds could be broken down into two main areas:

(1) protecting seeds as cryptographic material (such as a cryptographic key);

(2) whenever possible, using a uniquely generated seed from a cryptographically secure source

PRNGs require a seed as input to generate a stream of numbers that are functionally indistinguishable from random numbers. While the output is, in many cases, sufficient for cryptographic uses, the output of any PRNG is directly determined by the seed provided as input. If the seed can be ascertained by a third party, the entire output of the PRNG can be made known to them. As such, the seed should be kept secret and should ideally not be able to be guessed. For example, the current time may be a poor seed. Knowing the approximate time the PRNG was seeded greatly reduces the possible key space.

Seeds do not necessarily need to be unique, but reusing seeds may open up attacks if the seed is discovered.

## Modes of introduction

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Access Control, Other | Bypass Protection Mechanism, Other | If a PRNG is used incorrectly, such as using the same seed for each initialization or using a predictable seed, then an attacker may be able to easily guess the seed and thus the random numbers. This could lead to unauthorized access to a system if the seed is used for authentication and authorization. |

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

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

Both of these examples use a statistical PRNG seeded with the current value of the system clock to generate a random number:

Bad code:

```java
Random random = new Random(System.currentTimeMillis());
int accountID = random.nextInt();
```

Bad code:

```c
srand(time());
int randNum = rand();
```

An attacker can easily predict the seed used by these PRNGs, and so also predict the stream of random numbers generated. Note these examples also exhibit CWE-338 (Use of Cryptographically Weak PRNG).

### Example 3

This code grabs some random bytes and uses them for a seed in a PRNG, in order to generate a new cryptographic key.

Bad code:

```python
# getting 2 bytes of randomness for the seeding the PRNG
seed = os.urandom(2)
random.seed(a=seed)
key = random.getrandbits(128)
```

Since only 2 bytes are used as a seed, an attacker will only need to guess 2^16 (65,536) values before being able to replicate the state of the PRNG.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2020-7010 | Cloud application on Kubernetes generates passwords using a weak random number generator based on deployment time. |
| CVE-2019-11495 | server uses erlang:now() to seed the PRNG, which results in a small search space for potential random seeds |
| CVE-2018-12520 | Product's PRNG is not seeded for the generation of session IDs |
| CVE-2016-10180 | Router's PIN generation is based on rand(time(0)) seeding. |

## Real CVEs with this weakness (sample of 12 of 35)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2024-36048 | qtnetworkauth: badly seeded PRNG may result in guessable values | critical | 9.8 | - | No | 2024-05-18 |
| CVE-2023-4472 | Cryptographically weak PRNG in Opinio 7.22 | critical | 9.8 | - | No | 2024-02-01 |
| CVE-2012-1577 | - | critical | 9.8 | - | No | 2019-12-10 |
| CVE-2019-11495 | - | critical | 9.8 | - | No | 2019-09-10 |
| CVE-2019-10908 | - | critical | 9.8 | - | No | 2019-04-07 |
| CVE-2017-11519 | - | critical | 9.8 | - | No | 2017-07-21 |
| CVE-2021-41117 | Insecure random number generation | critical | 9.1 | - | No | 2021-10-11 |
| CVE-2018-1426 | - | critical | 9.1 | - | No | 2018-03-22 |
| CVE-2024-27632 | - | high | 8.8 | - | No | 2024-04-08 |
| CVE-2024-35875 | x86/coco: Require seeding RNG with RDRAND on CoCo systems | high | 8.4 | - | No | 2024-05-19 |
| CVE-2024-1579 | Insufficient seeding of random number generator | high | 8.1 | - | No | 2024-04-29 |
| CVE-2016-3735 | - | high | 8.1 | - | No | 2022-01-28 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-330](https://radicalnotion.ai/cwe/cwe-330) | Use of Insufficiently Random Values |
| Child | [CWE-336](https://radicalnotion.ai/cwe/cwe-336) | Same Seed in Pseudo-Random Number Generator (PRNG) |
| Child | [CWE-337](https://radicalnotion.ai/cwe/cwe-337) | Predictable Seed in Pseudo-Random Number Generator (PRNG) |
| Child | [CWE-339](https://radicalnotion.ai/cwe/cwe-339) | Small Seed Space in PRNG |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | PRNG Seed Error | - | - |

## Frequently asked questions

### What is CWE-335?

The product uses a Pseudo-Random Number Generator (PRNG) but does not correctly manage seeds.

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

35 recorded CVEs are attributed to CWE-335, including CVE-2024-36048, CVE-2023-4472 and CVE-2012-1577.

### How is CWE-335 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-335?

Exploiting CWE-335 can lead to: Bypass Protection Mechanism, Other.

### Is CWE-335 actively exploited?

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

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

---

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