Guides / Famous CVEs

Heartbleed (CVE-2014-0160): the OpenSSL memory leak

beginnerUpdated 26 Nov 2026838 words

On 2014-04-07 the OpenSSL project announced that a missing bounds check let any client read up to 64 KB of memory from a server per request, and any server from a client. The memory could hold private TLS keys, session cookies and passwords.

What broke

TLS has a heartbeat extension (RFC 6520): one side sends a small message with a payload, the other side echoes the payload back to show the connection is alive. The message says how long the payload is.

OpenSSL trusted that length field. An attacker sent a heartbeat with a one-byte payload and a claimed length of 64 KB. OpenSSL copied 64 KB starting at the payload into the reply: one byte of payload and the rest whatever happened to be next in memory. The attacker could repeat this as often as they liked. Normal web server logs do not record heartbeat messages.

The OpenSSL advisory: "A missing bounds check in the handling of the TLS heartbeat extension can be used to reveal up to 64k of memory to a connected client or server."

Who was affected

  • Versions: OpenSSL 1.0.1 through 1.0.1f and 1.0.2-beta1. Older branches such as 0.9.8 and 1.0.0 were not affected.
  • Software: every server or client linked against those versions with TLS or DTLS: web servers, mail servers, VPNs, appliances, and also clients that connected to a malicious server.
  • Distributions shipped fixes on the same and following days, for example Debian in DSA-2896 and Red Hat in RHSA-2014:0376 (RHEL 6, openssl-1.0.1e-16.el6_5.7).

The CVE record says the bug allows reading "sensitive information from process memory via crafted packets ... as demonstrated by reading private keys". The CVSS v3.1 base score is 7.5 (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N): anyone, over the network, high confidentiality impact. CISA added it to the KEV catalog on 2022-05-04, eight years after disclosure.

How the attack worked, in plain terms

Think of a service desk that repeats back whatever word you give it. You say "say back the word bird, it has 500 letters". The desk says "bird" and then 496 more letters from the papers on its desk. Each request gives a different slice of memory. With enough requests, the slices can contain the private key of the server certificate, which lets an attacker impersonate the site or decrypt recorded traffic that did not use forward secrecy.

How to check a server today

On any maintained distribution, Heartbleed has been fixed for more than a decade. It still turns up in old appliances, abandoned VMs and containers built from very old base images.

Check the OpenSSL version a system or image uses:

openssl version
dpkg-query -W 'libssl*' 2>/dev/null    # Debian, Ubuntu
rpm -q openssl-libs 2>/dev/null        # RHEL family

A version from 1.0.1 to 1.0.1f is vulnerable unless the distribution patched it; check the distribution advisory. Anything on the 1.0.x branch is out of support anyway.

Statically linked or vendored copies do not show up in the package list. Image scanners such as Trivy report OpenSSL inside images; for appliances, check the vendor advisory.

To test a TLS service you run, the nmap script ssl-heartbleed sends a test heartbeat and reports whether the server answers with extra memory:

nmap -p 443 --script ssl-heartbleed your-server.example

Only run it against hosts you are responsible for.

How it was fixed

OpenSSL 1.0.1g, released with the advisory, added the missing check: a heartbeat whose claimed length is larger than the record is discarded. As a workaround, OpenSSL could be rebuilt with -DOPENSSL_NO_HEARTBEATS.

Patching stopped new leaks but did not undo old ones. Because the attack left no trace, operators had to assume their keys were gone. The full fix was:

  1. update OpenSSL and restart every process that had the library loaded;
  2. create new private keys and certificates, and revoke the old certificates;
  3. invalidate sessions and ask users to change passwords;
  4. rotate any secret that a process with OpenSSL loaded had in memory.

What to take from it

  • A memory disclosure is a secret leak. After any bug that exposes process memory, rotate the keys and credentials that process held. Patching alone is not enough.
  • Restart after library updates. A patched library on disk does nothing for a process that still has the old one loaded. See security updates without downtime.
  • Forward secrecy limits the damage. With ECDHE key exchange, a stolen certificate key cannot decrypt traffic recorded earlier. Current TLS configurations use forward secrecy only.
  • End-of-life software keeps old bugs alive. Most Heartbleed findings today are on systems nobody updates any more.

Sources

Check your servers every day

The agent of Patchbrief reports the packages and settings of a server once a day; the digest names what to fix first.

Start free