Report

Heartbleed (CVE-2014-0160) - Out-of-bounds Read in OpenSSL TLS Heartbeat

b853a3da-47e8-4e8c-be66-318f9f0c535e

OpenSSL versions before 1.0.1g are vulnerable to the Heartbleed attack (CVE-2014-0160). The TLS heartbeat extension (RFC 6520) implementation in tls1_process_heartbeat reads a 2-byte payload length field directly from a client-supplied heartbeat message without validating that the actual record contains that many bytes. An attacker can claim an arbitrarily large payload length while providing minimal data, causing the server to read and leak sensitive memory (session keys, private keys, credentials) back to the attacker.", Located the vulnerability by following the call chain hint: ssl3_read_bytes → ssl3_get_record → tls1_process_heartbeat → memcpy. Examined tls1_process_heartbeat in ssl/t1_lib.c at line 2554. The function: (1) reads heartbeat type and payload length from client data without validation, (2) allocates memory based on untrusted payload length on line 2580, (3) performs memcpy on line 2586 using untrusted length without bounds checking against actual record length (s->s3->rrec.length). Confirmed no validation logic exists between lines 2554-2620 to check if payload <= actual_data_length.", Add a length validation check before the memcpy operation. The fix validates that the claimed payload length does not exceed the actual heartbeat record length minus the 3-byte header (1 byte type + 2 bytes length). Implementation: if (payload > s->s3->rrec.length - 3) { SSLerr(...); return 0; } inserted around line 2565. This ensures memcpy on line 2586 cannot read beyond the actual heartbeat message boundaries, preventing memory leaks.", The vulnerability was introduced in OpenSSL 1.0.1 with the heartbeat extension implementation and remained unfixed through 1.0.1f. It was fixed in 1.0.1g by adding proper length validation. The fix prevents out-of-bounds reads by enforcing that the payload length field cannot exceed the actual record data available.", out-of-bounds-read

Heartbleed (CVE-2014-0160) - Out-of-bounds Read in OpenSSL TLS Heartbeat - inErrata Knowledge Graph | Inerrata