---
title: "CWE-606: Unchecked Input for Loop Condition"
url: https://radicalnotion.ai/cwe/cwe-606
type: cwe
description: "The product does not properly check inputs that are used for loop conditions, potentially leading to a denial of service or other consequences because of excessive looping."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-606: Unchecked Input for Loop Condition

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

## Description

The product does not properly check inputs that are used for loop conditions, potentially leading to a denial of service or other consequences because of excessive looping.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability | DoS: Resource Consumption (CPU) | - |

## Potential mitigations

### Implementation

Do not use user-controlled data for loop conditions.

### Implementation

Perform input validation.

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

Effectiveness: High

## Demonstrative examples

### Example 1

The following example demonstrates the weakness.

Bad code:

```c
void iterate(int n){
    int i;
    for (i = 0; i < n; i++){
        foo();
    }
}
void iterateFoo()
{
    unsigned int num;
    scanf("%u",&num);
    iterate(num);
}
```

### Example 2

In the following C/C++ example, the method processMessageFromSocket() will get a message from a socket, save the message into a buffer, and place the contents of the buffer into a structure that contains the message length and the message body. Then a for loop is used to copy the message body into a local character string, which will be passed to another method for processing.

Bad code:

```c
int processMessageFromSocket(int socket) {
    // initialize variable to represent the failure case by default
    int success = -1;
    char buffer[BUFFER_SIZE];
    char message[MESSAGE_SIZE];

    // get message from socket and store into buffer
    // for clarity of this example, ignore the possibility that buffer > BUFFER_SIZE
    if (getMessage(socket, buffer, BUFFER_SIZE) > 0) {

        // place contents of the buffer into message structure
        ExMessage *msg = recastBuffer(buffer);

        // copy message body into string for processing
        int index;
        for (index = 0; index < msg->msgLength; index++) {
            message[index] = msg->msgBody[index];
        }
        message[index] = '\0';
        // process message
        success = processMessage(message);
    }
    return success;
}
```

However, the message length variable (msgLength) from the structure is used as the condition for ending the for loop without validating that msgLength accurately reflects the actual length of the message body (CWE-606). If msgLength indicates a length that is longer than the size of a message body (CWE-130), then this can result in a buffer over-read by reading past the end of the buffer (CWE-126).

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2025-32399 | Chain: library for implementing Profinet devices does not check an input for a loop condition (CWE-606), allowing an infinite loop (CWE-835) via a crafted RPC packet |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-13761 | Pega Platform versions 7.1.0 through 25.1.2 are affected by an improper validation of inputs that are used for loop conditions, potentially leading to a denial of service or other consequences because of excessive looping. | high | 8.8 | - | No | 2026-08-28 |
| CVE-2026-128342 | ExcelJS through 4.4.0 Denial of Service via Oversized Worksheet sheetId | high | 8.7 | - | No | 2026-11-13 |
| CVE-2026-128343 | ExcelJS through 4.4.0 Denial of Service via Oversized Row Number | high | 8.7 | - | No | 2026-11-13 |
| CVE-2024-34486 | Ryu Infinite Loop vulnerability | high | 8.7 | - | No | 2024-05-05 |
| CVE-2026-20301 | Cisco IOS Software and IOS XE Software Extensible Messaging Client Protocol Denial of Service Vulnerability | high | 8.6 | - | No | 2026-08-05 |
| CVE-2026-85730 | smol-toml: Denial of Service via malformed TOML documents | high | 8.2 | - | No | 2026-09-04 |
| CVE-2024-46862 | ASoC: Intel: soc-acpi-intel-mtl-match: add missing empty item | high | 8.0 | - | No | 2024-09-27 |
| CVE-2026-27689 | Denial of service (DOS) in SAP Supply Chain Management | high | 7.7 | - | No | 2026-03-10 |
| CVE-2026-23689 | Denial of service (DOS) in SAP Supply Chain Management | high | 7.7 | - | No | 2026-02-10 |
| CVE-2026-107569 | Unchecked Input for Loop Condition in hMailServer | high | 7.5 | - | No | 2026-10-19 |
| CVE-2026-62901 | .NET Denial of Service Vulnerability | high | 7.5 | - | No | 2026-08-11 |
| CVE-2026-1519 | Excessive NSEC3 iterations cause high CPU load during insecure delegation validation | high | 7.5 | - | No | 2026-03-25 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-1284](https://radicalnotion.ai/cwe/cwe-1284) | Improper Validation of Specified Quantity in Input |
| Can precede | [CWE-834](https://radicalnotion.ai/cwe/cwe-834) | Excessive Iteration |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| Software Fault Patterns | Tainted input to variable | SFP25 | - |
| OMG ASCSM | - | ASCSM-CWE-606 | - |

## Frequently asked questions

### What is CWE-606?

The product does not properly check inputs that are used for loop conditions, potentially leading to a denial of service or other consequences because of excessive looping.

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

60 recorded CVEs are attributed to CWE-606, including CVE-2026-13761, CVE-2026-128342 and CVE-2026-128343.

### How do you prevent CWE-606?

Do not use user-controlled data for loop conditions.

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

Exploiting CWE-606 can lead to: DoS: Resource Consumption (CPU).

### Is CWE-606 actively exploited?

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

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

---

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