CWE-674: Uncontrolled Recursion

Export to Word

Description

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

Extended Description

N/A


ThreatScore

Threat Mapped score: 1.8

Industry: Finiancial

Threat priority: P4 - Informational (Low)


Observed Examples (CVEs)

Related Attack Patterns (CAPEC)


Attack TTPs

N/A

Modes of Introduction

Phase Note
Implementation The uncontrolled recursion is often due to an improper or missing conditional

Common Consequences

Potential Mitigations

Applicable Platforms


Demonstrative Examples

Intro: 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.

Body: 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.

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);

Notes

← Back to CWE list