關於centos7和centos6中平滑升級nginx到新版本v1.12.1修復CVE-2017-7529漏洞的解決方案
漏洞描述
2017年7月11日,Nginx官方發佈最新的安全公告,在Nginx範圍過濾器中發現了一個安全問題(CVE-2017-7529),通過精心構造的惡意請求可能會導致整數溢出並且不正確處理範圍,從而導致敏感信息泄漏。
當使用Nginx標準模塊時,如果文件頭從緩存返回響應,允許攻擊者獲取緩存文件頭。在某些配置中,緩存文件頭可能包含後端服務器IP地址或其他敏感信息。
此外,如果使用第三方模塊有潛在的可能導致拒絕服務。
影響版本
Nginx 0.5.6-1.13.2
漏洞等級
中危
受影響網站:
安全指數分析中國互聯網共有713651個網站受到影響。
修復建議
1、升級Nginx到最新無漏洞版本,當前1.13.3,1.12.1版本中已修復了這個問題。
2、臨時方案:配置 max_ranges 1;
3、使用百度雲加速WAF防火牆進行防禦。
4、添加網站至安全指數,及時瞭解網站組件突發/0day漏洞。
1.添加nginx官方yum源
# vim /etc/yum.repos.d/nginx.repo
centos7:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1
centos6:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/6/$basearch/ gpgcheck=0 enabled=1
看到有最新的1.12.1版本在yum列表中了
# yum list |grep nginx nginx.x86_64 1:1.10.2-1.el7 @epel nginx-all-modules.noarch 1:1.10.2-1.el7 @epel nginx-filesystem.noarch 1:1.10.2-1.el7 @epel nginx-mod-http-geoip.x86_64 1:1.10.2-1.el7 @epel nginx-mod-http-image-filter.x86_64 1:1.10.2-1.el7 @epel nginx-mod-http-perl.x86_64 1:1.10.2-1.el7 @epel nginx-mod-http-xslt-filter.x86_64 1:1.10.2-1.el7 @epel nginx-mod-mail.x86_64 1:1.10.2-1.el7 @epel nginx-mod-stream.x86_64 1:1.10.2-1.el7 @epel collectd-nginx.x86_64 5.7.1-2.el7 epel munin-nginx.noarch 2.0.33-1.el7 epel nextcloud-nginx.noarch 10.0.4-2.el7 epel nginx.x86_64 1:1.12.1-1.el7.ngx nginx nginx-debug.x86_64 1:1.8.0-1.el7.ngx nginx nginx-debuginfo.x86_64 1:1.12.1-1.el7.ngx nginx nginx-module-geoip.x86_64 1:1.12.1-1.el7.ngx nginx nginx-module-geoip-debuginfo.x86_64 1:1.12.1-1.el7.ngx nginx nginx-module-image-filter.x86_64 1:1.12.1-1.el7.ngx nginx nginx-module-image-filter-debuginfo.x86_64 1:1.12.1-1.el7.ngx nginx nginx-module-njs.x86_64 1:1.12.1.0.1.10-1.el7.ngx nginx nginx-module-njs-debuginfo.x86_64 1:1.12.1.0.1.10-1.el7.ngx nginx nginx-module-perl.x86_64 1:1.12.1-1.el7.ngx nginx nginx-module-perl-debuginfo.x86_64 1:1.12.1-1.el7.ngx nginx nginx-module-xslt.x86_64 1:1.12.1-1.el7.ngx nginx nginx-module-xslt-debuginfo.x86_64 1:1.12.1-1.el7.ngx nginx nginx-nr-agent.noarch 2.0.0-12.el7.ngx nginx owncloud-nginx.noarch 9.1.5-1.el7 epel pcp-pmda-nginx.x86_64 3.11.3-4.el7 base python2-certbot-nginx.noarch 0.14.1-1.el7 epel
2.平滑升級nginx
# yum update nginx -y
可以看到已經成功升級到v1.12.1了
# nginx -v nginx version: nginx/1.12.1
升級以後發現nginx語法檢測無法通過
# nginx -t nginx: [emerg] module "/usr/lib64/nginx/modules/ngx_http_perl_module.so" version 1010002 instead of 1012001 in /usr/share/nginx/modules/mod-http-image-filter.conf:2 nginx: configuration file /etc/nginx/nginx.conf test failed
解決辦法:
vim /etc/nginx/nginx.conf
將這行註釋掉
#include /usr/share/nginx/modules/*.conf;
分析:是因爲modules指向了新的路徑/usr/lib64/nginx/modules
[root@test11_ckmusic_test nginx]# ll total 40 drwxr-xr-x 2 root root 114 Jul 13 10:47 conf.d drwxr-xr-x 2 root root 6 Oct 31 2016 default.d -rw-r--r-- 1 root root 1007 Jul 11 21:50 fastcgi_params -rw-r--r-- 1 root root 2837 Jul 11 21:50 koi-utf -rw-r--r-- 1 root root 2223 Jul 11 21:50 koi-win -rw-r--r-- 1 root root 3957 Jul 11 21:50 mime.types lrwxrwxrwx 1 root root 29 Jul 13 10:47 modules -> ../../usr/lib64/nginx/modules -rw-r--r-- 1 root root 1178 Jul 13 11:12 nginx.conf -rw-r--r-- 1 root root 1979 Jun 19 09:47 nginx.conf.bak -rw-r--r-- 1 root root 643 Jul 11 21:47 nginx.conf.rpmnew -rw-r--r-- 1 root root 636 Jul 11 21:50 scgi_params -rw-r--r-- 1 root root 664 Jul 11 21:50 uwsgi_params -rw-r--r-- 1 root root 3610 Jul 11 21:50 win-utf
3.平滑重啓
# systemctl reload nginx