---
title: "CWE-330: Use of Insufficiently Random Values"
url: https://radicalnotion.ai/cwe/cwe-330
type: cwe
description: "The product uses insufficiently random numbers or values in a security context that depends on unpredictable numbers."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-330: Use of Insufficiently Random Values

- **Abstraction:** Class
- **Structure:** Simple
- **Status:** Stable
- **Likelihood of exploit:** High
- **CVEs with this as primary weakness:** 347
- **Of those, in CISA KEV:** 0
- **New in 2026:** 73
- **CWE catalog version:** 4.21

## Description

The product uses insufficiently random numbers or values in a security context that depends on unpredictable numbers.

## Background

Computers are deterministic machines, and as such are unable to produce true randomness. Pseudo-Random Number Generators (PRNGs) approximate randomness algorithmically, starting with a seed from which subsequent values are calculated. There are two types of PRNGs: statistical and cryptographic. Statistical PRNGs provide useful statistical properties, but their output is highly predictable and forms an easy to reproduce numeric stream that is unsuitable for use in cases where security depends on generated values being unpredictable. Cryptographic PRNGs address this problem by generating output that is more difficult to predict. For a value to be cryptographically secure, it must be impossible or highly improbable for an attacker to distinguish between it and a truly random value.

## Modes of introduction

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

## Applicable platforms

**Languages:** Go (Undetermined), Python (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality, Other | Other | When a protection mechanism relies on random values to restrict access to a sensitive resource, such as a session ID or a seed for generating a cryptographic key, then the resource being protected could be accessed by guessing the ID or key. |
| Access Control, Other | Bypass Protection Mechanism, Other | If product relies on unique, unguessable IDs to identify a resource, an attacker might be able to guess an ID for a resource that is owned by another user. The attacker could then read the resource, or pre-create a resource with the same ID to prevent the legitimate program from properly sending the resource to the intended user. For example, a product might maintain session information in a file whose name is based on a username. An attacker could pre-create this file for a victim user, then set the permissions so that the application cannot generate the session for the victim, preventing the victim from using the application. |
| Access Control | Bypass Protection Mechanism, Gain Privileges or Assume Identity | When an authorization or authentication mechanism relies on random values to restrict access to restricted functionality, such as a session ID or a seed for generating a cryptographic key, then an attacker may access the restricted functionality by guessing the ID or key. |

## Potential mitigations

### Architecture and Design

Use a well-vetted algorithm that is currently considered to be strong by experts in the field, and select well-tested implementations with adequate length seeds.

In general, if a pseudo-random number generator is not advertised as being cryptographically secure, then it is probably a statistical PRNG and should not be used in security-sensitive contexts.

Pseudo-random number generators can produce predictable numbers if the generator is known and the seed can be guessed. A 256-bit seed is a good starting point for producing a "random enough" number.

### Implementation

Consider a PRNG that re-seeds itself as needed from high quality pseudo-random output sources, 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. Consult FIPS 140-2 Annex C ("Approved Random Number Generators").

## Detection methods

### Black Box

Use monitoring tools that examine the software's process as it interacts with the operating system and the network. This technique is useful in cases when source code is unavailable, if the software was not developed by you, or if you want to verify that the build phase did not introduce any new weaknesses. Examples include debuggers that directly attach to the running process; system-call tracing utilities such as truss (Solaris) and strace (Linux); system activity monitors such as FileMon, RegMon, Process Monitor, and other Sysinternals utilities (Windows); and sniffers and protocol analyzers that monitor network traffic.

Attach the monitor to the process and look for library functions that indicate when randomness is being used. Run the process multiple times to see if the seed changes. Look for accesses of devices or equivalent resources that are commonly used for strong (or weak) randomness, such as /dev/urandom on Linux. Look for library or system calls that access predictable information such as process IDs and system time.

### Automated Static Analysis - Binary or Bytecode

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Cost effective for partial coverage:

- Bytecode Weakness Analysis - including disassembler + source code weakness analysis
- Binary Weakness Analysis - including disassembler + source code weakness analysis

Effectiveness: SOAR Partial

### Manual Static Analysis - Binary or Bytecode

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Cost effective for partial coverage:

- Binary / Bytecode disassembler - then use manual analysis for vulnerabilities & anomalies

Effectiveness: SOAR Partial

### Dynamic Analysis with Manual Results Interpretation

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Cost effective for partial coverage:

- Man-in-the-middle attack tool

Effectiveness: SOAR Partial

### Manual Static Analysis - Source Code

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Highly cost effective:

- Focused Manual Spotcheck - Focused manual analysis of source
- Manual Source Code Review (not inspections)

Effectiveness: High

### Automated Static Analysis - Source Code

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Cost effective for partial coverage:

- Source code Weakness Analyzer
- Context-configured Source Code Weakness Analyzer

Effectiveness: SOAR Partial

### Architecture or Design Review

According to SOAR \[REF-1479\], the following detection techniques may be useful:

Highly cost effective:

- Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.)

Effectiveness: High

## Demonstrative examples

### Example 1

This code attempts to generate 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.

### Example 3

The example code is taken from the PRNG inside the buggy OpenPiton SoC of HACK@DAC'21 \[REF-1370\]. The SoC implements a pseudo-random number generator using a Linear Feedback Shift Register (LFSR).

Bad code:

```systemverilog
reg in_sr, entropy16_valid;
reg [15:0] entropy16;

assign entropy16_o = entropy16;
assign entropy16_valid_o = entropy16_valid;

always @ (*)
begin
    in_sr = ^ (poly_i [15:0] & entropy16 [15:0]);
end
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2021-3692 | PHP framework uses mt\_rand() function (Marsenne Twister) when generating tokens |
| CVE-2020-7010 | Cloud application on Kubernetes generates passwords using a weak random number generator based on deployment time. |
| CVE-2009-3278 | Crypto product uses rand() library function to generate a recovery key, making it easier to conduct brute force attacks. |
| CVE-2009-3238 | Random number generator can repeatedly generate the same value. |
| CVE-2009-2367 | Web application generates predictable session IDs, allowing session hijacking. |
| CVE-2009-2158 | Password recovery utility generates a relatively small number of random passwords, simplifying brute force attacks. |
| CVE-2009-0255 | Cryptographic key created with a seed based on the system time. |
| CVE-2008-5162 | Kernel function does not have a good entropy source just after boot. |
| CVE-2008-4905 | Blogging software uses a hard-coded salt when calculating a password hash. |
| CVE-2008-4929 | Bulletin board application uses insufficiently random names for uploaded files, allowing other users to access private files. |
| CVE-2008-3612 | Handheld device uses predictable TCP sequence numbers, allowing spoofing or hijacking of TCP connections. |
| CVE-2008-2433 | Web management console generates session IDs based on the login time, making it easier to conduct session hijacking. |
| CVE-2008-0166 | SSL library uses a weak random number generator that only generates 65,536 unique keys. |
| 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). |
| CVE-2008-2020 | CAPTCHA implementation does not produce enough different images, allowing bypass using a database of all possible checksums. |
| CVE-2008-0087 | DNS client uses predictable DNS transaction IDs, allowing DNS spoofing. |
| CVE-2008-0141 | Application generates passwords that are based on the time of day. |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2023-22601 | Use of Insufficiently Random Values in InHand Networks InRouter | critical | 10.0 | - | No | 2023-01-12 |
| CVE-2019-0007 | Junos OS: vMX series: Predictable IP ID sequence numbers vulnerability | critical | 10.0 | - | No | 2019-01-15 |
| CVE-2026-27637 | FreeScout's Predictable Authentication Token Enables Account Takeover | critical | 9.8 | - | No | 2026-02-25 |
| CVE-2025-4607 | PSW Front-end Login & Registration \<= 1.12 - Insufficiently Random Values to Unauthenticated Account Takeover/Privilege Escalation via customer\_registration Function | critical | 9.8 | - | No | 2025-05-31 |
| CVE-2024-25943 | - | critical | 9.8 | - | No | 2024-06-29 |
| CVE-2024-36389 | MileSight DeviceHub - CWE-330 Use of Insufficiently Random Values | critical | 9.8 | - | No | 2024-06-02 |
| CVE-2024-21495 | Use of Insufficiently Random Values in github.com/greenpau/caddy-security | critical | 9.8 | - | No | 2024-02-17 |
| CVE-2020-27631 | Use of Insufficiently Random Values in Multiple Embedded TCP/IP Stacks | critical | 9.8 | - | No | 2023-10-10 |
| CVE-2020-27630 | Use of Insufficiently Random Values in Multiple Embedded TCP/IP Stacks | critical | 9.8 | - | No | 2023-10-10 |
| CVE-2023-29332 | Microsoft Azure Kubernetes Service Elevation of Privilege Vulnerability | critical | 9.8 | - | No | 2023-09-12 |
| CVE-2022-39216 | Combodo iTop's weak password reset token leads to account takeover | critical | 9.8 | - | No | 2023-03-14 |
| CVE-2021-4248 | kapetan dns Request.cs entropy | critical | 9.8 | - | No | 2022-12-18 |

## Related attack patterns (CAPEC)

- [CAPEC-112](https://radicalnotion.ai/capec/capec-112): Brute Force
- [CAPEC-485](https://radicalnotion.ai/capec/capec-485): Signature Spoofing by Key Recreation
- [CAPEC-59](https://radicalnotion.ai/capec/capec-59): Session Credential Falsification through Prediction

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-693](https://radicalnotion.ai/cwe/cwe-693) | Protection Mechanism Failure |
| Child | [CWE-331](https://radicalnotion.ai/cwe/cwe-331) | Insufficient Entropy |
| Child | [CWE-334](https://radicalnotion.ai/cwe/cwe-334) | Small Space of Random Values |
| Child | [CWE-335](https://radicalnotion.ai/cwe/cwe-335) | Incorrect Usage of Seeds in Pseudo-Random Number Generator (PRNG) |
| Child | [CWE-338](https://radicalnotion.ai/cwe/cwe-338) | Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG) |
| Child | [CWE-340](https://radicalnotion.ai/cwe/cwe-340) | Generation of Predictable Numbers or Identifiers |
| Child | [CWE-344](https://radicalnotion.ai/cwe/cwe-344) | Use of Invariant Value in Dynamically Changing Context |
| Child | [CWE-1204](https://radicalnotion.ai/cwe/cwe-1204) | Generation of Weak Initialization Vector (IV) |
| Child | [CWE-1241](https://radicalnotion.ai/cwe/cwe-1241) | Use of Predictable Algorithm in Random Number Generator |
| Can precede | [CWE-804](https://radicalnotion.ai/cwe/cwe-804) | Guessable CAPTCHA |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Randomness and Predictability | - | - |
| 7 Pernicious Kingdoms | Insecure Randomness | - | - |
| OWASP Top Ten 2004 | Broken Access Control | A2 | CWE More Specific |
| CERT C Secure Coding | Avoid race conditions when using library functions | CON33-C | Imprecise |
| CERT C Secure Coding | Do not use the rand() function for generating pseudorandom numbers | MSC30-C | CWE More Abstract |
| CERT C Secure Coding | Properly seed pseudorandom number generators | MSC32-C | CWE More Abstract |
| WASC | Brute Force | 11 | - |
| WASC | Credential/Session Prediction | 18 | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Generate strong random numbers | MSC02-J | - |
| OpenSSF Secure Coding Guide for Python | Use Sufficiently Random Values | pyscg-0038 | - |
| OWASP Golang Secure Coding Practices Guide | Cryptographic Practices | - | - |

## Frequently asked questions

### What is CWE-330?

The product uses insufficiently random numbers or values in a security context that depends on unpredictable numbers.

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

347 recorded CVEs are attributed to CWE-330, including CVE-2023-22601, CVE-2019-0007 and CVE-2026-27637.

### Is CWE-330 part of the OWASP Top 10?

CWE-330 maps to OWASP Top Ten 2004: Broken Access Control (A2) in the OWASP security taxonomy.

### How do you prevent CWE-330?

Use a well-vetted algorithm that is currently considered to be strong by experts in the field, and select well-tested implementations with adequate length seeds.

### How is CWE-330 detected?

Black Box: Use monitoring tools that examine the software's process as it interacts with the operating system and the network. This technique is useful in cases when source code is unavailable, if the software was not developed by you, or if you want to verify that the build phase did not introduce any new weaknesses. Examples include debuggers that directly attach to the running process; system-call tracing utilities such as truss (Solaris) and strace (Linux); system activity monitors such as FileMon, RegMon, Process Monitor, and other Sysinternals utilities (Windows); and sniffers and protocol analyzers that monitor network traffic.

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

Exploiting CWE-330 can lead to: Other, Bypass Protection Mechanism, Gain Privileges or Assume Identity.

### Is CWE-330 actively exploited?

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

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

---

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