CWE-674: Uncontrolled Recursion

What is CWE-674?

CWE-674 is Uncontrolled Recursion. The flaw arises when the product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack. The database currently holds 226 vulnerabilities mapped to CWE-674 and none of them are in the CISA Known Exploited Vulnerabilities catalog.

Analyzing data...

OWASP Top 10 Rank-
Related CVES (365 days)226
AbstractionClass
Likelihood of exploit-

Vulnerabilities mapped to CWE-674

226 vulnerabilities1955% increase year over year

No data

No vulnerability data in CISA KEV for CWE-674

Official definition

ByMitre CWE

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

Characteristics

Alternate terms

  • Stack Exhaustion

Modes of introduction

  • Implementation: The uncontrolled recursion is often due to an improper or missing conditional

Common consequences

ImpactScopeExplanation
DoS: Resource Consumption (CPU), DoS: Resource Consumption (Memory)AvailabilityResources including CPU, memory, and stack memory could be rapidly consumed or exhausted, eventually leading to an exit or crash.
Read Application DataConfidentialityIn 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.

Risk mitigations

  1. Implementation · Effectiveness: ModerateEnsure that an end condition will be reached under all logic conditions. The end condition may include checking 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.
  2. Implementation · Effectiveness: LimitedIncrease the stack size.Increasing the stack size might only be a temporary measure, since the stack typically is still not very large, and it might remain easy for attackers to cause an out-of-stack fault.

Detection methods

MethodApproachEffectiveness
Automated Static AnalysisAutomated 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

Representative vulnerabilities

Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.