HACKORY
Language · English
← All cases
HACKORY / Real-world cases

Heartbleed: the server that answered more than it was asked

In 2014, a bug in OpenSSL, the component that encrypts a large share of https connections, let anyone read small pieces of a server’s memory: passwords, messages and even private keys.

New here? Try the first lesson without an account

Company or project

OpenSSL

When

Published: 7 Apr 2014

Reference

CVE-2014-0160

Severity and scale

High (CVSS 7.5) · private keys exposed

Real-world cases

The story

OpenSSL is free software that a huge number of servers use to encrypt connections: the padlock of https. It has a feature called heartbeat, with which one end of the connection tells the other “I am still here, repeat this back to me” to check that the connection is alive. On 7 April 2014, it was announced that this heartbeat had a flaw. It was found separately by Neel Mehta of Google Security and by a team at the security company Codenomicon. The bug had existed since March 2012, and it was named Heartbleed.

The term, explained simply

Imagine you say to someone: “repeat the word sun, which has 500 letters”. An attentive person would answer that sun has three. The server, instead, trusted the number: it repeated sun and then kept reading whatever was next to it in memory until it reached 500. That is an out-of-bounds read (or buffer over-read): a program reads beyond the space that belongs to it and hands over data it should not show.

The root cause

A bounds check was missing: the code did not verify that the length announced in the request matched the data that had actually arrived.

What could happen

Each heartbeat could return up to 64 KB of the server’s memory, and it could be repeated. That memory could contain passwords, messages and the private keys of certificates, which make it possible to impersonate the site or decrypt its traffic. The researchers said they could do it against their own services without leaving a trace. NVD rates it 7.5 out of 10 (high).

How it was fixed and how to prevent it

OpenSSL released version 1.0.1g with the missing check. But updating was not enough: each site had to revoke its certificates, create new keys and, where needed, ask people to change their passwords. To prevent bugs like this: always check that a declared length does not exceed the data received, prefer languages and functions that check bounds on their own, and test code automatically with unexpected data (fuzzing). Codenomicon found Heartbleed while improving a security testing tool.

Practice it in Hackory

Sources

Official documents and the researcher’s own write-up. We tell the story, the concept and the defense; there are no steps to repeat the attack.