---
title: "CWE-1241: Use of Predictable Algorithm in Random Number Generator"
url: https://radicalnotion.ai/cwe/cwe-1241
type: cwe
description: "The device uses an algorithm that is predictable and generates a pseudo-random number."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-1241: Use of Predictable Algorithm in Random Number Generator

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

## Description

The device uses an algorithm that is predictable and generates a pseudo-random number.

Pseudo-random number generator algorithms are predictable because their registers have a finite number of possible states, which eventually lead to repeating patterns. As a result, pseudo-random number generators (PRNGs) can compromise their randomness or expose their internal state to various attacks, such as reverse engineering or tampering.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Architecture and Design | - |
| Implementation | In many cases, the design originally defines a cryptographically secure random number generator, but is then changed during implementation due to unforeseen constraints. |

## Applicable platforms

**Technologies:** System on Chip (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality | Read Application Data | - |

## Potential mitigations

### Architecture and Design, Implementation

It is highly recommended to use a true random number generator (TRNG) to ensure the security of encryption schemes. Hardware-based TRNGs generate unpredictable, unbiased, and independent random numbers because they employ physical phenomena, e.g., electrical noise, as sources to generate random numbers.

## Demonstrative examples

### Example 1

Suppose a cryptographic function expects random value to be supplied for the crypto algorithm.

During the implementation phase, due to space constraint, a cryptographically secure random-number-generator could not be used, and instead of using a TRNG (True Random Number Generator), a LFSR (Linear Feedback Shift Register) is used to generate a random value. While an LFSR will provide a pseudo-random number, its entropy (measure of randomness) is insufficient for a cryptographic algorithm.

### Example 2

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 |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2023-4695 | Use of Predictable Algorithm in Random Number Generator in pkp/pkp-lib | high | 8.1 | - | No | 2023-09-01 |
| CVE-2021-3689 | Use of Predictable Algorithm in Random Number Generator in yiisoft/yii2 | high | 7.5 | - | No | 2021-08-10 |
| CVE-2026-73576 | - | medium | 6.5 | - | No | 2026-08-13 |
| CVE-2026-82190 | Joomla Extension - j2commerce.com - Predictable/forgeable order access token in J2Store 1.0.0-3.3.2, 4.0.0-4.0.22, 4.1.0-4.1.7 | medium | 6.3 | - | No | 2026-09-15 |
| CVE-2026-6420 | Keylime: keylime: security bypass due to hardcoded tpm quote nonce | medium | 6.3 | - | No | 2026-05-06 |
| CVE-2026-80922 | crypto: qcom-rng - Allow zero as a random number | medium | 5.5 | - | No | 2026-09-09 |
| CVE-2026-82191 | Joomla Extension - j2commerce.com - Unescaped request data reflected into PayPal notify redirect in J2Store 1.0.0-3.3.2, 4.0.0-4.0.22, 4.1.0-4.1.7 | medium | 5.3 | - | No | 2026-09-15 |
| CVE-2025-13079 | Popup Builder - Create highly converting, mobile friendly marketing popups. \<= 4.4.2 - Improper Authorization to Unauthenticated Subscriber Removal via Predictable Tokens | medium | 5.3 | - | No | 2026-02-19 |
| CVE-2021-3692 | Use of Predictable Algorithm in Random Number Generator in yiisoft/yii2 | medium | 5.3 | - | No | 2021-08-10 |
| CVE-2025-32056 | Anti-Theft Bypass for Infotainment ECU | medium | 4.0 | - | No | 2026-01-22 |

## Related attack patterns (CAPEC)

- [CAPEC-97](https://radicalnotion.ai/capec/capec-97): Cryptanalysis

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-330](https://radicalnotion.ai/cwe/cwe-330) | Use of Insufficiently Random Values |

## Frequently asked questions

### What is CWE-1241?

The device uses an algorithm that is predictable and generates a pseudo-random number.

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

10 recorded CVEs are attributed to CWE-1241, including CVE-2023-4695, CVE-2021-3689 and CVE-2026-73576.

### How do you prevent CWE-1241?

It is highly recommended to use a true random number generator (TRNG) to ensure the security of encryption schemes. Hardware-based TRNGs generate unpredictable, unbiased, and independent random numbers because they employ physical phenomena, e.g., electrical noise, as sources to generate random numbers.

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

Exploiting CWE-1241 can lead to: Read Application Data.

### Is CWE-1241 actively exploited?

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

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

---

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