A buffer overread occurs when software reads beyond the valid contents or allocated bounds of a memory buffer. It can expose data from adjacent memory that the requester was never allowed to access. section 10.6
Heartbleed heartbeat request
A TLS heartbeat normally echoes a declared 12-byte payload. A malicious client can declare thousands of bytes while supplying only a few; the server then reads beyond the heartbeat input and returns nearby memory, potentially exposing private keys. section 10.6
Prevent buffer overreads by:
- Validating declared lengths against the actual available input before copying or echoing data. section 10.6
- Avoiding unsafe functions such as strcpy(), sprintf(), gets(), and scanf(); prefer alternatives requiring explicit buffer bounds. section 10.6
- Treating memcpy() as bounds-neutral: it copies blindly, so the programmer must establish both source and destination limits. section 10.6
