liveBook · Manning

Heartbleed

As explained in Hacking Cryptography

Heartbleed is a memory-disclosure vulnerability in implementations of the TLS heartbeat extension that can return unintended server memory.

Heartbleed is a memory-disclosure vulnerability in TLS heartbeat handling. A normal heartbeat asks a server to echo a stated payload, such as the 12-byte message “good_morning.” The server should return only that payload. section 10.6

The failure follows a simple attack sequence:

  • A malicious client supplies a short payload but claims that it contains thousands of bytes. section 10.6
  • The vulnerable server allocates a response using the claimed length and calls memcpy() without verifying that the input contains that many bytes. section 10.6
  • The response reads beyond the heartbeat input and discloses adjacent server memory, potentially including private keys. section 10.6

The dangerous length mismatch

A request can provide only a few bytes while requesting several thousand bytes in the response. The server then copies from the attacker-controlled pointer for the claimed length, exposing data outside the payload buffer.

How Hacking Cryptography covers it

How deep it goes
Traces the attack through concrete inputs and vulnerable OpenSSL code, while stopping short of remediation implementation details.
Examples
Uses a good_morning echo, an undersized payload with an oversized length, and OpenSSL 1.0.1f source code.
What it assumes
Assumes basic TLS and C/C++ buffer handling, while grounding the failure in a concrete heartbeat exchange.
What you can do after
Diagnose/debug with it by tracing attacker-controlled lengths and checking every copy operation against available buffer bounds.
How it connects
Connects TLS heartbeat handling with buffer overreads, memory safety, memcpy(), OpenSSL, and private-key exposure.

This explainer was generated by Manning's knowledge graph from the text of Hacking Cryptography. The section links point to the parts of the book it draws on.