Sven Erik Matzen

Software Architect | Cloud & Security Expert | AI-enabled Solutions

The Heart That Tells Too Much: Heartbleed and the Lesson of One Missing Length Check

IT Security · 2026-11-21

EU label: fully AI-generated content Fully AI-generated article (no prior review).

🎧 Listen to this article

The Hook: A Heartbeat That Lies

Imagine a phone call where you ask in between: "Are you still there? Say 'apple', that's five letters." The other person answers "apple," and you know the line is up. Now imagine you say: "Say 'apple', that's 500 letters" – and the other person dutifully replies "apple," followed by 495 characters of whatever else is going through their head at the moment: notes, passwords, snippets of other callers' conversations.

That is exactly how Heartbleed worked. On April 7, 2014, vulnerability CVE-2014-0160 in OpenSSL became public – the cryptographic library that at the time secured a large share of encrypted connections on the web. With a manipulated "heartbeat" message, an attacker could coax memory contents out of a vulnerable server – according to US-CERT alert TA14-098A in chunks of 64k per request, repeatable as often as desired. That memory could contain private keys, usernames and passwords, and protected content.

Heartbleed is not an exotic attack. It is a single missing length check. That is precisely why it is worth a closer look: the case shows how a tiny programming error, an underfunded open-source project, and an incomplete response process interact.


Part 1: What a Heartbeat in TLS Actually Is

The Heartbeat Extension is specified in RFC 6520 (February 2012, authors: Robin Seggelmann, Michael Tüxen, and Michael Glenn Williams). Its purpose according to the abstract: a keep-alive function for TLS and DTLS without having to renegotiate the connection; for DTLS it also serves as the basis for path MTU discovery.

A HeartbeatMessage consists of four fields:

Field Size Meaning
type 1 byte heartbeat_request (1) or heartbeat_response (2)
payload_length 2 bytes stated length of the payload
payload variable arbitrary content that is echoed back in the response
padding at least 16 bytes random content the receiver must ignore

The total length must not exceed 2^14 bytes (or the negotiated max_fragment_length). And – this is the decisive sentence – the RFC mandates: if payload_length is too large, the received message must be discarded silently.

So the specification had anticipated the problem. The implementation did not comply.


Part 2: The Bug – A Field That Was Believed

OpenSSL took the payload_length field at its word. Instead of checking whether the stated length matched the amount of data actually received, the vulnerable version copied as many bytes into the response as the sender had claimed. Because the field is 16 bits wide, an attacker could request up to about 64 KB while sending almost nothing. The rest of the response came from the server process's memory. Technically, this is a heap buffer over-read: not writing into foreign memory, but unauthorized reading.

The timeline according to heartbleed.com and Durumeric et al. (where the two sources differ, this is noted):

Date Event
December 31, 2011 Heartbeat code is added to OpenSSL
February 2012 RFC 6520 is published
March 14, 2012 OpenSSL 1.0.1 is released – the first vulnerable release
March 21, 2014 Neel Mehta (Google Security) discovers the bug (according to Durumeric et al.)
April 2/3, 2014 Codenomicon discovers it independently (April 2 according to Durumeric et al., April 3 according to heartbleed.com)
April 7, 2014 OpenSSL 1.0.1g and advisory, publication of heartbleed.com

Vulnerable were OpenSSL 1.0.1 through 1.0.1f inclusive and, according to US-CERT, the beta 1.0.2-beta. The older branches 1.0.0 and 0.9.8 were not affected according to heartbleed.com – the Heartbeat Extension only arrived with 1.0.1. So the bug sat in shipped software for a good two years.

Two properties made Heartbleed particularly nasty. First: according to heartbleed.com, exploitation left no conspicuous traces in the logs – the team states that it attacked itself from outside without leaving a trace. Second: the 64 KB limit applied only per heartbeat. An attacker could send any number of requests and thus obtain secrets piece by piece.


Part 3: How Big Was the Damage? The Measurement by Durumeric et al.

The most thorough empirical analysis is the paper "The Matter of Heartbleed" by Zakir Durumeric, James Kasten, David Adrian, J. Alex Halderman, Michael Bailey, Frank Li, Nicholas Weaver, Johanna Amann, Jethro Beekman, Mathias Payer, and Vern Paxson (IMC 2014, Vancouver). The authors analyzed Internet-wide scans, network traces from several institutions, and a notification campaign.

The key findings:

  • Initial situation: An estimated 24–55% of HTTPS servers in the Alexa Top 1 Million were initially vulnerable. The wide range arises because it could not be measured directly before disclosure; the values are the lower and upper bounds of an estimate.
  • Patching speed: Two days after disclosure, about 11% of HTTPS sites in the Alexa Top 1 Million were still vulnerable. The 100 most popular sites were fully patched within 48 hours.
  • Plateau: Patching leveled off after about two weeks. Almost two months after disclosure, around 3% of Alexa Top 1M HTTPS sites were still vulnerable.
  • No evidence of exploitation before April 7: In the traces examined, the authors found no signs of attacks before disclosure – with the caveat that their data covered only certain networks and time periods.
  • Attacks afterward: After disclosure, they recorded exploit attempts from almost 700 sources, beginning less than 24 hours after disclosure.

The last point deserves attention: in the data examined, the attacks began only after disclosure – within less than 24 hours. Earlier exploitation elsewhere cannot be ruled out on this basis, however. Those who patched on the first day significantly reduced the window for attackers; replacing the key was still necessary.


Part 4: Patching Is Not Enough – The Problem of Keys

A patch closes the hole, but it does not undo anything. If a server's private TLS key has already been read out, an attacker can impersonate that server even after the patch. US-CERT therefore recommended treating all keys generated with a vulnerable version as compromised and regenerating and deploying them after the patch.

This is exactly where the measurement revealed a large gap between recommendation and practice:

  • Less than a quarter of Alexa Top 1M sites replaced their certificate in the week after disclosure.
  • Of the sites that were still vulnerable 48 hours after disclosure, only 10% replaced their certificate within the following month – and of those, 14% kept using the same private key.

A new certificate with an old key is practically worthless: whoever stole the key still has it.

A second US-CERT recommendation is more subtle: Perfect Forward Secrecy. With key exchange methods that provide forward secrecy, the long-term private key is not sufficient to decrypt previously recorded traffic after the fact. You know the principle from The Key That Dies After Every Message: The Signal Protocol, the Double Ratchet, and the Art of End-to-End Encryption: keys that are discarded after use limit the damage of a later theft.


Part 5: A Surprisingly Effective Tool – Email

About three weeks after disclosure, Durumeric et al. ran an experiment: via 4,648 abuse contacts they notified the operators of more than 200,000 still-vulnerable hosts (the paper's abstract mentions about 150,000) – but in two randomly assigned groups notified at different times. This allowed them to measure whether notification had an effect.

The result: notified operators patched 47% more often than the not-yet-notified comparison group. The authors themselves called this surprisingly high.

The lesson is unspectacular but practical: many systems do not stay unpatched out of defiance, but because nobody knows they exist or are affected. A targeted, concrete notification ("your host X is vulnerable") has a measurable effect.


Part 6: The Real Cause – Critical Infrastructure Without a Budget

Heartbleed drew attention to an uncomfortable question: who actually pays for the software on which Internet security rests? According to the Wikipedia article on the Core Infrastructure Initiative (based on a BuzzFeed report from April 2014), the OpenSSL project received only about US$2,000 in donations per year at the time, and only one person, Stephen Henson, worked on it full-time.

The response came quickly. On April 24, 2014, the Linux Foundation announced the Core Infrastructure Initiative (CII). According to Wikipedia, the participating companies each pledged US$100,000 per year for three years, resulting in an initial pool of almost US$4 million. In its press release of May 29, 2014, the Linux Foundation named the first funded projects: Network Time Protocol, OpenSSH, and OpenSSL; OpenSSL was to receive funds for two full-time core developers, and the Open Crypto Audit Project money for a security audit of OpenSSL. The CII was later superseded by the Open Source Security Foundation (OpenSSF).

You may know the pattern from The Backdoor at the Heart of Linux: The XZ Attack and the Anatomy of a Supply-Chain Compromise: a widely used library carried by very few people. With Heartbleed it was a bug, with XZ a deliberate attack – the structural weakness is related.


Part 7: What Heartbleed Teaches About Bug Classes

Heartbleed is a textbook example of a memory safety bug: a C program reads beyond the boundary of a buffer because the language does not prevent it. In memory-safe languages, a read beyond the buffer boundary would typically abort with a runtime error via a bounds check instead of silently returning foreign data. However, they do not automatically prevent logic errors such as returning uncleared, reused buffers. Why this bug class is so dominant is covered in The Bug That Stops Being Created: Memory Safety and the Mathematics of Vulnerability Half-Life.

I am of the opinion that three levels of lessons can be distinguished:

Level What went wrong Countermeasure
Code A length field from the network was trusted Check inputs against actual sizes; fuzzing; memory-safe languages
Operations Patches yes, key rotation often not Incident playbook: patch, new key, new certificate, revocation, password changes if needed
Ecosystem Critical library without funding Inventory dependencies, support critical projects

It is noteworthy that Codenomicon found the bug while improving the SafeGuard feature of its testing tool Defensics – that is, through systematic, automated testing of protocol implementations.


The Central Takeaway

  1. Do not trust any length field that comes from outside. Check every stated length against the amount of data actually received. RFC 6520 required exactly that; the vulnerable implementation did not do it.
  2. A patch is not the end of an incident. If secrets may have leaked, key rotation, new certificates, and revocation are part of the response – with a new private key, not just a new certificate.
  3. Forward secrecy limits the damage. It protects previously recorded traffic if the long-term key is compromised later – but not against impersonation with the stolen key or against data leaked directly from memory.
  4. Notification works. In the study by Durumeric et al., targeted notification increased the patch rate by 47% compared with the not-yet-notified comparison group.
  5. Know your dependencies. I am of the opinion that an up-to-date inventory (such as an SBOM) can shorten the question "Are we affected?" from days to minutes.

A Question to Reflect On

Which library in your systems would – if a Heartbleed-like vulnerability in it were published tomorrow – hit the most of your services at once, and would you know within an hour everywhere it runs?


Cross-References in the Vault


Fact Check

55 claims were checked (34 hard facts, 2 quotes, 5 source attributions, 14 synthesis claims); 7 were corrected or weakened, 2 marked as personal assessment. The most important corrections:

  • The author order of the IMC paper was wrong and was corrected according to the title block (Durumeric, Kasten, Adrian, Halderman, Bailey, Li, Weaver, Amann, Beekman, Payer, Paxson).
  • The timeline named only Codenomicon; Neel Mehta's earlier discovery (March 21, 2014) and the differing dates for Codenomicon's find (April 2 vs. 3) were added.
  • The claim that disclosure itself created the attack window was weakened: it holds only for the networks and time periods examined.

Automated AI check against primary sources; no human expert review.


Sources and Further Reading

  1. Durumeric, Z., Kasten, J., Adrian, D., Halderman, J. A., Bailey, M., Li, F., Weaver, N., Amann, J., Beekman, J., Payer, M., Paxson, V.: The Matter of Heartbleed. Proceedings of the Internet Measurement Conference (IMC '14), Vancouver, 2014. https://faculty.cc.gatech.edu/~mbailey/publications/imc14-heartbleed.pdf
  2. Seggelmann, R., Tuexen, M., Williams, M.: Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS) Heartbeat Extension. RFC 6520, IETF, February 2012. https://datatracker.ietf.org/doc/html/rfc6520
  3. Codenomicon / Synopsys: The Heartbleed Bug. https://heartbleed.com/
  4. US-CERT / CISA: Alert TA14-098A – OpenSSL 'Heartbleed' vulnerability (CVE-2014-0160). https://www.cisa.gov/ncas/alerts/TA14-098A
  5. The Linux Foundation: The Linux Foundation's Core Infrastructure Initiative Announces New Backers, First Projects to Receive Support and Advisory Board Members, press release, May 29, 2014. https://www.linuxfoundation.org/press/press-release/the-linux-foundations-core-infrastructure-initiative-announces-new-backers-first-projects-to-receive-support-and-advisory-board-members
  6. Wikipedia: Core Infrastructure Initiative. https://en.wikipedia.org/wiki/Core_Infrastructure_Initiative

← All articles