This vulnerability occurs when a program reads a structured data packet or message but fails to properly validate that the declared length field matches the actual amount of data provided.
Attackers exploit this flaw by deliberately sending data where the stated length is incorrect—either longer or shorter than the real payload. This inconsistency tricks the application's parsing logic, often leading to catastrophic security failures like buffer overflows, memory corruption, or the processing of garbage data as if it were legitimate instructions. In practice, an attacker might use a manipulated length field to inject massive amounts of data beyond allocated buffers or to carefully craft input that alters critical application state. The core defense is for developers to always independently calculate or strictly verify data lengths during parsing, never trusting the user-supplied length parameter alone before processing the associated data block.
Impact: Read MemoryModify MemoryVaries by Context
c
// get message from socket and store into buffer*
c
c
// process message* success = processMessage(message);} return success;}