打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Linux命令: 使用dmsetup建立snapshot

########################################################################
# This document provides information could be used to assist the security
# of a server against this vulnerabilities. Don't use what you learn here
# to test/check/attack a server without permission from the server owner.
# 本文档所提供之信息仅供协助提升系统安全以防范该漏洞,请勿作非授权测试或攻击用途.
# 本文檔所提供之信息僅供協助提升系統安全以防範該漏洞,請勿作非授權測試或攻擊用途.
########################################################################

HTTPoxy - Apache CGI Vulnerability

Refs:
https://httpoxy.org/
https://tools.ietf.org/html/rfc3875
https://www.hkcert.org/my_url/en/alert/16071901
https://www.apache.org/security/asf-httpoxy-response.txt
https://www.nginx.com/blog/mitigating-the-httpoxy-vulnerability-with-nginx/

Testing Environment:
  OS Version:     CentOS release 6.8 (Final)
  Apache Version: 2.2.15 (CentOS)

Apache cgi-bin Configuration(/etc/httpd/conf/httpd.conf):
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
AddHandler cgi-script .cgi .sh .pl

For testing, I created a simple testing CGI file with bash shell comand:
# vi /var/www/cgi-bin/httpoxy.sh
------------------------------------------------------------------------
#!/bin/sh
echo "Content-type: text/html"
echo "<html>"
echo "<body>"
echo "HTTP_PROXY: $HTTP_PROXY"
echo "</body>"
echo "</html>"
------------------------------------------------------------------------

Set execute permission for bash shell CGI script file:
# chmod 755 /var/www/cgi-bin/httpoxy.sh

Then try to access this CGI file with curl command, watch the return:
$ curl http://10.10.0.6/cgi-bin/httpoxy.sh
<html>
<body>
HTTP_PROXY:
</body>
</html>


If I try to include extra header in the request:
$ curl -H "Proxy:hacker_server:port" http://10.10.0.6/cgi-bin/httpoxy.sh
<html>
<body>
HTTP_PROXY: hacker_server:port
</body>
</html>


As you can see, the CGI environment variable had been changed !


Open this CGI file with browser, you should see:

(pic:httpoxy-apache-cgi-bash-1.jpg)


Try to modify header:

(pic:httpoxy-apache-cgi-bash-2.jpg)



How to fix ?

Ref: https://www.apache.org/security/asf-httpoxy-response.txt

# vi /etc/httpd/conf/httpd.conf
LoadModule headers_module modules/mod_headers.so
RequestHeader unset Proxy early

Note: Above two lines enabled in the httpd.conf file will remove the "Proxy:" header from all incoming requests, before further processing; So it will mitigate "httpoxy" issues across all of the Apache CGI mechanisms, including PHP(FastCGI/CGI), Perl CGI script, Bash shell CGI script, .., and so on.

Ref: https://httpoxy.org/#fix-now
Example for using this in .htaccess files:
<IfModule mod_headers.c>
   RequestHeader unset Proxy
</IfModule>


# /etc/init.d/httpd restart

Then try to include extra header with curl command:
$ curl -H "Proxy:hacker_server:port" http://10.10.0.6/cgi-bin/httpoxy.sh
<html>
<body>
HTTP_PROXY:
</body>
</html>

You should see the HTTP_PROXY variable is empty now !
















########################################################################
# This document provides information could be used to assist the security
# of a server against this vulnerabilities. Don't use what you learn here
# to test/check/attack a server without permission from the server owner.
# 本文档所提供之信息仅供协助提升系统安全以防范该漏洞,请勿作非授权测试或攻击用途.
# 本文檔所提供之信息僅供協助提升系統安全以防範該漏洞,請勿作非授權測試或攻擊用途.
########################################################################

HTTPoxy - Apache CGI Vulnerability

Refs:
https://httpoxy.org/
https://tools.ietf.org/html/rfc3875
https://www.hkcert.org/my_url/en/alert/16071901
https://www.apache.org/security/asf-httpoxy-response.txt
https://www.nginx.com/blog/mitigating-the-httpoxy-vulnerability-with-nginx/

Testing Environment:
  OS Version:     CentOS release 6.8 (Final)
  Apache Version: 2.2.15 (CentOS)

Apache cgi-bin Configuration(/etc/httpd/conf/httpd.conf):
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
AddHandler cgi-script .cgi .sh .pl

For testing, I created a simple testing CGI file with bash shell comand:
# vi /var/www/cgi-bin/httpoxy.sh
------------------------------------------------------------------------
#!/bin/sh
echo "Content-type: text/html"
echo "<html>"
echo "<body>"
echo "HTTP_PROXY: $HTTP_PROXY"
echo "</body>"
echo "</html>"
------------------------------------------------------------------------

Set execute permission for bash shell CGI script file:
# chmod 755 /var/www/cgi-bin/httpoxy.sh

Then try to access this CGI file with curl command, watch the return:
$ curl http://10.10.0.6/cgi-bin/httpoxy.sh
<html>
<body>
HTTP_PROXY:
</body>
</html>


If I try to include extra header in the request:
$ curl -H "Proxy:hacker_server:port" http://10.10.0.6/cgi-bin/httpoxy.sh
<html>
<body>
HTTP_PROXY: hacker_server:port
</body>
</html>


As you can see, the CGI environment variable had been changed !


Open this CGI file with browser, you should see:

(pic:httpoxy-apache-cgi-bash-1.jpg)


Try to modify header:

(pic:httpoxy-apache-cgi-bash-2.jpg)



How to fix ?

Ref: https://www.apache.org/security/asf-httpoxy-response.txt

# vi /etc/httpd/conf/httpd.conf
LoadModule headers_module modules/mod_headers.so
RequestHeader unset Proxy early

Note: Above two lines enabled in the httpd.conf file will remove the "Proxy:" header from all incoming requests, before further processing; So it will mitigate "httpoxy" issues across all of the Apache CGI mechanisms, including PHP(FastCGI/CGI), Perl CGI script, Bash shell CGI script, .., and so on.

Ref: https://httpoxy.org/#fix-now
Example for using this in .htaccess files:
<IfModule mod_headers.c>
   RequestHeader unset Proxy
</IfModule>


# /etc/init.d/httpd restart

Then try to include extra header with curl command:
$ curl -H "Proxy:hacker_server:port" http://10.10.0.6/cgi-bin/httpoxy.sh
<html>
<body>
HTTP_PROXY:
</body>
</html>

You should see the HTTP_PROXY variable is empty now !
















########################################################################
# This document provides information could be used to assist the security
# of a server against this vulnerabilities. Don't use what you learn here
# to test/check/attack a server without permission from the server owner.
# 本文档所提供之信息仅供协助提升系统安全以防范该漏洞,请勿作非授权测试或攻击用途.
# 本文檔所提供之信息僅供協助提升系統安全以防範該漏洞,請勿作非授權測試或攻擊用途.
########################################################################

HTTPoxy - Apache CGI Vulnerability

Refs:
https://httpoxy.org/
https://tools.ietf.org/html/rfc3875
https://www.hkcert.org/my_url/en/alert/16071901
https://www.apache.org/security/asf-httpoxy-response.txt
https://www.nginx.com/blog/mitigating-the-httpoxy-vulnerability-with-nginx/

Testing Environment:
  OS Version:     CentOS release 6.8 (Final)
  Apache Version: 2.2.15 (CentOS)

Apache cgi-bin Configuration(/etc/httpd/conf/httpd.conf):
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>
AddHandler cgi-script .cgi .sh .pl

For testing, I created a simple testing CGI file with bash shell comand:
# vi /var/www/cgi-bin/httpoxy.sh
------------------------------------------------------------------------
#!/bin/sh
echo "Content-type: text/html"
echo "<html>"
echo "<body>"
echo "HTTP_PROXY: $HTTP_PROXY"
echo "</body>"
echo "</html>"
------------------------------------------------------------------------

Set execute permission for bash shell CGI script file:
# chmod 755 /var/www/cgi-bin/httpoxy.sh

Then try to access this CGI file with curl command, watch the return:
$ curl http://10.10.0.6/cgi-bin/httpoxy.sh
<html>
<body>
HTTP_PROXY:
</body>
</html>


If I try to include extra header in the request:
$ curl -H "Proxy:hacker_server:port" http://10.10.0.6/cgi-bin/httpoxy.sh
<html>
<body>
HTTP_PROXY: hacker_server:port
</body>
</html>


As you can see, the CGI environment variable had been changed !


Open this CGI file with browser, you should see:

(pic:httpoxy-apache-cgi-bash-1.jpg)


Try to modify header:

(pic:httpoxy-apache-cgi-bash-2.jpg)



How to fix ?

Ref: https://www.apache.org/security/asf-httpoxy-response.txt

# vi /etc/httpd/conf/httpd.conf
LoadModule headers_module modules/mod_headers.so
RequestHeader unset Proxy early

Note: Above two lines enabled in the httpd.conf file will remove the "Proxy:" header from all incoming requests, before further processing; So it will mitigate "httpoxy" issues across all of the Apache CGI mechanisms, including PHP(FastCGI/CGI), Perl CGI script, Bash shell CGI script, .., and so on.

Ref: https://httpoxy.org/#fix-now
Example for using this in .htaccess files:
<IfModule mod_headers.c>
   RequestHeader unset Proxy
</IfModule>


# /etc/init.d/httpd restart

Then try to include extra header with curl command:
$ curl -H "Proxy:hacker_server:port" http://10.10.0.6/cgi-bin/httpoxy.sh
<html>
<body>
HTTP_PROXY:
</body>
</html>

You should see the HTTP_PROXY variable is empty now !
















本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
历史学习网站推荐
PHP 、Python 等网站应用惊爆远程代理漏洞:httpoxy
学习Apache
Apache服务器配置安全规范及缺陷(4)
linux Apache CGI 安装配置_Linux/apache_脚本之家
Apache与Tomcat整合实现动静分离与负载均衡的配置实践 ? Hey! Linux.
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服