The product does not properly check inputs that are used for loop conditions, potentially leading to a denial of service or other consequences because of excessive looping.
View on MITREDo not use user-controlled data for loop conditions.
Perform input validation.
No detection method information available for this CWE.
The following example demonstrates the weakness.
In the following C/C++ example the method processMessageFromSocket() will get a message from a socket, placed into a buffer, and will parse the contents of the buffer into a structure that contains the message length and the message body. A for loop is used to copy the message body into a local character string which will be passed to another method for processing.
However, the message length variable (msgLength) from the structure is used as the condition for ending the for loop without validating that msgLength accurately reflects the actual length of the message body (CWE-606). If msgLength indicates a length that is longer than the size of a message body (CWE-130), then this can result in a buffer over-read by reading past the end of the buffer (CWE-126).
CWE-606: Unchecked Input for Loop Condition is a Common Weakness Enumeration (CWE) entry maintained by MITRE. The product does not properly check inputs that are used for loop conditions, potentially leading to a denial of service or other consequences because of excessive looping.
If exploited, CWE-606 (Unchecked Input for Loop Condition) it can compromise Availability, leading to outcomes such as DoS: Resource Consumption (CPU).
Recommended mitigations for CWE-606 include: Do not use user-controlled data for loop conditions. Perform input validation.
A CWE (Common Weakness Enumeration) like CWE-606 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.