最近收到安所有門的安全掃描報告。內容以下:html
nginx 安全漏洞(CVE-2018-16845) 中危 nginx類 nginx是由俄羅斯的程序設計師Igor Sysoev所開發的一款輕量級Web服務器/反向代理服務器及電子郵件(IMAP/POP3)代理服務器。 Nginx 1.15.5及以前的版本和1.14.1版本中的ngx_http_mp4_module組件存在內存泄露漏洞,該漏洞源於程序沒有正確處理MP4文件。遠程攻擊者可利用該漏洞獲取敏感信息或形成拒絕服務。 廠商補丁: 目前廠商已發佈升級補丁以修復漏洞,補丁獲取連接: http://mailman.nginx.org/pipermail/nginx-announce/2018/000221.html
一個高危漏洞,趕忙網上查詢下資料這準備修復。nginx
去補丁地址獲取補丁,能夠看到這個內容:安全
Patch for the issue can be found here: http://nginx.org/download/patch.2018.mp4.txt
點擊獲取查看補丁信息:服務器
--- src/http/modules/ngx_http_mp4_module.c +++ src/http/modules/ngx_http_mp4_module.c @@ -942,6 +942,13 @@ ngx_http_mp4_read_atom(ngx_http_mp4_file atom_size = ngx_mp4_get_64value(atom_header + 8); atom_header_size = sizeof(ngx_mp4_atom_header64_t); + if (atom_size < sizeof(ngx_mp4_atom_header64_t)) { + ngx_log_error(NGX_LOG_ERR, mp4->file.log, 0, + "\"%s\" mp4 atom is too small:%uL", + mp4->file.name.data, atom_size); + return NGX_ERROR; + } + } else { ngx_log_error(NGX_LOG_ERR, mp4->file.log, 0, "\"%s\" mp4 atom is too small:%uL",
第一行和第二行表示漏洞發生的文須要修改的文件
第三行表示修復前的漏洞位置在942行的後6行,942,13爲補丁添加的位置到第13行
真正須要添加的部分爲+
號部分,複製定漏洞文件須要刪除+
號(+
表示新增)
接着去nginx的啓動文件夾,查看編譯參數信息:app
./nginx -V
獲得以下信息:ui
nginx version: nginx/1.11.5 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) built with OpenSSL 1.0.1c 10 May 2012 TLS SNI support enabled configure arguments: --prefix=/app/nginx/nginx --with-pcre=/app/nginx/soft/pcre-8.35 --with-zlib=/app/nginx/soft/zlib-1.2.8 --with-openssl=/app/nginx/soft/openssl-1.0.1c --with-http_ssl_module --with-http_realip_module
須要用到的內容爲
configure arguments:
後的內容
去nginx源碼目錄編譯atom
cd nginx-1.11.5 && ./configure --prefix=/app/nginx/nginx --with-pcre=/app/nginx/soft/pcre-8.35 --with-zlib=/app/nginx/soft/zlib-1.2.8 --with-openssl=/app/nginx/soft/openssl-1.0.1c --with-http_ssl_module --with-http_realip_module && make
注意:不要make install,否則會覆蓋現有的
等待編譯成功後會生成一個objs
目錄,進入目錄設計
cd objs
複製編譯生成的可執行文件到原先的nginx的sbin目錄代理
cp nginx /app/nginx/nginx/sbin
注意,複製前建議先備份原有的
sbin
文件
切換進程:code
make upgrade
或者去替換的sbin目錄
,./nginx -s reload