340
Scope Impact Likelihood
This weakness will generally lead to undefined behavior
and therefore crashes. In the case of overflows involving
loop index variables, the likelihood of infinite loops is also
high.
Integrity Modify Memory
If the value in question is important to data (as opposed
to flow), simple data corruption has occurred. Also, if the
wrap around results in other conditions such as buffer
overflows, further memory corruption may occur.
Confidentiality
Availability
Access Control
Execute Unauthorized Code or Commands
Bypass Protection Mechanism
This weakness can sometimes trigger buffer overflows
which can be used to execute arbitrary code. This is
usually outside the scope of a program's implicit security
policy.
Potential Mitigations
Requirements specification: The choice could be made to use a language that is not susceptible
to these issues.
Phase: Architecture and Design
Provide clear upper and lower bounds on the scale of any protocols designed.
Phase: Implementation
Perform validation on all incremented variables to ensure that they remain within reasonable
bounds.
Demonstrative Examples
Example 1:
The following image processing code allocates a table for images.
Example Language: C (Bad)
img_t table_ptr; /*struct containing img data, 10kB each*/
int num_imgs;
...
num_imgs = get_num_imgs();
table_ptr = (img_t*)malloc(sizeof(img_t)*num_imgs);
...
This code intends to allocate a table of size num_imgs, however as num_imgs grows large, the
calculation determining the size of the list will eventually overflow (CWE-190). This will result in
a very small list to be allocated instead. If the subsequent code operates on the list as if it were
num_imgs long, it may result in many types of out-of-bounds problems (CWE-119).
MemberOf Relationships
This MemberOf relationships table shows additional CWE Catgeories and Views that reference this
weakness as a member. This information is often useful in understanding where a weakness fits
within the context of external information sources.
Nature Type ID Name Page
MemberOf 742 CERT C Secure Coding Standard (2008) Chapter 9 -
Memory Management (MEM)
734 2345
MemberOf 876 CERT C++ Secure Coding Section 08 - Memory
Management (MEM)
868 2376
CWE Version 4.14
CWE-129: Improper Validation of Array Index
CWE-129: Improper Validation of Array Index