Nginx 安全漏洞

Nginx 安全漏洞

漏洞引发的威胁:

  • CVE-2021-23017 nginx存在安全漏洞,该漏洞源于一个离一错误在该漏洞允许远程攻击者可利用该漏洞在目标系统上执行任意代码。受影响版本:0.6.18-1.20.0
  • CVE-2019-9511,CVE-2019-9513,CVE-2019-9516 Nginx 1.9.51 至 16.0版本及1.17.2.版本中的HTTP/2实现中存在拒绝服务漏洞,攻击者以多个数据流请求特定资源上的大量数据,通过操纵窗口大小和流优先级,强迫服务器将数据排列在1字节的块中,导致CPU及内存资源耗尽,造成拒绝服务。
  • CVE-2018-16844 Nginx 1.15.5之前的版本和1.14.1版本中的HTTP/2实现过程中存在安全漏洞。远程攻击者可通过发送恶意的请求利用该漏洞造成拒绝服务。
  • CVE-2018-16843 nginx 1.15.6和1.14.1之前的版本的HTTP/2实现过程中存在安全漏洞。攻击者可利用该漏洞消耗大量的内存空间。
  • CVE-2018-16845 Nginx 1.15.5及之前的版本和1.14.1版本中的ngx_http_mp4_module组件存在内存泄露漏洞,该漏洞源于程序没有正确处理MP4文件。远程攻击者可利用该漏洞获取敏感信息或造成拒绝服务。
  • CVE-2017-20005 Nginx在1.13.6之前存在安全漏洞,该漏洞源于当autoindex模块遇到这个文件时,会导致一个整数溢出。

解决方案

一、查看当前版本
[root@localhost ~]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.2.9
二、官网下载最新版本

http://nginx.org/en/download.html
https://nginx.org/

三、备份配置文件
[root@localhost ~]# cp -r /usr/local/nginx/ /usr/local/nginx_bak/
[root@localhost ~]# ls /usr/local/nginx
nginx/     nginx_bak/
四、上传新版本的nginx,先解压,配置,编译。

不可以使用make && make install直接编译安装,不然会覆盖原来版本产生多种问题

[root@localhost ~]# tar zxf nginx-1.20.2.tar.gz 
[root@localhost ~]# cd nginx-1.20.2/
[root@localhost nginx-1.20.2]# ./configure
[root@localhost nginx-1.20.2]# make
五、复制新版本的启动文件
[root@localhost nginx-1.20.2]# cd /usr/local/nginx/sbin/
[root@localhost sbin]# mv nginx nginx.old
[root@localhost sbin]# cp /root/nginx-1.20.2/objs/nginx /usr/local/nginx/sbin/
六、回到新版本安装目录进行平滑升级
[root@localhost sbin]# cd /root/nginx-1.20.2/
[root@localhost nginx-1.20.2]# make upgrade
/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
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`

出现这个提示pid文件位置不一致,那就需要换一种方式

[root@localhost nginx-1.20.2]# /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

可以查看一下 nginx.pid位置

[root@localhost nginx-1.20.2]# find / -name nginx.pid
/usr/local/nginx/logs/nginx.pid
[root@localhost nginx-1.20.2]# kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
现在会在/usr/local/nginx/logs/下生成一个nginx.pid.oldbin的pid文件
[root@localhost nginx-1.20.2]# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
[root@localhost nginx-1.20.2]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.20.2
升级结束 新版本为1.20.2
### F5 Nginx 安全漏洞 CVE-2024-24990 修复方案 F5 Nginx安全漏洞 CVE-2024-24990 主要涉及 Nginx 的特定配置和模块使用中可能存在的安全隐患。以下是针对该漏洞的详细修复方案: #### 1. 更新到安全版本 确保将 Nginx 更新到官方发布的最新版本,这些版本已修复了 CVE-2024-24990 漏洞。根据官方公告,Nginx 版本 1.26.3 及以上版本已经解决了相关问题[^1]。可以通过以下命令检查当前版本,并下载最新稳定版进行升级: ```bash # 检查当前 Nginx 版本 nginx -v # 下载并安装最新版本 wget http://nginx.org/download/nginx-1.26.3.tar.gz tar -zxvf nginx-1.26.3.tar.gz cd nginx-1.26.3 ``` #### 2. 配置编译选项 在重新编译 Nginx 时,需要确保保留原有的功能模块,并根据实际需求添加必要的安全模块。例如: ```bash ./configure \ --prefix=/usr/local/nginx \ --with-http_ssl_module \ --with-http_v2_module \ --with-http_realip_module \ --with-http_stub_status_module \ --with-stream \ --with-stream_ssl_module \ --with-pcre ``` 上述配置选项确保了 Nginx 的核心功能得以保留,同时增强了安全性[^2]。 #### 3. 平滑升级 为了减少服务中断时间,可以采用平滑升级的方式更新 Nginx。步骤如下: - 停止旧的 Nginx 进程: ```bash kill -USR2 `cat /usr/local/nginx/logs/nginx.pid` ``` - 启动新的 Nginx 进程: ```bash cd /home/nginx/sbin ./nginx ``` - 验证版本是否正确: ```bash ./nginx -v ``` #### 4. 验证修复效果 完成升级后,验证 Nginx 是否成功修复了 CVE-2024-24990 漏洞。可以通过以下方式进行测试: - 使用专业的漏洞扫描工具(如 Nessus 或 OpenVAS)对服务器进行扫描。 - 手动检查日志文件,确认没有异常访问或攻击记录。 #### 5. 其他安全建议 除了修复漏洞外,还应采取以下措施提升整体安全性: - 定期更新系统补丁,保持操作系统和软件处于最新状态。 - 禁用不必要的模块和服务,减少攻击面。 - 配置防火墙规则,限制对 Nginx 的访问范围。 ---
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

看着博客敲代码

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值