---
title: "CWE-331: Insufficient Entropy"
url: https://radicalnotion.ai/cwe/cwe-331
type: cwe
description: "The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-331: Insufficient Entropy

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

## Description

The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Architecture and Design | - |
| 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 | An attacker could guess the random numbers generated and could gain unauthorized access to a system if the random numbers are used for authentication and authorization. |

## Potential mitigations

### Implementation

Determine the necessary entropy to adequately provide for randomness and predictability. This can be achieved by increasing the number of bits of objects such as keys and seeds.

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

This code generates a unique random identifier for a user's session.

Bad code:

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

### Example 2

The following code uses a statistical PRNG to create a URL for a receipt that remains active for some period of time after a purchase.

Bad code:

```java
String GenerateReceiptURL(String baseUrl) {
    Random ranGen = new Random();
    ranGen.setSeed((new Date()).getTime());
    return(baseUrl + ranGen.nextInt(400000000) + ".html");
}
```

This code uses the Random.nextInt() function to generate "unique" identifiers for the receipt pages it generates. Because Random.nextInt() is a statistical PRNG, it is easy for an attacker to guess the strings it generates. Although the underlying design of the receipt system is also faulty, it would be more secure if it used a random number generator that did not produce predictable receipt identifiers, such as a cryptographic PRNG.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2001-0950 | Insufficiently random data used to generate session tokens using C rand(). Also, for certificate/key generation, uses a source that does not block when entropy is low. |
| CVE-2008-2108 | Chain: insufficient precision (CWE-1339) in random-number generator causes some zero bits to be reliably generated, reducing the amount of entropy (CWE-331) |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-13639 | - | critical | 9.8 | - | No | 2026-09-18 |
| CVE-2026-38447 | - | critical | 9.8 | - | No | 2026-08-03 |
| CVE-2026-34236 | Auth0 PHP SDK Insufficient Entropy in Cookie Encryption | critical | 9.8 | - | No | 2026-04-01 |
| CVE-2025-67504 | WBCE CMS has Weak Random Number Generator in Password Generation Function | critical | 9.8 | - | No | 2025-12-09 |
| CVE-2025-47781 | Rallly Insufficient Password Login Token Entropy Leads to Account Takeover | critical | 9.8 | - | No | 2025-05-14 |
| CVE-2024-36400 | nano-id is unable to generate the correct character set | critical | 9.8 | - | No | 2024-06-04 |
| CVE-2024-25730 | - | critical | 9.8 | - | No | 2024-02-23 |
| CVE-2023-49599 | WWBN AVideo Insufficient Entropy vulnerbaility | critical | 9.8 | - | No | 2024-01-10 |
| CVE-2023-31176 | Insufficient entropy vulnerability could lead to authentication bypass | critical | 9.8 | - | No | 2023-11-30 |
| CVE-2023-4344 | Broadcom RAID Controller web interface is vulnerable to insufficient randomness due to improper use of ssl.rnd to setup CIM connection | critical | 9.8 | - | No | 2023-08-15 |
| CVE-2022-43755 | Rancher: Non-random authentication token | critical | 9.8 | - | No | 2023-02-07 |
| CVE-2022-34294 | - | critical | 9.8 | - | No | 2022-08-15 |

## Related attack patterns (CAPEC)

- [CAPEC-59](https://radicalnotion.ai/capec/capec-59): Session Credential Falsification through Prediction

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-330](https://radicalnotion.ai/cwe/cwe-330) | Use of Insufficiently Random Values |
| Child | [CWE-332](https://radicalnotion.ai/cwe/cwe-332) | Insufficient Entropy in PRNG |
| Child | [CWE-333](https://radicalnotion.ai/cwe/cwe-333) | Improper Handling of Insufficient Entropy in TRNG |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Insufficient Entropy | - | - |
| WASC | Brute Force | 11 | - |
| CERT C Secure Coding | Properly seed pseudorandom number generators | MSC32-C | Exact |

## Frequently asked questions

### What is CWE-331?

The product uses an algorithm or scheme that produces insufficient entropy, leaving patterns or clusters of values that are more likely to occur than others.

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

130 recorded CVEs are attributed to CWE-331, including CVE-2026-13639, CVE-2026-38447 and CVE-2026-34236.

### How do you prevent CWE-331?

Determine the necessary entropy to adequately provide for randomness and predictability. This can be achieved by increasing the number of bits of objects such as keys and seeds.

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

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

### Is CWE-331 actively exploited?

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

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

---

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