---
title: "CWE-340: Generation of Predictable Numbers or Identifiers"
url: https://radicalnotion.ai/cwe/cwe-340
type: cwe
description: "The product uses a scheme that generates numbers or identifiers that are more predictable than required."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-340: Generation of Predictable Numbers or Identifiers

- **Abstraction:** Class
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 62
- **Of those, in CISA KEV:** 1
- **New in 2026:** 38
- **CWE catalog version:** 4.21

## Description

The product uses a scheme that generates numbers or identifiers that are more predictable than required.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Architecture and Design | - |
| Implementation | - |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Varies by Context | - |

## 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();
}
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2022-29330 | Product for administering PBX systems uses predictable identifiers and timestamps for filenames (CWE-340) which allows attackers to access files via direct request (CWE-425). |
| CVE-2001-1141 | PRNG allows attackers to use the output of small PRNG requests to determine the internal state information, which could be used by attackers to predict future pseudo-random numbers. |
| CVE-1999-0074 | Listening TCP ports are sequentially allocated, allowing spoofing attacks. |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-118527 | Ivanti Connect Secure Generation of Predictable Numbers or Identifiers Vulnerability | medium | 4.3 | - | Yes | 2026-11-03 |
| CVE-2026-3256 | HTTP::Session versions before 0.54 for Perl defaults to using insecurely generated session ids | critical | 9.8 | - | No | 2026-03-28 |
| CVE-2025-15604 | Amon2 versions before 6.17 for Perl use an insecure random\_string implementation for security functions | critical | 9.8 | - | No | 2026-03-28 |
| CVE-2025-40926 | Plack::Middleware::Session::Simple versions before 0.05 for Perl generates session ids insecurely | critical | 9.8 | - | No | 2026-03-05 |
| CVE-2026-2439 | Concierge::Sessions versions from 0.8.1 before 0.8.5 for Perl generate insecure session ids | critical | 9.8 | - | No | 2026-02-16 |
| CVE-2024-47945 | Predictable Session ID | critical | 9.8 | - | No | 2024-10-15 |
| CVE-2026-75106 | OpnForm Editable Submission Secret Derivation via Empty Hashids Salt | critical | 9.3 | - | No | 2026-08-17 |
| CVE-2026-107242 | - | critical | 9.1 | - | No | 2026-11-10 |
| CVE-2026-9733 | Mojolicious::Plugin::Web::Auth::OAuth2 versions through 0.17 for Perl have an insecure default state parameter | critical | 9.1 | - | No | 2026-06-23 |
| CVE-2026-5081 | Apache::Session::Generate::ModUniqueId versions from 1.54 through 1.94 for Perl session ids are insecure | critical | 9.1 | - | No | 2026-05-06 |
| CVE-2026-5085 | Solstice::Session versions through 1440 for Perl generates session ids insecurely | critical | 9.1 | - | No | 2026-04-13 |
| CVE-2025-40931 | Apache::Session::Generate::MD5 versions through 1.94 for Perl create insecure session id | critical | 9.1 | - | No | 2026-03-05 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-330](https://radicalnotion.ai/cwe/cwe-330) | Use of Insufficiently Random Values |
| Child | [CWE-341](https://radicalnotion.ai/cwe/cwe-341) | Predictable from Observable State |
| Child | [CWE-342](https://radicalnotion.ai/cwe/cwe-342) | Predictable Exact Value from Previous Values |
| Child | [CWE-343](https://radicalnotion.ai/cwe/cwe-343) | Predictable Value Range from Previous Values |
| Can precede | [CWE-384](https://radicalnotion.ai/cwe/cwe-384) | Session Fixation |
| Related | [CWE-61](https://radicalnotion.ai/cwe/cwe-61) | UNIX Symbolic Link (Symlink) Following |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Predictability problems | - | - |
| WASC | Brute Force | 11 | - |

## Frequently asked questions

### What is CWE-340?

The product uses a scheme that generates numbers or identifiers that are more predictable than required.

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

62 recorded CVEs are attributed to CWE-340, including CVE-2026-118527, CVE-2026-3256 and CVE-2025-15604. 1 is listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

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

Exploiting CWE-340 can lead to: Varies by Context.

### Is CWE-340 actively exploited?

Yes. 1 CWE-340 vulnerability is in CISA's KEV catalog of actively exploited flaws, out of 62 recorded CVEs.

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

---

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