Cloned Boy
Professional
- Messages
- 1,016
- Reaction score
- 786
- Points
- 113
The Heartbleed vulnerability (CVE-2014-0160) is a critical vulnerability in the OpenSSL library discovered in 2014. It allows an attacker to read the contents of a server's RAM, which could lead to the leak of sensitive data, including private keys, passwords, and other sensitive information.
Example request (simplified):
If payload_length = 65535 and the actual payload = "A" (1 byte), the server will return "A" + 65534 bytes from memory.
Fix :
Added check that payload_length matches the actual payload length.
Example of using the openssl utility to check for vulnerability:
If the server supported Heartbeat, it could be vulnerable.
The essence of vulnerability
- TLS/SSL Protocol and Heartbeat Extension
- OpenSSL implements the TLS/SSL encryption protocols used to secure Internet connections.
- The Heartbeat extension allows you to check if a remote server is alive by sending a small request and waiting for a response.
- Error processing Heartbeat request
- The vulnerability was in the dtls1_process_heartbeat() (for DTLS) and tls1_process_heartbeat() (for TLS) functions.
- The server did not correctly validate the length (payload_length) in the Heartbeat request.
- An attacker could send a request with a small actual payload (e.g. 1 byte), but specify a large length (up to 64 KB).
- In response, the server copied not only the transmitted data, but also random data from its memory corresponding to the specified length.
Technical details
- Affected OpenSSL versions: 1.0.1 – 1.0.1f (fixed in 1.0.1g).
- Attack type: Read Overflow.
- Possible consequences:
- Server private keys leaked.
- Session interception (cookies, tokens).
- Compromise of user data.
Example request (simplified):
Code:
| type (1B) | payload_length (2B) | payload (N bytes) | padding |
Vulnerability code (before fix)
C:
/* Vulnerable code in OpenSSL (simplified) */
memcpy(bp, pl, payload_length); // Copy payload + data from memory
Fix :
Added check that payload_length matches the actual payload length.
How was the vulnerability exploited?
- The attacker sent a specially crafted Heartbeat request.
- The server responded by including random data from its memory in the response.
- By repeating requests, it was possible to obtain critical information (such as TLS private keys).
Example of using the openssl utility to check for vulnerability:
Bash:
openssl s_client -connect example.com:443 -tlsextdebug 2>&1 | grep "TLS server extension"
Consequences and scale
- Thousands of servers are affected (including large companies like Yahoo, Cloudflare).
- The vulnerability existed for 2 years before being discovered.
- A massive replacement of SSL certificates was required.
Protective measures
- Update OpenSSL to version 1.0.1g or later.
- Disable the Heartbeat extension if you don't need it.
- Replace SSL certificates after a potential leak.
- Use IDS/IPS to detect abnormal Heartbeat requests.