---
title: "CWE-407: Inefficient Algorithmic Complexity"
url: https://radicalnotion.ai/cwe/cwe-407
type: cwe
description: "An algorithm in a product has an inefficient worst-case computational complexity that may be detrimental to system performance and can be triggered by an attacker, typically using crafted manipulations that ensure that the worst case is being reached."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-407: Inefficient Algorithmic Complexity

- **Abstraction:** Class
- **Structure:** Simple
- **Status:** Incomplete
- **Likelihood of exploit:** Low
- **CVEs with this as primary weakness:** 276
- **Of those, in CISA KEV:** 0
- **New in 2026:** 224
- **CWE catalog version:** 4.21

## Description

An algorithm in a product has an inefficient worst-case computational complexity that may be detrimental to system performance and can be triggered by an attacker, typically using crafted manipulations that ensure that the worst case is being reached.

## Alternate terms

- **Quadratic Complexity:** Used when the algorithmic complexity is related to the square of the number of inputs (N^2)

## Modes of introduction

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Availability | DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), DoS: Resource Consumption (Other) | The typical consequence is CPU consumption, but memory consumption and consumption of other resources can also occur. |

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

This example attempts to check if an input string is a "sentence" \[REF-1164\].

Bad code:

```javascript
var test_string = "Bad characters: $@#";
var bad_pattern  = /^(\w+\s?)*$/i;
var result = test_string.search(bad_pattern);
```

Good code:

```javascript
var test_string = "Bad characters: $@#";
var good_pattern  = /^((?=(\w+))\2\s?)*$/i;
var result = test_string.search(good_pattern);
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2021-32617 | C++ library for image metadata has "quadratic complexity" issue with unnecessarily repetitive parsing each time an invalid character is encountered |
| CVE-2020-10735 | Python has "quadratic complexity" issue when converting string to int with many digits in unexpected bases |
| CVE-2020-5243 | server allows ReDOS with crafted User-Agent strings, due to overlapping capture groups that cause excessive backtracking. |
| CVE-2014-1474 | Perl-based email address parser has "quadratic complexity" issue via a string that does not contain a valid address |
| CVE-2003-0244 | CPU consumption via inputs that cause many hash table collisions. |
| CVE-2003-0364 | CPU consumption via inputs that cause many hash table collisions. |
| CVE-2002-1203 | Product performs unnecessary processing before dropping an invalid packet. |
| CVE-2001-1501 | CPU and memory consumption using many wildcards. |
| CVE-2004-2527 | Product allows attackers to cause multiple copies of a program to be loaded more quickly than the program can detect that other copies are running, then exit. This type of error should probably have its own category, where teardown takes more time than initialization. |
| CVE-2006-6931 | Network monitoring system allows remote attackers to cause a denial of service (CPU consumption and detection outage) via crafted network traffic, aka a "backtracking attack." |
| CVE-2006-3380 | Wiki allows remote attackers to cause a denial of service (CPU consumption) by performing a diff between large, crafted pages that trigger the worst case algorithmic complexity. |
| CVE-2006-3379 | Wiki allows remote attackers to cause a denial of service (CPU consumption) by performing a diff between large, crafted pages that trigger the worst case algorithmic complexity. |
| CVE-2005-2506 | OS allows attackers to cause a denial of service (CPU consumption) via crafted Gregorian dates. |
| CVE-2005-1792 | Memory leak by performing actions faster than the software can clear them. |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2024-43485 | .NET and Visual Studio Denial of Service Vulnerability | high | 8.8 | - | No | 2024-10-08 |
| CVE-2024-43484 | .NET, .NET Framework, and Visual Studio Denial of Service Vulnerability | high | 8.8 | - | No | 2024-10-08 |
| CVE-2024-43483 | .NET, .NET Framework, and Visual Studio Denial of Service Vulnerability | high | 8.8 | - | No | 2024-10-08 |
| CVE-2026-134812 | msgpackr before 2.1.4 Inefficient Algorithmic Complexity via UnpackrStream and decodeIter | high | 8.7 | - | No | 2026-11-22 |
| CVE-2026-134366 | pypdf before 7.0.0 Memory Exhaustion via Cross-Reference Streams with Identical Offsets | high | 8.7 | - | No | 2026-11-21 |
| CVE-2026-134164 | probe-image-size before 7.5.0 Denial of Service via EXIF Sub-IFD Traversal | high | 8.7 | - | No | 2026-11-20 |
| CVE-2026-128126 | AIOHTTP: Too many URL-encoded form fields block the event loop | high | 8.7 | - | No | 2026-11-13 |
| CVE-2026-126401 | Fleet before 4.86.2 Unauthenticated DoS via SSO Callback XML Canonicalization | high | 8.7 | - | No | 2026-11-13 |
| CVE-2026-127056 | PapaParse before 5.7.1 Quadratic-Time Parsing DoS via indexOf Scan | high | 8.7 | - | No | 2026-11-12 |
| CVE-2026-124683 | - | high | 8.7 | - | No | 2026-11-09 |
| CVE-2026-123608 | Hickory DNS hickory-proto 0.3.1 before 0.26.1 CPU Exhaustion via BinEncoder Name Compression | high | 8.7 | - | No | 2026-11-08 |
| CVE-2026-123559 | Zebra before 7.0.0 Denial of Service via Quadratic Sighash Computation | high | 8.7 | - | No | 2026-11-08 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-405](https://radicalnotion.ai/cwe/cwe-405) | Asymmetric Resource Consumption (Amplification) |
| Child | [CWE-1333](https://radicalnotion.ai/cwe/cwe-1333) | Inefficient Regular Expression Complexity |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Algorithmic Complexity | - | - |

## Frequently asked questions

### What is CWE-407?

An algorithm in a product has an inefficient worst-case computational complexity that may be detrimental to system performance and can be triggered by an attacker, typically using crafted manipulations that ensure that the worst case is being reached.

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

276 recorded CVEs are attributed to CWE-407, including CVE-2024-43485, CVE-2024-43484 and CVE-2024-43483.

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

Exploiting CWE-407 can lead to: DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory), DoS: Resource Consumption (Other).

### Is CWE-407 actively exploited?

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

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

---

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