nginx漏洞分析與升級修復


一 、此次漏洞分析

1 nginx HTTP/2漏洞

[nginx-announce] nginx安全公告(CVE-2018-16843,CVE-2018-16844)
在nginx HTTP / 2實現中發現了兩個安全問題,
漏洞對服務器的影響:
可能會導致過多的內存消耗(CVE-2018-16843)和CPU使用率(CVE-2018-16844)。
影響范圍:
這些問題會影響使用ngx_http_v2_module編譯的nginx(不是默認情況下編譯)如果“listen”指令的“http2”選項是用於配置文件。
影響版本:
這些問題會影響nginx 1.9.5 - 1.15.5。
解決方法:
問題在nginx 1.15.6,1.14.1中得到修復。建議升級到最新穩定版

以上內容參考:
 http://mailman.nginx.org/pipermail/nginx-announce/2018/000220.html

2 ngx_http_mp4_module漏洞

[nginx-announce] nginx安全公告(CVE-2018-16845)
漏洞對服務器的影響:
在ngx_http_mp4_module中發現了一個安全問題,可能是這個問題允許攻擊者在工作進程中導致無限循環,導致攻擊工作進程崩潰,或者可能導致工作進程內存使用特制的mp4文件(CVE-2018-16845)進行披露。
影響范圍:
如果使用ngx_http_mp4_module構建,則該問題僅影響nginx(默認情況下不構建模塊)並使用“mp4”指令配置文件。此外,只有在攻擊時才能進行攻擊,攻擊者能夠觸發特制的mp4文件的處理使用ngx_http_mp4_module。
影響版本:
該問題影響nginx 1.1.3 +,1.0.7 +。
解決方法:
該問題在1.15.6,1.14.4中得到修復。建議升級到最新穩定版

該問題的補丁可以在這里找到:
http://nginx.org/download/patch.2018.mp4.txt
以上內容參考:
http://mailman.nginx.org/pipermail/nginx-announce/2018/000221.html

3 模塊ngx_http_mp4_module介紹

作用:為H.264(一種視頻編碼格式)/AAC(一種音頻編碼格式)文件,主要是以 .mp4、.m4v、和.m4a為擴展名的文件, 提供偽流媒體服務端支持。

二、nginx升級

1 備份原有文件

cp -a /usr/local/nginx /tmp/nginx_back

2 下載並解壓nginx-1.14.1.tar.gz文件

wget http://nginx.org/download/nginx-1.14.1.tar.gz
tar
-xf nginx-1.14.1

3 進入nginx-1.14.1目錄

cd nginx-1.14.1

4 編譯配置

(1)請先使用nginx -V 命令查看原有nginx編譯的選項,

# nginx -V

nginx version: nginx/1.0.15
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_flv_module --add-module=/usr/local/src/nginx-auth-ldap --with-http_realip_module

(2)故保持和原有一樣的編譯配置,根據自己情況具體而定

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module 
--with-http_ssl_module --with-http_gzip_static_module --with-http_flv_module --with-http_realip_module
--with-http_auth_request_module --with-http_auth_request_module --add-module=/usr/local/src/nginx-auth-ldap
--add-module=/usr/local/src/headers-more-nginx-module-master --with-cc-opt=-Wno-error

5 編譯

make

6 備份原來sbin/nginx

cd /usr/local/nginx/sbin/
mv nginx nginx.back

7 復制nginx-1.14.1/objs/nginx到/usr/local/nginx/sbin/

cp nginx-1.14.1/objs/nginx /usr/local/nginx/sbin/

8 升級

cd nginx-1.14.1
make upgrade

輸出如下:

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
sleep 1
test -f /usr/local/nginx/logs/nginx.pid.oldbin
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`

或者輸出為以下內容: 

/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
sleep 1
test -f /usr/local/nginx/logs/nginx.pid.oldbin
make: *** [upgrade] Error 1    

看到 Error 1也不用太在意,已經升級成功

如果nginx是關閉的請情況輸出如下:

/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
make: *** [upgrade] Error 1

9 查看升級是否成功

# /usr/local/nginx/sbin/nginx -v

nginx version: nginx/1.14.1

如果想隱藏版本號,可參考 https://www.cnblogs.com/Sunzz/p/9962891.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM