This vulnerability occurs when an application fails to properly validate or limit user-supplied values that control loop iterations. Without these checks, malicious input can force the program into an endless or excessively long loop, consuming system resources and leading to denial of service or application instability.
At its core, this weakness allows an attacker to manipulate a program's flow by controlling how many times a loop executes. Common scenarios include using an unexpectedly large integer for a counter, a negative number that bypasses termination logic, or a specially crafted string that causes unexpected parsing behavior within the loop condition. Developers often trust these values from sources like configuration files, APIs, or user inputs without implementing strict bounds checking. To prevent this, always validate and sanitize any external input before it determines loop behavior. Implement explicit limits on maximum iterations, use signed/unsigned integer checks to prevent wrap-around issues, and consider adding timeout mechanisms for processing loops. Treat loop control variables with the same level of distrust as any other user input, as they directly control resource consumption and application availability.
Impact: DoS: Resource Consumption (CPU)
cc
// get message from socket and store into buffer*
c
c
// process message* success = processMessage(message);} return success;}