等保注意事项和修复方式
Linux 主机
- 密码策略未对root账户生效
# 编辑 /etc/pam.d/system-auth 文件 vi /etc/pam.d/system-auth # 在/etc/pam.d/system-auth文件配置如下参数值:( password requisite pam_pwquality.so try_first_pass retry=3 dcredit=-1 lcredit=-1 ucredit=-1 ocredit=-1 minlen=8)后追加参数:enforce_for_root password requisite pam_pwquality.so try_first_pass retry=3 dcredit=-1 lcredit=-1 ucredit=-1 ocredit=-1 minlen=8 enforce_for_root
- 服务器未配置密码有效期策略
# 编辑 /etc/login.defs 文件 vi /etc/login.defs #配置 PASS MAX_DAYS 的值为90 # Password aging controls: # # PASS_MAX_DAYS Maximum number of days a password may be used. # PASS_MIN_DAYS Minimum number of days allowed between password changes. # PASS_MIN_LEN Minimum acceptable password length. # PASS_WARN_AGE Number of days warning given before a password expires. # PASS_MAX_DAYS 90 PASS_MIN_DAYS 0 PASS_MIN_LEN 5 PASS_WARN_AGE 7
- 未配置登录失败锁定策略
# 建议在/etc/pam.d/sshd或/etc/pam.d/password-auth文件中配置(如:auth required pam_tally2.so deny=5,unlock_time=600,even_deny_root unlock_time=600) #vi /etc/pam.d/sshd vi /etc/pam.d/password-auth auth required pam_tally2.so deny=5,unlock_time=600,even_deny_root unlock_time=600
- 当前服务器仅存在root账户,未实现管理用户的权限分离
建至少一个不同权限的账户实现管理用户的权限分离。管理员创建一个具有必要权限的管理账户,避免直接使用root账户进行日常管理操作1、打开终端(Terminal)。 2、以root用户身份登录(或使用sudo命令):输入`su`,然后输入root用户的密码。 3、输入以下命令来创建新用户(以“admin”为例): useradd -m admin `-m`参数会自动创建一个与用户名相同的目录作为用户的主目录。 4、设置新用户的密码,输入以下命令: passwd admin 5、然后按照提示输入新密码,并确认密码。 6、将新用户添加到sudo组,以便拥有管理员权限,输入以下命令: usermod -aG sudo admin 7、这将把新用户“admin”添加到sudo组中。 8、退出root用户,输入以下命令: exit 9、现在,你可以使用新的管理员账户登录系统了。
- 未对服务器的日志进行定期备份
- 网马脚本
1、解压缩下载的脚本包,将目录下得所有文件拷贝到被检测主机 2、终端下执行如下命令:"bash check_system_linux_linux.sh IP" 3、脚本执行完成后会在当前目录生成一个result文件夹,将该文件夹反馈给我们,做完一个系统以系统命名文件夹。 4、注意一定不要修改离线工具生成文件的文件名. > 说明:IP替换为检查主机的IP shell> bash check_system_linux_linux.sh 192.168.x.x tar -zxvf linuxwsscan.tar.gz cd linuxwsscan ./wsclient /home ./wsclient /opt ./wsclient /usr ./wsclient /tmp
中间件
- 中间件未开启全面的安全审计功能
建议中间件未开启全面的安全审计功能,如在nginx所在操作系统的/etc/audit/rules.d/audit.rules
文件配置如下参数:(-w nginx安装路径 -p rwxa)。vi /etc/audit/rules.d/audit.rules 添加如下 -w <nginx安装路径> -p rwxa -W /www/server/nginx -p rwxa
- 未对Nginx的日志记录定期进行备份
# 宝塔Linux面板 安装的Nginx 日志目录 /www/server/nginx/logs/ 和 /www/wwwlogs 建议将中间件的日志文件(nginx路径下logs文件夹内的文件)通过脚本定期备份到素质评价存储服务器(192.168.39.190)或其他服务器(异机),并提供脚本配置、Crontab 配置(more /etc/crontab)和已备份的日志文件截图。 # 查看 crontab 命令 more /etc/crontab 0 0 0 * * ?
数据库
自查脚本:
select version();
select * from mysql.user;
select host,user,authentication_string,plugin from mysql.user;
select * from mysql.plugin;
show plugins;
show variables like 'validate%';
show variables like '%password%';
show variables like '%general%';
show variables like 'general_log%';
show variables like '%control%';
show variables like '%connection_control%';
show variables like '%timeout%';
show variables like '%ssl%';
show variables like '%have_ssl%';
show variables like '%have_openssl%';
show variables like '%validate_password%';
show variables like '%connection_control%';
show global variables like '%default_password_lifetime%';
show global variables like '%timeout%';
show global variables like '%max_connect_errors%';
show binlog events limit 100;
show variables like 'require_secure_transport';
show variables like '%ssl%';
show global variables like '%log%';
show grants;
- 数据库未配置密码复杂度策略
#安装插件 INSTALL PLUGIN validate_password SONAME 'validate_password.so'; #建议配置强制密码复杂度策略,密码长度不少于8位,至少包含数字、大小写字母、特殊字符中的至少3种; #如在数据库中添加“validate_password%“模块,并配置如下参数值: SET GLOBAL validate_password_length=8; SET GLOBAL validate_password_mixed_case_count=1; SET GLOBAL validate_password_number_count=1; SET GLOBAL validate_password_policy=MEDIUM; SET GLOBAL validate_password_special_char_count=1;
- 数据库未配置口令有效期(可选)。
show variables like '%password%'; # 建议配置密码有效期策略,90天强制更改密码,至多不超过120天; # 在数据库中添加“default_password_lifetime”模块,并配置以下参数值: SET GLOBAL default_password_lifetime=90; # SET GLOBAL default_password_lifetime=3650;
- 数据库未配置登录失败锁定策略。
# 查看数据库登录失败锁定策略 show variables like '%connection_control%'; install plugin connection_control soname 'connection_control.so'; install plugin connection_control_failed_login_attempts soname 'connection_control.so'; # 建议配置登录失败处理功能,如在数据库添加“connection_control”,并在此模块下配置如下参数值: SET GLOBAL connection_control_failed_connections_threshold=5; SET GLOBAL connection_control_max_connection_delay=600000; SET GLOBAL connection_control_min_connection_delay=60000;
- 数据库目前登录超时时间为8小时,超时时间过长
# 建议配置登录连接超时自动退出功能,如在数据库“%time%”模块处配置如下参数值:(interactive_timeout=1800) show variables like '%timeout%'; SET GLOBAL interactive_timeout=1800;
- 数据库未做地址限制
建议通过mysql的user表的host字段或者主机防火墙限制远程管理数据库的网络地址范围。select user, host FROM mysql.user; -- 比如Host字段值从 % 改为 192.168.39.%
- 未提供数据库日志
建议开启mysql数据库的general_log日志功能,或者mysql部署MariaDB Audit Plugin审计插件后,提供数据库的审计日志。
MySQL 使用开源审计插件示例详解show variables like 'general_log'; -- 查看日志是否开启 show variables like 'general_log_file'; -- 看看日志文件保存位置 show variables like 'log_output'; -- 看看日志输出类型 table或file set global general_log=on; -- 对全局开启general log show variables like 'log_output'; set global general_log=off;
作者:Jeebiz 创建时间:2024-08-16 11:58
最后编辑:Jeebiz 更新时间:2024-08-20 18:42
最后编辑:Jeebiz 更新时间:2024-08-20 18:42