最近服务器提示高危漏洞:RHSA-2019:3286,RHSA-2018:1453,RHSA-2021:4904等,为了保障安全,进行了漏洞修复,将修复过程记录下来方便后期进行查阅。

一、RHSA-2021:4904 nss 安全更新漏洞修复。

#1 查看可更新的软件nss
yum list updates |grep nss
#2 如果有可更新软件,则进行更新
yum -y update nss.x86_64

二、RHSA-2018:1453 dhcp 安全更新漏洞修复。

#1 查看可更新的软件dhcp
yum list updates |grep dhcp
#2 如果有可更新软件,则进行更新
yum -y update dhcp-common.x86_64

三、RHSA-2019:3286 php 安全更新漏洞修复。

yum remove php-common 然后像安装那样问你是否继续的,输入yes即可
yum list installed | grep php
yum remove php56w.x86_64
yum remove php.x86_64
yum remove php-common.x86_64
yum install php74-php php74-php-mysqlnd php74-php-gd php74-php-mbstring php74-php-xml php74-php-zip php4-php-pdo php74-php-pear 
yum install php74-php-fpm
systemctl start php-fpm
systemctl enable php-fpm
3.1、首先查看系统中php的各个版本
find / -name php
3.2、在找到的诸如../bin/php 文件处执行查看各个php版本的命令。比如如果查出的结果中有/usr/bin/php/usr/local/bin/php,则可分别查看其版本:
/usr/local/bin/php -v
PHP 5.4.17 (cli) (built: Sep 21 2017 10:27:13)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
/usr/bin/php -v
PHP 7.2.6 (cli) (built: Jun 2 2018 07:49:42) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.6, Copyright (c) 1999-shan2018, by Zend Technologiess
3.3、删除版本比较低的php相关目录
cd /usr/local/bin/
rm -rf ./php
rm -rf ./php-cgi
rm -rf ./php-config
3.4、在系统环境变量中加入高版本的php目录
vim /etc/profile
3.5、并在文件末尾加上:export PATH=”/usr/bin:$PATH”(因为该处php版本高)
用root用户名运行以下命令
source /etc/profile
3.6、运行php版本查看命令
php -v
PHP 7.1.6 (cli) (built: Jun 22 2017 02:42:34) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.6, Copyright (c) 1999-2017, by Zend Technologie
yum install php74-php php74-php-mysqlnd php74-php-gd php74-php-mbstring php74-php-xml php74-php-zip

四、RHSA-2019:1587 python 安全更新漏洞修复。

yum update python-libs
yum update python

五、RHSA-2019:1294 bind 安全更新漏洞修复。

yum update bind-libs-lite
yum update bind-utils
yum update bind-libs
yum update bind-license

六、RHSA-2021:3028(RHSA-2021:2305) microcode_ctl安全更新漏洞修复。

yum update microcode_ctl

七、RHSA-2019:2169 linux-firmware security,bug fix,和 enhancement update安全更新漏洞修复。

yum update iwl2030-firmware -y
yum update iwl6050-firmware -y
yum update iwl5000-firmware -y
yum update iwl4965-firmware -y
yum update iwl3945-firmware -y
yum update iwl135-firmware -y
yum update iwl7260-firmware -y
yum update linux-firmware -y
yum update iwl3160-firmware -y
yum update iwl1000-firmware -y
yum update iwl6000-firmware -y
yum update iwl105-firmware -y
yum update iwl2000-firmware -y
yum update iwl100-firmware -y
yum update iwl6000g2b-firmware -y
yum update iwl6000g2a-firmware -y
yum update iwl7265-firmware -y

八、RHSA-2021:0221 sudo 堆缓冲区溢出致本地提权安全更新漏洞修复。

yum update sudo

九、RHSA-2019:0368 systemd 安全更新漏洞修复。

yum update systemd -y

十、RHSA-2022:0143: httpd 安全更新漏洞修复。

yum update httpd-tools
yum update httpd

十一、RHSA-2020:1113 bash 安全更新漏洞修复。

yum update bash

十二、RHBA-2019:2044 gnome 和 enhancement 安全漏洞修复。

yum update plymouth
yum update plymouth-core-libs
yum update plymouth-scripts
yum update glib2
yum update glib2-devel
yum update pango

十三、RHSA-2020:1021 GNOME 和 enhancement 安全更新漏洞修复。

yum update shared-mime-info
yum update gtk-update-icon-cache

十四、RHSA-2019:2189 procps-ng安全更新漏洞修复。

yum update procps-ng -y

十五、RHSA-2019:2197 elfutils和enhancement 安全更新漏洞修复。

yum update elfutils-libs -y
yum update elfutils-libelf -y
yum update elfutils-default-yama-scope

十六、RHSA-2019:2075 binutils安全更新漏洞修复。

yum update binutils -y

十七、RHSA-2020:4041 openldap安全更新漏洞修复。

yum update openldap

十八、RHSA-2019:3976 tcpdump安全更新漏洞修复。

yum update tcpdump -y

十九、RHSA-2019:2053: libtiff安全更新漏洞修复。

yum update doxygen -y
yum update libtiff -y

二十、未使用安全的套接字加密远程管理ssh。

vi /etc/ssh/sshd_config
Protocol 2
systemctl restart sshd

二十一、bootloader配置权限错误修复。

chmod 600 /boot/grub2/grub.cfg
chown root /boot/grub2/grub.cfg
ls -l /boot/grub2/grub.cfg

二十一、存在suid特权文件、存在sgid特权文件。

chmod u-s /usr/bin/chage /usr/bin/gpasswd /usr/bin/chfn /usr/bin/chsh /usr/bin/newgrp /usr/sbin/usernetctl /bin/mount /bin/umount
chmod g-s /usr/bin/wall /usr/bin/write /sbin/netreport

二十二、数据库未定期备份。

计划任务-数据库备份-备份时间执行即可。

二十三、数据库存在被爆破风险。

安装Fail2ban插件,创建防爆破任务。

二十四、未关闭PHP错误提示信息。

运行环境–PHP插件–配置修改–display_error设置为关闭。

二十五、禁止ICMP协议访问服务器。

安全–禁ping–开启。

二十六、未设置无操作超时退出。

vi /etc/profile
添加命令:tmout=300
source /etc/profile

二十七、SSH空闲超时时间未设置。

vi /etc/ssh/sshd_config
ClientAliveInterval 900

二十八、SSH登陆超时配置未设置。

vi /etc/ssh/sshd_config
LoginGraceTime 60

二十九、未开启TCP-SYNcookie保护。

vi /etc/sysctl.conf
net.ipv4.tcp_syncookies=1
sysctl -p

三十、未禁用wheel组外的用户su切换为root用户。

vi /etc/pam.d/su
添加auth required pam_wheel.so
cat /etc/group | grep wheel //查找wheel组中的用户
usermod -aG wheel user1
gpasswd -a user1 wheel

三十一、SSH密码复杂度不够。

vi /etc/security/pwquality.conf
minclass=3

三十二、未在/etc/modprobe.d/*.conf配置禁用规则:install sctp /bin/true。

vim /etc/modprobe.d/CIS.conf
# 在文件中添加以下内容(直接复制粘贴即可)
install sctp /bin/true
blacklist sctp # 可选,双重禁用更安全
# 保存退出vim:按Esc → 输入:wq → 回车

三十三、未设置Banner或被置为none。

vim /etc/ssh/sshd_config

在文件中找到 Banner 相关行(通常被注释,格式为 #Banner none);

将其修改为:Banner /etc/issue.net(删除开头的 #,并修改路径);

若找不到 Banner 行,直接在文件末尾新增该行即可。

保存退出:按 Esc → 输入 :wq → 回车。

systemctl restart sshd

三十四、inet_interfaces未设置为127.0.0.1(/etc/postfix/main.cf)

postconf -e 'inet_interfaces = 127.0.0.1'
systemctl restart postfix

三十五、未配置sysctl:net.ipv4.icmp_echo_ignore_broadcasts=1

vi /etc/sysctl.conf
net.ipv4.icmp_echo_ignore_broadcasts = 1
执行:sysctl -w net.ipv4.icmp_echo_ignore_broadcasts=1;
执行:sysctl -w net.ipv4.route.flush=1

三十六、未配置sysctl:net.ipv4.icmp_ignore_bogus_error_responses=1

vi /etc/sysctl.conf

net.ipv4.icmp_ignore_bogus_error_responses = 1

执行:sysctl -w net.ipv4.icmp_ignore_bogus_error_responses=1

执行:sysctl -w net.ipv4.route.flush=1

三十七、未在/etc/sysctl.conf禁用源路由:net.ipv4.conf.all.accept_source_route,net.ipv4.conf.default.accept_source_route

vi /etc/sysctl.conf

net.ipv4.conf.all.accept_source_route = 0

net.ipv4.conf.default.accept_source_route = 0

执行:sysctl -w net.ipv4.conf.all.accept_source_route=0

执行:sysctl -w net.ipv4.conf.default.accept_source_route=0

执行:sysctl -w net.ipv4.route.flush=1

三十八、未在/etc/sysctl.conf禁用IPv4 ICMP重定向:net.ipv4.conf.all.accept_redirects,net.ipv4.conf.default.accept_redirects

vi /etc/sysctl.conf

net.ipv4.conf.all.accept_redirects = 0

net.ipv4.conf.default.accept_redirects = 0

执行:sysctl -w net.ipv4.conf.all.accept_redirects=0

执行:sysctl -w net.ipv4.conf.default.accept_redirects=0

执行:sysctl -w net.ipv4.route.flush=1

三十九、未启用可疑数据包日志:net.ipv4.conf.all.log_martians,net.ipv4.conf.default.log_martians

vi /etc/sysctl.conf

net.ipv4.conf.all.log_martians = 1

net.ipv4.conf.default.log_martians = 1

执行:sysctl -w net.ipv4.conf.all.log_martians=1

执行:sysctl -w net.ipv4.conf.default.log_martians=1

执行:sysctl -w net.ipv4.route.flush=1

四十、未禁用安全ICMP重定向:net.ipv4.conf.all.secure_redirects,net.ipv4.conf.default.secure_redirects

net.ipv4.conf.all.secure_redirects = 0;net.ipv4.conf.default.secure_redirects = 0;执行:sysctl -w net.ipv4.conf.all.secure_redirects=0;执行:sysctl -w net.ipv4.conf.default.secure_redirects=0;执行:sysctl -w net.ipv4.route.flush=1

四十一、本地登录标语包含系统信息变量:\m,\r

vi /etc/issue

删除`\m`、`\r`、`\s`、`\v`配置;根据站点策略填充统一警告内容,例如:;echo “Authorized uses only. All activity may be monitored and reported.” > /etc/issue

四十二、ntp配置不规范:缺少restrict -4 default 配置、缺少restrict -6 default 配置、ntpd未以ntp用户运行(缺少 -u ntp:ntp)

vi /etc/ntp.conf

restrict -4 default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery

systemctl enable –now ntpd

四十三、未安装TCP Wrappers

yum install tcp_wrappers

四十四、检测到已安装telnet客户端:/usr/bin/telnet,/bin/telnet

yum remove telnet

四十五、未在/etc/modprobe.d/*.conf配置禁用规则:install tipc /bin/true

vi /etc/modprobe.d/CIS.conf

install tipc /bin/true

四十六、未在/etc/modprobe.d/*.conf配置禁用规则:install udf /bin/true

vi /etc/modprobe.d/CIS.conf

install udf /bin/true

四十七、未设置/tmp的nosuid挂载选项

vim /etc/systemd/system/local-fs.target.wants/tmp.mount

Options=mode=1777,strictatime,noexec,nodev,nosuid

 

声明:
本站所有文章,如无特殊说明或标注,均为本站原创发布。
任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。
如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。