This vulnerability occurs when software accepts user input to determine a location—like an array index, file position, or memory offset—but fails to properly check if that location is safe and valid before using it.
Many software resources, like arrays in memory or files on disk, are accessed using numerical positions. When an application trusts user-supplied numbers for these positions without rigorous checks, attackers can supply crafted values that point outside the intended boundaries. This can lead directly to severe consequences like reading or corrupting adjacent memory (buffer overflows), forcing the allocation of huge amounts of resources, or causing the application to crash. To prevent this, developers must treat all input that defines a position as untrusted. Always validate that the specified index or offset falls within the exact, current bounds of the target resource before any access is performed. Implementing strict range checking is a critical first line of defense to ensure the software only interacts with authorized sections of data.
Impact: Varies by Context
Strategy: Input Validation
Effectiveness: High
/* capture the sizes of all messages / int getsizes(int sock, int count, int *sizes) { ``` ... char buf[BUFFER_SIZE]; int ok; int num, size;
c
// continue read from socket until buf only contains '.'* if (DOTLINE(buf)) ``` break; else if (sscanf(buf, "%d %d", &num, &size) == 2) sizes[num - 1] = size; } ... }
/* capture the sizes of all messages / int getsizes(int sock, int count, int *sizes) { ``` ... char buf[BUFFER_SIZE]; int ok; int num, size;
c
// continue read from socket until buf only contains '.'* if (DOTLINE(buf)) ``` break; else if (sscanf(buf, "%d %d", &num, &size) == 2) { if (num > 0 && num <= (unsigned)count) sizes[num - 1] = size; else
c// Method called from servlet to obtain product information* public String displayProductSummary(int index) {
java
// Method called from servlet to obtain product information* public String displayProductSummary(int index) {
java
javac