Guides / Famous CVEs

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

beginnerUpdated 26 Nov 2026777 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. Neel Mehta of Google Security found the bug.

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, and normal web server logs do not record heartbeat messages.

Each request returned a different slice of memory. With enough requests, the slices could 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.

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

OpenSSL 1.0.1 through 1.0.1f and 1.0.2-beta1 were vulnerable; older branches such as 0.9.8 and 1.0.0 were not. That covered every server or client linked against those versions with TLS or DTLS (web servers, mail servers, VPNs, appliances), including 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 to check a server today

Every maintained distribution fixed Heartbleed in 2014. 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. The whole 1.0.x branch is out of support.

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

After any bug that exposes process memory, rotate the keys and credentials that the process held. A patch does not take them back from the attacker.

A patched library on disk does nothing for a process that still has the old one loaded, so restart services after library updates (security updates without downtime).

With ECDHE key exchange (forward secrecy), a stolen certificate key cannot decrypt traffic recorded earlier. Current TLS configurations use forward secrecy only.

A Heartbleed finding today points at a system that nobody updates any more.

Sources

Check your servers every day

The Vulnpocalypse agent reports the packages and settings of a server once a day, and the digest lists what to fix, most urgent first.

Start free