文章目录
前言
由于安全测试组扫描主机漏洞,扫出来两个安全漏洞,因此记录一下解决方法。
CVE-2024-6387:OpenSSH:远程代码执行漏洞 解决办法:升级至9.8p1版本
一、CVE-2024-6387漏洞详情
OpenSSH is the premier connectivity tool for remote login with the SSH protocol. It encrypts all traffic to eliminate eavesdropping, connection hijacking, and other attacks. In addition, OpenSSH provides a large suite of secure tunneling capabilities, several authentication methods, and sophisticated configuration options.
OpenSSH 是使用 SSH 协议进行远程登录的主要连接工具。它对所有流量进行加密,以消除窃听、连接劫持和其他攻击。此外,OpenSSH 还提供了一大套安全隧道功能、多种身份验证方法和复杂的配置选项。
据官方描述,在 OpenSSH 服务器中的信号处理程序中存在条件竞争漏洞,未经身份验证的远程攻击者可利用该漏洞在基于 glibc 的 Linux 系统上以 root 身份执行任意代码。
影响版本
OpenSSH < 4.4p1(未更新历史漏洞 CVE-2006-5051、CVE-2008-4109 的补丁)
8.5p1 <= OpenSSH < 9.8p1
安全版本
4.4p1 <= OpenSSH < 8.5p1
OpenSSH >= 9.8p1
二、升级OpenSSH版本步骤
主机ssh原先版本:OpenSSH 8.6p1,OpenSSL 1.1.1k
1、安装并开启telnet连接
启用Telnet方式防止SSH中断无法操作,关键时刻可以救命
[root@localhost ~]# yum -y install telnet* xinetd*
[root@localhost ~]# cat /etc/securetty | grep pts
pts/1
pts/2
pts/3
pts/4
pts/5
若没有则编辑将其追加到/etc/securetty文档中
#开启telnet连接
[root@localhost ~]# systemctl start telnet.socket
[root@localhost ~]# systemctl status telnet.socket
测试telnet连接:telnet ip
2、准备好安装openssh环境
ssh -V
yum install wget tar make gcc openssh-devel zlib-devel
3、备份ssh配置
cp -rf /etc/ssh /etc/ssh.bak
cp -rf /usr/bin/ssh /usr/bin/ssh.bak
cp -rf /usr/sbin/sshd /usr/sbin/sshd.bak
4、下载上传并解压9.8p1包
下载链接:https://ftp.openbsd.org/pub/OpenBSD/OpenSSH/openssh-9.8.tar.gz
解压:tar -zxvf openssh-9.8p1.tar.gz
5、卸载低版本openssh
yum list openssh
yum remove openssh*
yum remove openssh.aarch64 && yum remove openssh-debuginfo-8.6p1-1.axs7.1.aarch64 && rpm-qa |grep ssh
6、安装高版本9.8p1
cd openssh-9.8p1
./configure —sysconfigdir=/etc/ssh
make
make install
一行命令直接执行:cd openssh-9.8p1 && ./configure —sysconfigdir=/etc/ssh && make && make install
7、复制生成SSHD服务文件
cd openssh-9.8p1 && cp -a contrib/redhat/sshd.init /etc/init.d/sshd && cp -a /usr/local/bin/ssh-keygen /usr/bin/ssh-keygen
8、修改SSHD路径
[root@localhost ~]# ll /usr/local/sbin/sshd
[root@localhost ~]# vim /etc/init.d/sshd
将SSHD=的值改为/usr/local/sbin/sshd
[root@localhost ~]# cat /etc/init.d/sshd|grep SSHD=
SSHD= /usr/local/sbin/sshd
9、设置允许root登陆
[root@localhost ~]# cat /etc/init.d/sshd_config |grep PermitRootLogin
[root@localhost ~]# echo “PasswordAuthentication yes” >> /usr/local/etc/sshd_config && echo “X11Forwarding yes” >> /usr/local/etc/sshd_config && echo “PermitRootLogin yes” >> /usr/local/etc/sshd_config && echo “UsePAM yes” >> /usr/local/etc/sshd_config
10、设置ssh开机自启动
chkconfig —add sshd && chkconfig sshd on
11、启动sshd
systemctl daemon-reload
systemctl restart sshd
systemctl status sshd
12、测试ssh是否正常
ssh ip 测试使用ssh连接是否正常
ssh -V 检查是否已升级为OpenSSH 9.8p1版本
若执行ssh -V找不到文件或目录,sshd正常
[root@localhost ~]# which ssh
/usr/local/bin/ssh
[root@localhost ~]# ln -s /usr/local/bin/ssh /bin/ssh
[root@localhost ~]# ssh -V
13、telnet服务停用
systemctl stop telnet.socket
systemctl status telnet.socket
apache hbase /logs路径遍历漏洞、hdfs未授权访问漏洞 解决方法:添加防火墙规则
三、Apache Hbase /logs 路径遍历漏洞
eq: http://127.0.0.0:9999 没有设置密码可以直接访问
apache hbase /logs路径遍历漏洞、hdfs未授权访问
四、添加防火墙规则
配置iptables防火墙规则
可以配置只允许某些ip访问该端口
1、使用iptables限制访问
设置规则:9999端口允许198.1.1.1、198.1.1.2访问,其他来源的IP都拒绝
[root@localhost ~]# iptables -A INPUT -p tcp —dport 9999 -s 198.1.1.1 -j ACCEPT
[root@localhost ~]# iptables -A INPUT -p tcp —dport 9999 -s 198.1.1.2 -j ACCEPT
[root@localhost ~]# iptables -A INPUT -p tcp —dport 9999 -j DROP
2、iptables命令查看当前的规则链
查看iptables规则,⚠️这个规则是按照顺序执行的
iptables -L -n -v —line-numbers
3、删除某条规则 慎用
例如删除第5条:iptables -D INPUT 5
4、保存规则
sudo sh -c “iptables-save > /etc/iptables/rules.v4”
总结
有关openssh的各个配置的作用、iptables命令的含义之后会单独整理出来。