This vulnerability occurs when software attempts to read from or write to a memory location positioned before the official start of a buffer.
This flaw, often called a 'buffer under-read' or 'under-write,' happens when a pointer or index is incorrectly positioned. Common triggers include decrementing a pointer beyond the buffer's first element, performing pointer arithmetic that steps back too far, or directly using a negative index value to access array-like structures. Accessing memory before a buffer's valid range can lead to unpredictable behavior. It may read sensitive data from unrelated parts of memory, corrupt critical program state, or cause an immediate crash, creating opportunities for denial-of-service or information disclosure attacks.
Impact: Read Memory
For an out-of-bounds read, the attacker may have access to sensitive information. If the sensitive information contains system details, such as the current buffer's position in memory, this knowledge can be used to craft further attacks, possibly with more severe consequences.
Impact: Modify MemoryDoS: Crash, Exit, or Restart
Out of bounds memory access will very likely result in the corruption of relevant memory, and perhaps instructions, possibly leading to a crash.
Impact: Modify MemoryExecute Unauthorized Code or Commands
If the corrupted memory can be effectively controlled, it may be possible to execute arbitrary code. If the corrupted memory is data rather than instructions, the system will continue to function with improper changes, possibly in violation of an implicit or explicit policy.
c
// copy input string to a temporary string* char message[length+1]; int index; for (index = 0; index < length; index++) { ``` message[index] = strMessage[index]; } message[index] = '\0';
c
// return string without trailing whitespace* retMessage = message; return retMessage;}
cc