---
title: "CWE-834: Excessive Iteration"
url: https://radicalnotion.ai/cwe/cwe-834
type: cwe
description: "The product performs an iteration or loop without sufficiently limiting the number of times that the loop is executed."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-834: Excessive Iteration

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

## Description

The product performs an iteration or loop without sufficiently limiting the number of times that the loop is executed.

## Modes of introduction

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability | DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), DoS: Amplification, DoS: Crash, Exit, or Restart | Excessive looping will cause unexpected consumption of resources, such as CPU cycles or memory. The product's operation may slow down, or cause a long time to respond. If limited resources such as memory are consumed for each iteration, the loop may eventually cause a crash or program exit due to exhaustion of resources, such as an out-of-memory error. In many cases, a loop does not need to be infinite in order to cause enough resource consumption to adversely affect the product or its host system; it depends on the amount of resources consumed per iteration. |

## Detection methods

### Dynamic Analysis with Manual Results Interpretation

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

Cost effective for partial coverage:

- Fuzz Tester
- Framework-based Fuzzer
- Forced Path Execution

Effectiveness: SOAR Partial

### Manual Static Analysis - Source Code

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

Cost effective for partial coverage:

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

Effectiveness: SOAR Partial

### Automated Static Analysis - Source Code

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

Highly cost effective:

- Context-configured Source Code Weakness Analyzer

Effectiveness: High

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

In this example a mistake exists in the code where the exit condition contained in flg is never called. This results in the function calling itself over and over again until the stack is exhausted.

Bad code:

```c
void do_something_recursive (int flg)
{
    ... // Do some real work here, but the value of flg is unmodified
    if (flg) { do_something_recursive (flg); }    // flg is never modified so it is always TRUE - this call will continue until the stack explodes
}
int flag = 1; // Set to TRUE
do_something_recursive (flag);
```

Good code:

```c
void do_something_recursive (int flg)
{
    ... // Do some real work here
    // Modify value of flg on done condition
    if (flg) { do_something_recursive (flg); }    // returns when flg changes to 0
}
int flag = 1; // Set to TRUE
do_something_recursive (flag);
```

Note that the only difference between the Good and Bad examples is that the recursion flag will change value and cause the recursive call to return.

### Example 2

For this example, the method isReorderNeeded is part of a bookstore application that determines if a particular book needs to be reordered based on the current inventory count and the rate at which the book is being sold.

Bad code:

```java
public boolean isReorderNeeded(String bookISBN, int rateSold) {

    boolean isReorder = false;

    int minimumCount = 10;
    int days = 0;

    // get inventory count for book
    int inventoryCount = inventory.getIventoryCount(bookISBN);

    // find number of days until inventory count reaches minimum
    while (inventoryCount > minimumCount) {

        inventoryCount = inventoryCount - rateSold;
        days++;
    }

    // if number of days within reorder timeframe

    // set reorder return boolean to true
    if (days > 0 && days < 5) {
        isReorder = true;
    }

    return isReorder;
}
```

Good code:

```java
public boolean isReorderNeeded(String bookISBN, int rateSold) {
    ...

    // validate rateSold variable
    if (rateSold < 1) {
        return isReorder;
    }

    ...
}
```

However, the while loop will become an infinite loop if the rateSold input parameter has a value of zero since the inventoryCount will never fall below the minimumCount. In this case the input parameter should be validated to ensure that a value of zero does not cause an infinite loop, as in the following code.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2011-1027 | Chain: off-by-one error (CWE-193) leads to infinite loop (CWE-835) using invalid hex-encoded characters. |
| CVE-2006-6499 | Chain: web browser crashes due to infinite loop - "bad looping logic \[that relies on\] floating point math \[CWE-1339\] to exit the loop \[CWE-835\]" |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2017-12587 | ImageMagick: Resource exhaustion in ReadPWPImage function in coders\\pwp.c | high | 8.8 | - | No | 2017-08-06 |
| CVE-2026-59644 | MLS hash-ratchet honours arbitrary 32-bit generation counter from sender | high | 8.7 | - | No | 2026-08-03 |
| CVE-2026-64641 | Next.js: Denial of Service in App Router using Server Actions | high | 8.2 | - | No | 2026-07-27 |
| CVE-2024-42071 | ionic: use dev\_consume\_skb\_any outside of napi | high | 7.8 | - | No | 2024-07-29 |
| CVE-2026-16497 | - | high | 7.5 | - | No | 2026-09-08 |
| CVE-2025-67726 | Tornado is Vulnerable to Quadratic DoS via Crafted Multipart Parameters | high | 7.5 | - | No | 2025-12-12 |
| CVE-2025-56571 | Finance.js vulnerable to DoS via the IRR function’s depth parameter | high | 7.5 | - | No | 2025-09-30 |
| CVE-2025-6714 | Incorrect Handling of incomplete data may prevent mongoS from Accepting New Connections | high | 7.5 | - | No | 2025-07-07 |
| CVE-2024-4227 | gSOAP: Vulnerable to specially crafted unencrypted SDC messages | high | 7.5 | - | No | 2025-01-15 |
| CVE-2023-49316 | Phpseclib needs guardrails on large binaryfield integers | high | 7.5 | - | No | 2023-11-27 |
| CVE-2023-5632 | Unconditionally adding an event to the epoll causes excessive CPU consumption | high | 7.5 | - | No | 2023-10-18 |
| CVE-2023-33953 | Denial-of-Service in gRPC | high | 7.5 | - | No | 2023-08-09 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-691](https://radicalnotion.ai/cwe/cwe-691) | Insufficient Control Flow Management |
| Child | [CWE-674](https://radicalnotion.ai/cwe/cwe-674) | Uncontrolled Recursion |
| Child | [CWE-835](https://radicalnotion.ai/cwe/cwe-835) | Loop with Unreachable Exit Condition |
| Child | [CWE-1322](https://radicalnotion.ai/cwe/cwe-1322) | Use of Blocking Code in Single-threaded, Non-blocking Context |
| Related | [CWE-606](https://radicalnotion.ai/cwe/cwe-606) | Unchecked Input for Loop Condition |
| Related | [CWE-1339](https://radicalnotion.ai/cwe/cwe-1339) | Insufficient Precision or Accuracy of a Real Number |

## Frequently asked questions

### What is CWE-834?

The product performs an iteration or loop without sufficiently limiting the number of times that the loop is executed.

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

96 recorded CVEs are attributed to CWE-834, including CVE-2017-12587, CVE-2026-59644 and CVE-2026-64641.

### How is CWE-834 detected?

Dynamic Analysis with Manual Results Interpretation: According to SOAR, the following detection techniques may be useful:

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

Exploiting CWE-834 can lead to: DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), DoS: Amplification, DoS: Crash, Exit, or Restart.

### Is CWE-834 actively exploited?

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

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

---

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