心脏滴血漏洞:
心脏滴血漏洞是OpenSSL加密库中的一个严重设计缺陷,它允许攻击者通过发送一个恶意的“心跳”请求,窃取服务器内存64KB(最大)的敏感信息,而且这个过程可以重复进行,无需留下任何痕迹。

漏洞根源:缺乏边界检查
问题的关键在于处理这个“心跳”请求的代码中,缺少了一个至关重要的“边界检查”。

正常的工作流程应该是:

  1. 客户端对服务器说:“我是客户端,我发给你一个单词 ‘Apple’,这个单词的长度是 5 个字节。”

  2. 服务器收到请求,读取请求中声明的长度值 5,然后从内存中准确地拷贝出 5 个字节的数据(也就是 ‘A’, ‘p’, ‘p’, ‘l’, ‘e’)发回给客户端。

  3. 客户端收到 “Apple”,确认连接正常。

存在漏洞的流程(心脏滴血):

  1. 攻击者(恶意客户端) 对服务器说:“我是客户端,我发给你一个单词 ‘Apple’,但这个单词的长度是 500 个字节。”(这里撒谎了! 实际数据只有5字节,却声称长度是500)。

  2. 存在漏洞的服务器代码(memcpy函数)盲目信任了客户端声明的长度值 500,而没有去验证客户端实际发送的数据是否真的有500字节那么长。

  3. 服务器于是从存放心跳数据的内存地址开始,向后拷贝500个字节的内容。它先拷贝了真实的5字节 “Apple”,然后继续拷贝了其后内存地址里的495个字节。

  4. 服务器将这500个字节的数据(包含“Apple” + 495字节的未知内存内容)打包发回给攻击者。


用Nmap检测主机漏洞

nmap -sV --script=ssl-heartbleed [your ip] -p 443

有心脏滴血漏洞的报告:

➜  ~ nmap -sV --script=ssl-heartbleed 111.X.X.53 -p 443
Starting Nmap 7.80 ( https://nmap.org ) at 2020-05-22 12:10 CST
Nmap scan report for 111.X.X.53
Host is up (0.040s latency).

PORT    STATE SERVICE  VERSION
443/tcp open  ssl/http nginx
| ssl-heartbleed:
|   VULNERABLE:
|   The Heartbleed Bug is a serious vulnerability in the popular OpenSSL cryptographic software library. It allows for stealing information intended to be protected by SSL/TLS encryption.
|     State: VULNERABLE
|     Risk factor: High
|       OpenSSL versions 1.0.1 and 1.0.2-beta releases (including 1.0.1f and 1.0.2-beta1) of OpenSSL are affected by the Heartbleed bug. The bug allows for reading memory of systems protected by the vulnerable OpenSSL versions and could allow for disclosure of otherwise encrypted confidential information as well as the encryption keys themselves.
|
|     References:
|       http://www.openssl.org/news/secadv_20140407.txt
|       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160
|_      http://cvedetails.com/cve/2014-0160/

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 16.26 seconds

没有心脏滴血漏洞的报告:

➜  ~ nmap -sV --script=ssl-heartbleed 39.156.69.79 -p 443
Starting Nmap 7.91 ( https://nmap.org ) at 2021-02-13 07:59 CST
Nmap scan report for 39.156.69.79
Host is up (0.0091s latency).

PORT    STATE SERVICE  VERSION
443/tcp open  ssl/http Baidu Front End httpd 1.0.8.18
|_http-server-header: bfe/1.0.8.18

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 37.99 seconds

修复建议

  1. 若发现出现漏洞的服务器,立刻下线,避免其继续暴露敏感信息。
  2. 停止旧版本的SSL服务,升级新版SSL服务。
posted on 2020-05-22 12:15  Mysticbinary  阅读(2302)  评论(0)    收藏  举报