CWE-674: Uncontrolled Recursion

Class Draft Simple

CWE版本: 4.18

更新日期: 2025-09-09

弱点描述

The product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack.

常见后果

影响范围: Availability

技术影响: DoS: Resource Consumption (CPU) DoS: Resource Consumption (Memory)

说明: Resources including CPU, memory, and stack memory could be rapidly consumed or exhausted, eventually leading to an exit or crash.

影响范围: Confidentiality

技术影响: Read Application Data

说明: In some cases, an application's interpreter might kill a process or thread that appears to be consuming too much resources, such as with PHP's memory_limit setting. When the interpreter kills the process/thread, it might report an error containing detailed information such as the application's installation path.

潜在缓解措施

阶段: Implementation

描述: Ensure an end condition will be reached under all logic conditions. The end condition may include testing against the depth of recursion and exiting with an error if the recursion goes too deep. The complexity of the end condition contributes to the effectiveness of this action.

有效性: Moderate

阶段: Implementation

描述: Increase the stack size.

有效性: Limited

检测方法

方法: 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.)

有效性: High

观察示例

参考: CVE-2007-1285

Deeply nested arrays trigger stack exhaustion.

参考: CVE-2007-3409

Self-referencing pointers create infinite loop and resultant stack exhaustion.

参考: CVE-2016-10707

Javascript application accidentally changes input in a way that prevents a recursive call from detecting an exit condition.

参考: CVE-2016-3627

An attempt to recover a corrupted XML file infinite recursion protection counter was not always incremented missing the exit condition.

参考: CVE-2019-15118

USB-audio driver's descriptor code parsing allows unlimited recursion leading to stack exhaustion.

引入模式

阶段 说明
Implementation The uncontrolled recursion is often due to an improper or missing conditional

适用平台

编程语言
Not Language-Specific (Undetermined)

分类映射

分类名称 条目ID 条目名称 映射适配度
OWASP Top Ten 2004 A9 Denial of Service CWE More Specific
Software Fault Patterns SFP13 Unrestricted Consumption -
OMG ASCRM ASCRM-CWE-674 -
关键信息

CWE ID: CWE-674

抽象级别: Class

结构: Simple

状态: Draft

相关弱点
相关攻击模式
CAPEC-230 CAPEC-231