From c3f0ad8f5ae2898fb58430f2307726d80616ed2c Mon Sep 17 00:00:00 2001 From: YuQing Date: Fri, 27 May 2022 14:11:15 +0800 Subject: [PATCH 1/2] docs/development-guide.md: fix a typo Signed-off-by: YuQing --- docs/development-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development-guide.md b/docs/development-guide.md index 17407e4..e8d119b 100644 --- a/docs/development-guide.md +++ b/docs/development-guide.md @@ -18,7 +18,7 @@ . ├── benchmarks │ └── access-and-control -│ └── logging and auditing +│ └── logging-and-auditing │ └── services │ └── 3.1-disable-http-server.md │ └── system-configurations -- Gitee From dd9a1cf40777488b324fd66719d4b1146ab1536c Mon Sep 17 00:00:00 2001 From: YuQing Date: Fri, 27 May 2022 14:13:43 +0800 Subject: [PATCH 2/2] benchmarks/logging-and-auditing: add items from 2.1 to 2.18 Fixes: #I57ZOJ Signed-off-by: YuQing --- ...-write-accessible-by-unauthorized-users.md | 52 ++++++++++++++ ...ure-audit-tools-are-group-owned-by-root.md | 48 +++++++++++++ ...to-protect-the-integrity-of-audit-tools.md | 53 ++++++++++++++ .../2.12-ensure-rsyslog-is-installed.md | 38 ++++++++++ .../2.13-ensure-rsyslog-service-is-enabled.md | 38 ++++++++++ ...log-default-file-permissions-configured.md | 40 +++++++++++ ...gured-to-send-logs-to-a-remote-log-host.md | 40 +++++++++++ ...d-is-configured-to-send-logs-to-rsyslog.md | 34 +++++++++ ...-configured-to-compress-large-log-files.md | 36 ++++++++++ ...ed-to-write-logfiles-to-persistent-disk.md | 35 ++++++++++ ...ly-authorized-users-own-audit-log-files.md | 52 ++++++++++++++ ...zed-groups-ownership-of-audit-log-files.md | 70 +++++++++++++++++++ ...g-directory-is-0750-or-more-restrictive.md | 50 +++++++++++++ ...tion-files-are-0640-or-more-restrictive.md | 46 ++++++++++++ ...ounts-own-the-audit-configuration-files.md | 51 ++++++++++++++ ...roups-own-the-audit-configuration-files.md | 47 +++++++++++++ ...ls-are-mode-of-0755-or-more-restrictive.md | 48 +++++++++++++ ....9-ensure-audit-tools-are-owned-by-root.md | 48 +++++++++++++ 18 files changed, 826 insertions(+) create mode 100644 benchmarks/logging-and-auditing/2.1-ensure-audit-log-files-are-not-read-or-write-accessible-by-unauthorized-users.md create mode 100644 benchmarks/logging-and-auditing/2.10-ensure-audit-tools-are-group-owned-by-root.md create mode 100644 benchmarks/logging-and-auditing/2.11-ensure-cryptographic-mechanisms-are-used-to-protect-the-integrity-of-audit-tools.md create mode 100644 benchmarks/logging-and-auditing/2.12-ensure-rsyslog-is-installed.md create mode 100644 benchmarks/logging-and-auditing/2.13-ensure-rsyslog-service-is-enabled.md create mode 100644 benchmarks/logging-and-auditing/2.14-ensure-rsyslog-default-file-permissions-configured.md create mode 100644 benchmarks/logging-and-auditing/2.15-ensure-rsyslog-is-configured-to-send-logs-to-a-remote-log-host.md create mode 100644 benchmarks/logging-and-auditing/2.16-ensure-journald-is-configured-to-send-logs-to-rsyslog.md create mode 100644 benchmarks/logging-and-auditing/2.17-ensure-journald-is-configured-to-compress-large-log-files.md create mode 100644 benchmarks/logging-and-auditing/2.18-ensure-journald-is-configured-to-write-logfiles-to-persistent-disk.md create mode 100644 benchmarks/logging-and-auditing/2.2-ensure-only-authorized-users-own-audit-log-files.md create mode 100644 benchmarks/logging-and-auditing/2.3-ensure-only-authorized-groups-ownership-of-audit-log-files.md create mode 100644 benchmarks/logging-and-auditing/2.4-ensure-the-audit-log-directory-is-0750-or-more-restrictive.md create mode 100644 benchmarks/logging-and-auditing/2.5-ensure-audit-configuration-files-are-0640-or-more-restrictive.md create mode 100644 benchmarks/logging-and-auditing/2.6-ensure-only-authorized-accounts-own-the-audit-configuration-files.md create mode 100644 benchmarks/logging-and-auditing/2.7-ensure-only-authorized-groups-own-the-audit-configuration-files.md create mode 100644 benchmarks/logging-and-auditing/2.8-ensure-audit-tools-are-mode-of-0755-or-more-restrictive.md create mode 100644 benchmarks/logging-and-auditing/2.9-ensure-audit-tools-are-owned-by-root.md diff --git a/benchmarks/logging-and-auditing/2.1-ensure-audit-log-files-are-not-read-or-write-accessible-by-unauthorized-users.md b/benchmarks/logging-and-auditing/2.1-ensure-audit-log-files-are-not-read-or-write-accessible-by-unauthorized-users.md new file mode 100644 index 0000000..9c7b82e --- /dev/null +++ b/benchmarks/logging-and-auditing/2.1-ensure-audit-log-files-are-not-read-or-write-accessible-by-unauthorized-users.md @@ -0,0 +1,52 @@ +# 2.1 确保审计日志的文件权限被正确配置 + +## 安全等级 + +Level 1 + +## 描述 + +审计信息(审计记录、审计设置、审计报告)含有系统配置、用户数据、登录信息、操作记录等敏感数据,需严格控制其读写权限,避免数据泄露或丢失风险。 + +通过对**审计日志**文件权限进行配置,确保其不被未授权的用户读取或修改。 + +## 修复建议 + +目标:确保审计日志文件的权限为`0600`或更低。 + +1. 执行以下命令来确定审计日志的路径: + +```shell +# grep -iw log_file /etc/audit/auditd.conf +log_file = /var/log/audit/audit.log +``` + +2. 根据上一步得到的审计日志文件路径,执行以下命令,将其权限配置为`0600`或更低: + +```shell +# chmod 0600 /var/log/audit/* +``` + +## 扫描检测 + +确保审计日志文件的权限为`0600`或更低。 + +1. 执行以下命令来确定审计日志的路径: + +```shell +# grep -iw log_file /etc/audit/auditd.conf +log_file = /var/log/audit/audit.log +``` + +2. 根据上一步得到的审计日志文件路径,执行以下命令来检查审计日志文件的权限是否为`0600`或更低: + +```shell +# stat -c "%n %a" /var/log/audit/* +/var/log/audit/audit.log 600 +``` + +如结果为`0600`或更低,则视为通过此项检查。 + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.10-ensure-audit-tools-are-group-owned-by-root.md b/benchmarks/logging-and-auditing/2.10-ensure-audit-tools-are-group-owned-by-root.md new file mode 100644 index 0000000..3974094 --- /dev/null +++ b/benchmarks/logging-and-auditing/2.10-ensure-audit-tools-are-group-owned-by-root.md @@ -0,0 +1,48 @@ +# 2.10 确保审计工具属于root用户组 + +## 安全等级 + +Level 1 + +## 描述 + +审计工具包括但不限于:查看和操作审计信息所需的供应商或开源工具,如自定义查询和报告生成器等。因此,对审计工具的保护是非常必要的,以防未经授权的用户对审计信息进行提取或操作。 + +**审计工具**的所属组应为`root` + +## 修复建议 + +目标:确保审计工具的所属组为`root`。 + +1. 使用以下命令将审计工具的所属组设置为`root`: + +```shell +# chown :root /sbin/auditctl +# chown :root /sbin/aureport +# chown :root /sbin/ausearch +# chown :root /sbin/autrace +# chown :root /sbin/auditd +# chown :root /sbin/augenrules +``` + +## 扫描检测 + +确保审计工具的所属组为`root`。 + +1. 执行以下命令,检查审计工具的所属组是否为`root`: + +```shell +# stat -c "%n %G" /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace /sbin/auditd /sbin/augenrules +/sbin/auditctl root +/sbin/aureport root +/sbin/ausearch root +/sbin/autrace root +/sbin/auditd root +/sbin/augenrules root +``` + +如所有审计工具的所属组均为`root`,则视为通过此项检查。 + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.11-ensure-cryptographic-mechanisms-are-used-to-protect-the-integrity-of-audit-tools.md b/benchmarks/logging-and-auditing/2.11-ensure-cryptographic-mechanisms-are-used-to-protect-the-integrity-of-audit-tools.md new file mode 100644 index 0000000..3104a17 --- /dev/null +++ b/benchmarks/logging-and-auditing/2.11-ensure-cryptographic-mechanisms-are-used-to-protect-the-integrity-of-audit-tools.md @@ -0,0 +1,53 @@ +# 2.11 确保使用加密机制来保护审计工具的完整性 + +## 安全等级 + +Level 1 + +## 描述 + +审计工具包括但不限于:查看和操作审计信息所需的供应商或开源工具,如自定义查询和报告生成器等。因此,对审计工具的保护是非常必要的,以防未经授权的用户对审计信息进行提取或操作。 + +攻击者常替换审计工具或向现有工具中注入代码,从而将审计日志中的信息隐藏或删除。这种情况并不少见。 + +要解决此风险,审计工具必须进行加密签名,以便识别审计工具是否有被修改、操纵或替换。 + +## 修复建议 + +目标:使用加密机制保护审计工具的完整性 + +1. 向配置文件`/etc/aide/aide.conf`中添加或更新以下配置,对审计工具进行加密: + +```shell +# Audit Tools +/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512 +/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512 +/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512 +/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512 +/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512 +/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512 +``` + +如没有此配置文件,需新建。 + +## 扫描检测 + +确保审计工具有加密机制。 + +1. 执行以下命令,检查`/etc/aide/aide.conf`配置文件中,审计工具是否有加密机制: + +```shell +# grep -E '(\/sbin\/(audit|au))' /etc/aide/aide.conf +/sbin/auditctl p+i+n+u+g+s+b+acl+xattrs+sha512 +/sbin/auditd p+i+n+u+g+s+b+acl+xattrs+sha512 +/sbin/ausearch p+i+n+u+g+s+b+acl+xattrs+sha512 +/sbin/aureport p+i+n+u+g+s+b+acl+xattrs+sha512 +/sbin/autrace p+i+n+u+g+s+b+acl+xattrs+sha512 +/sbin/augenrules p+i+n+u+g+s+b+acl+xattrs+sha512 +``` + +如所有审计工具均有加密机制,则视为通过此项检查。 + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.12-ensure-rsyslog-is-installed.md b/benchmarks/logging-and-auditing/2.12-ensure-rsyslog-is-installed.md new file mode 100644 index 0000000..c2a6fb7 --- /dev/null +++ b/benchmarks/logging-and-auditing/2.12-ensure-rsyslog-is-installed.md @@ -0,0 +1,38 @@ +# 2.12 确保已安装 rsyslog + +## 安全等级 + +Level 1 + +## 描述 + +rsyslog 软件是原 syslogd 守护程序的替代品,其相比于 syslogd 做了很多改进,添加了如:面向连接(即TCP)的日志传输、将日志记录到数据库,以及在与中央日志服务器交互中对日志数据进行加密等特性及功能。 + +以上多种新特性与功能,都证明了安装和配置 rsyslog 软件包的合理性及必要性。 + +## 修复建议 + +目标:安装`rsyslog`软件包。 + +1. 运行以下命令安装`rsyslog`: + +```shell +# yum install rsyslog -y +``` + +## 扫描检测 + +确保已安装 rsyslog。 + +1. 执行以下命令,检查 rsyslog 软件是否正确安装: + +```shell +# rpm -q rsyslog +rsyslog- +``` + +``为版本号,如:`rsyslog-8.2102.0-5.an8.x86_64` + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' diff --git a/benchmarks/logging-and-auditing/2.13-ensure-rsyslog-service-is-enabled.md b/benchmarks/logging-and-auditing/2.13-ensure-rsyslog-service-is-enabled.md new file mode 100644 index 0000000..6763bc9 --- /dev/null +++ b/benchmarks/logging-and-auditing/2.13-ensure-rsyslog-service-is-enabled.md @@ -0,0 +1,38 @@ +# 2.13 确保 rsyslog 服务已启用 + +## 安全等级 + +Level 1 + +## 描述 + +rsyslog 软件是原 syslogd 守护程序的替代品,其相比于 syslogd 做了很多改进,添加了如:面向连接(即TCP)的日志传输、将日志记录到数据库,以及在与中央日志服务器交互中对日志数据进行加密等特性及功能。 + +在安装了 rsyslog 软件后,应正确的激活并启用该服务。 + +## 修复建议 + +目标:确保 rsyslog 服务已启用。 + +1. 运行以下命令启用 rsyslog 服务: + +```shell +# systemctl --now enable rsyslog +``` + +## 扫描检测 + +确保 rsyslog 服务已启用。 + +1. 执行以下命令,检查 rsyslog 服务是否启用: + +```shell +# systemctl is-enabled rsyslog +enabled +``` + +如输出结果为`enabled`,则视为通过此项检查。 + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.14-ensure-rsyslog-default-file-permissions-configured.md b/benchmarks/logging-and-auditing/2.14-ensure-rsyslog-default-file-permissions-configured.md new file mode 100644 index 0000000..a6cf5e4 --- /dev/null +++ b/benchmarks/logging-and-auditing/2.14-ensure-rsyslog-default-file-permissions-configured.md @@ -0,0 +1,40 @@ +# 2.14 确保正确配置了 rsyslog 默认文件权限 + +## 安全等级 + +Level 1 + +## 描述 + +对日志文件进行正确有效的权限管理是尤为重要的,通过权限管理可以确保敏感数据被正确的归档和保护。 + +rsyslog 服务会生成新的日志文件,以下配置的作用在于控制这些新生成的日志文件权限。 + +## 修复建议 + +目标:正确配置 rsyslog 默认文件权限。 + +1. 编辑`/etc/rsyslog.conf`和`/etc/rsyslog.d/*.conf`文件,将`$FileCreateMode`的值设置为`0640`或更低: + +```shell +# echo "\$FileCreateMode 0640" >> /etc/rsyslog.conf +# echo "\$FileCreateMode 0640" >> /etc/rsyslog.d/listen.conf +``` + +## 扫描检测 + +确保正确配置 rsyslog 默认文件权限。 + +1. 执行以下命令,验证配置文件中`$FileCreateMode`的值是否为`0640`或更低: + +```shell +# grep ^\$FileCreateMode /etc/rsyslog.conf /etc/rsyslog.d/*.conf +/etc/rsyslog.conf:$FileCreateMode 0640 +/etc/rsyslog.d/listen.conf:$FileCreateMode 0640 +``` + +如`$FileCreateMode`的值为`0640`或更低,则视为通过此项检查。 + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.15-ensure-rsyslog-is-configured-to-send-logs-to-a-remote-log-host.md b/benchmarks/logging-and-auditing/2.15-ensure-rsyslog-is-configured-to-send-logs-to-a-remote-log-host.md new file mode 100644 index 0000000..2b48466 --- /dev/null +++ b/benchmarks/logging-and-auditing/2.15-ensure-rsyslog-is-configured-to-send-logs-to-a-remote-log-host.md @@ -0,0 +1,40 @@ +# 2.15 确保 rsyslog 配置了远程日志主机 + +## 安全等级 + +Level 2 + +## 描述 + +将日志数据存储在远程主机上可以保护日志的完整性,使其免受本地攻击。 + +如果攻击者获得了本地系统的root权限,他们就可以篡改或删除存储在本地系统中的日志数据。而远程日志主机上的数据则不会受到影响。可通过远程日志主机轻松的对本地数据进行比对和恢复。 + +rsyslog 工具支持将其收集的日志发送到运行 syslogd(8) 的远程日志主机或接收来自远程主机的信息,从而减少管理开销。 + +## 修复建议 + +目标:正确配置 rsyslog 远程日志主机。 + +1. 编辑`/etc/rsyslog.conf`和`/etc/rsyslog.d/*.conf`文件,并添加以下代码(其中 loghost.example.com 是您的中央日志主机的名称,根据实际情况进行修改。): + +```shell +*.* @@loghost.example.com +``` + +如没有此配置文件,需新建。 + +## 扫描检测 + +确保正确配置 rsyslog 远程日志主机。 + +1. 运行以下命令,检查`/etc/rsyslog.conf`和`/etc/rsyslog.d/*.conf`文件是否正确配置了远程日志主机(其中 loghost.example.com 是您的中央日志主机的名称,根据实际情况进行修改。): + +```shell +# grep "^*.*[^I][^I]*@" /etc/rsyslog.conf /etc/rsyslog.d/*.conf +*.* @@loghost.example.com +``` + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.16-ensure-journald-is-configured-to-send-logs-to-rsyslog.md b/benchmarks/logging-and-auditing/2.16-ensure-journald-is-configured-to-send-logs-to-rsyslog.md new file mode 100644 index 0000000..0653f9b --- /dev/null +++ b/benchmarks/logging-and-auditing/2.16-ensure-journald-is-configured-to-send-logs-to-rsyslog.md @@ -0,0 +1,34 @@ +# 2.16 确保配置 journald 向 rsyslog 发送日志 + +## 安全等级 + +Level 1 + +## 描述 + +来自 journald 的数据可以存储在易失性内存中,也可以在服务器上本地保存。使用 rsyslog 服务可以提供一致的日志收集和导出方式。 + +## 修复建议 + +目标:正确配置 journald 向 rsyslog 发送日志。 + +1. 编辑`/etc/systemd/journald.conf`文件,增加如下代码: + +```shell +ForwardToSyslog=yes +``` + +## 扫描检测 + +确保配置 journald 向 rsyslog 发送日志 + +1. 检查`/etc/systemd/journald.conf`,确认日志是否被发送到 rsyslog : + +```shell +# grep -e ^\s*ForwardToSyslog /etc/systemd/journald.conf +ForwardToSyslog=yes +``` + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.17-ensure-journald-is-configured-to-compress-large-log-files.md b/benchmarks/logging-and-auditing/2.17-ensure-journald-is-configured-to-compress-large-log-files.md new file mode 100644 index 0000000..3d17001 --- /dev/null +++ b/benchmarks/logging-and-auditing/2.17-ensure-journald-is-configured-to-compress-large-log-files.md @@ -0,0 +1,36 @@ +# 2.17 确保 journald 日志压缩功能正确启用 + +## 安全等级 + +Level 1 + +## 描述 + +未经压缩的日志文件可能会填满硬盘,导致主机性能下降,资源不可用等问题。 + +journald 有大型日志文件压缩功能,应正确配置并启用该功能,以避免日志文件填满硬盘。 + +## 修复建议 + +目标:正确配置 journald 大型日志压缩功能。 + +1. 编辑`/etc/systemd/journald.conf`文件,增加如下代码: + +```shell +Compress=yes +``` + +## 扫描检测 + +确认 journald 日志压缩功能正确配置 + +1. 检查`/etc/systemd/journald.conf`文件,确认 journald 日志压缩功能被正确配置: + +```shell +# grep -e ^\s*Compress /etc/systemd/journald.conf +Compress=yes +``` + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.18-ensure-journald-is-configured-to-write-logfiles-to-persistent-disk.md b/benchmarks/logging-and-auditing/2.18-ensure-journald-is-configured-to-write-logfiles-to-persistent-disk.md new file mode 100644 index 0000000..770398e --- /dev/null +++ b/benchmarks/logging-and-auditing/2.18-ensure-journald-is-configured-to-write-logfiles-to-persistent-disk.md @@ -0,0 +1,35 @@ +# 2.18 确保 journald 日志文件写入硬盘功能正确开启 + +## 安全等级 + +Level 1 + +## 描述 + +journald 的日志数据既可以保存在内存中,也可以保存在本地硬盘中。 +内存中的日志在系统崩溃或重启后将会丢失。将日志数据写入硬盘,以保证数据的安全性。 + +## 修复建议 + +目标:正确配置 journald 日志写入硬盘功能。 + +1. 编辑`/etc/systemd/journald.conf`文件,增加如下代码: + +```shell +Storage=persistent +``` + +## 扫描检测 + +确认 journald 日志写入硬盘功能正确配置 + +1. 检查`/etc/systemd/journald.conf`文件,确认 journald 日志写入硬盘功能被正确配置。 + +```shell +# grep -e ^\s*Storage /etc/systemd/journald.conf +Storage=persistent +``` + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.2-ensure-only-authorized-users-own-audit-log-files.md b/benchmarks/logging-and-auditing/2.2-ensure-only-authorized-users-own-audit-log-files.md new file mode 100644 index 0000000..42a6008 --- /dev/null +++ b/benchmarks/logging-and-auditing/2.2-ensure-only-authorized-users-own-audit-log-files.md @@ -0,0 +1,52 @@ +# 2.2 确保审计日志文件的所有者为已授权用户 + +## 安全等级 + +Level 1 + +## 描述 + +审计信息(审计记录、审计设置、审计报告)含有系统配置、用户数据、登录信息、操作记录等敏感数据,需正确配置其所有者,避免数据泄露或丢失。 + +通过对审计日志文件的**所有者**进行配置,确保其只被已授权用户所拥有。 + +## 修复建议 + +目标:将审计日志文件的所有者配置为`root`用户。 + +1. 执行以下命令来确定审计日志的路径: + +```shell +# grep -iw log_file /etc/audit/auditd.conf +log_file = /var/log/audit/audit.log +``` + +2. 根据上一步得到的审计日志文件路径,执行以下命令,将其所有者配置为`root`用户: + +```shell +# chown root /var/log/audit/* +``` + +## 扫描检测 + +确保审计日志文件的所有者为`root`。 + +1. 执行以下命令来确定审计日志的路径: + +```shell +# grep -iw log_file /etc/audit/auditd.conf +log_file = /var/log/audit/audit.log +``` + +2. 根据上一步得到的审计日志文件路径,执行以下命令来检查审计日志文件的所有者是否为`root`: + +```shell +# stat -c "%n %U" /var/log/audit/* +/var/log/audit/audit.log root +``` + +如结果为`root`,则视为通过此项检查。 + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' diff --git a/benchmarks/logging-and-auditing/2.3-ensure-only-authorized-groups-ownership-of-audit-log-files.md b/benchmarks/logging-and-auditing/2.3-ensure-only-authorized-groups-ownership-of-audit-log-files.md new file mode 100644 index 0000000..ed24bad --- /dev/null +++ b/benchmarks/logging-and-auditing/2.3-ensure-only-authorized-groups-ownership-of-audit-log-files.md @@ -0,0 +1,70 @@ +# 2.3 确保审计日志文件的所属组为已授权的用户组 + +## 安全等级 + +Level 1 + +## 描述 + +审计信息(审计记录、审计设置、审计报告)含有系统配置、用户数据、登录信息、操作记录等敏感数据,需正确配置其所属组,避免数据泄露或丢失风险。 + +通过对审计日志文件**所属组**进行配置,确保其只被已授权用户组所拥有。 + +## 修复建议 + +目标:将审计日志文件的所属组配置为`adm`用户组。 + +1. 执行以下命令来确定审计日志的路径: + +```shell +# grep -iw ^log_file /etc/audit/auditd.conf +log_file = /var/log/audit/audit.log +``` + +2. 根据上一步得到的审计日志文件路径,执行以下命令,将其所属组配置为`adm`用户组: + +```shell +# chown :adm /var/log/audit/ +``` + +3. 将审计配置文件的`log_group`参数的值设置为`adm`,确保在新日志文件生成时,默认所属组为`adm`: + +```shell +# sed -i '/^log_group/D' /etc/audit/auditd.conf +# sed -i /^log_file/a'log_group = adm' /etc/audit/auditd.conf +``` + +4. 向`auditd`进程发送信号,使配置文件生效: + +```shell +# systemctl kill auditd -s SIGHUP +``` + +## 扫描检测 + +确保审计日志文件的所属组为`adm`。 + +1. 使用以下命令,验证`auditd.conf`(审计配置文件) `log_file`的值是否被正确设置为`adm`或`root`: + +```shell +# grep -iw log_group /etc/audit/auditd.conf +log_group = adm +``` + +2. 使用以下命令,确定审计日志文件的路径: + +```shell +$ sudo grep -iw log_file /etc/audit/auditd.conf +log_file = /var/log/audit/audit.log +``` + +3. 根据上一步得到的审计日志文件路径,执行以下命令,来验证审计日志文件的所属组是否为`adm`或`root`: + +```shell +# stat -c "%n %G" /var/log/audit/* +/var/log/audit/audit.log root +``` + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.4-ensure-the-audit-log-directory-is-0750-or-more-restrictive.md b/benchmarks/logging-and-auditing/2.4-ensure-the-audit-log-directory-is-0750-or-more-restrictive.md new file mode 100644 index 0000000..42cc52e --- /dev/null +++ b/benchmarks/logging-and-auditing/2.4-ensure-the-audit-log-directory-is-0750-or-more-restrictive.md @@ -0,0 +1,50 @@ +# 2.4 确保审计目录的权限小于 0750 + +## 安全等级 + +Level 1 + +## 描述 + +审计信息(审计记录、审计设置、审计报告)含有系统配置、用户数据、登录信息、操作记录等敏感数据。需正确配置其所在目录的权限,避免非授权用户篡改或删除审计数据,破坏审计信息的准确性,影响系统管理人员对恶意活动的发现和判断。 + +通过对**审计目录**的权限进行配置,确保其不被非授权用户篡改或删除。 + +## 修复建议 + +目标:确保审计目录的权限小于`0750` + +1. 执行以下命令来确定审计目录的路径: + +```shell +# grep -iw ^log_file /etc/audit/auditd.conf +log_file = /var/log/audit/audit.log +``` + +2. 根据上一步得到的审计目录路径,执行以下命令,将审计日志目录的权限配置为`0750`或更小: + +```shell +# chmod -R g-w,o-rwx /var/log/audit +``` + +## 扫描检测 + +确保审计目录的权限小于`0750` + +1. 执行以下命令来确定审计目录的路径: + +```shell +# grep -iw ^log_file /etc/audit/auditd.conf +log_file = /var/log/audit/audit.log +``` + +2. 根据上一步得到的审计目录路径,执行以下命令,检查审计目录的权限是否为`0750`或更小: + +```shell +# stat -c "%n %a" /var/log/audit /var/log/audit/* +/var/log/audit 750 +``` + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.5-ensure-audit-configuration-files-are-0640-or-more-restrictive.md b/benchmarks/logging-and-auditing/2.5-ensure-audit-configuration-files-are-0640-or-more-restrictive.md new file mode 100644 index 0000000..49a8824 --- /dev/null +++ b/benchmarks/logging-and-auditing/2.5-ensure-audit-configuration-files-are-0640-or-more-restrictive.md @@ -0,0 +1,46 @@ +# 2.5 确保审计配置文件的权限小于 0640 + +## 安全等级 + +Level 1 + +## 描述 + +审计配置文件影响审计的内容、审计的事件、日志保存路径等。如不对其权限进行限制,未经授权的人员可能会篡改审计配置文件,阻止其对关键事件的审计。破坏审计信息的准确性,影响系统管理人员对恶意活动的发现和判断。 + +错误的审计配置也可能会导致审计日志过载,从而降低系统性能。 + +通过对**审计配置文件**的权限进行配置,确保其不被非授权用户篡改或删除。 + +## 修复建议 + +目标:确保审计配置文件的权限小于`0640` + +1. 设置 `/etc/audit/audit.rules`, `/etc/audit/rules.d/*`, `/etc/audit/auditd.conf` 文件的权限为`0640`或更低: + +```shell +# chmod -R 0640 /etc/audit/audit*.{rules,conf} /etc/audit/rules.d/* +``` + +## 扫描检测 + +确保审计配置文件的权限小于`0640` + +1. 执行以下命令,确认 `/etc/audit/audit.rules`, `/etc/audit/rules.d/*`, `/etc/audit/auditd.conf` 文件的权限为`0640`或更低: + +```shell +# ls -al /etc/audit/ /etc/audit/rules.d/ +/etc/audit/: +-rw-r----- 1 root root 804 Nov 25 11:01 auditd.conf +-rw-r----- 1 root root 9128 Dec 27 09:56 audit.rules +-rw-r----- 1 root root 9373 Dec 27 09:56 audit.rules.prev +-rw-r----- 1 root root 127 Feb 7 2018 audit-stop.rules +drwxr-x--- 2 root root 4096 Dec 27 09:56 rules.d +/etc/audit/rules.d/: +-rw-r----- 1 root root 10357 Dec 27 09:56 stig.rules +``` + + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.6-ensure-only-authorized-accounts-own-the-audit-configuration-files.md b/benchmarks/logging-and-auditing/2.6-ensure-only-authorized-accounts-own-the-audit-configuration-files.md new file mode 100644 index 0000000..a0185fb --- /dev/null +++ b/benchmarks/logging-and-auditing/2.6-ensure-only-authorized-accounts-own-the-audit-configuration-files.md @@ -0,0 +1,51 @@ +# 2.6 确保审计配置文件的所有者为已授权用户 + +## 安全等级 + +Level 1 + +## 描述 + +审计配置文件影响审计的内容、审计的事件、日志保存路径等。如不对其所有者进行限制,未经授权的人员可能会篡改审计配置文件,阻止其对关键事件的审计。破坏审计信息的准确性,影响系统管理人员对恶意活动的发现和判断。 + +错误的审计配置也可能会导致审计日志过载,从而降低系统性能。 + +通过对审计配置文件的**所有者**进行配置,确保其不被非授权用户篡改或删除。 + +## 修复建议 + +目标:确保审计配置文件所有者为`root` + +1. 设置 `/etc/audit/audit.rules`, `/etc/audit/rules.d/*`, `/etc/audit/auditd.conf` 文件的所有者为`root`: + +```shell +# chown root /etc/audit/audit*.{rules,conf} /etc/audit/rules.d/* +``` + +## 扫描检测 + +确保审计配置文件所有者为`root` + +1. 执行以下命令,确认 `/etc/audit/audit.rules`, `/etc/audit/rules.d/*`, `/etc/audit/auditd.conf` 文件的所有者为`root`: + +```shell +# ls -al /etc/audit/ /etc/audit/rules.d/ +/etc/audit/: +drwxr-x--- 3 root root 4096 Nov 25 11:02 . +drwxr-xr-x 130 root root 12288 Dec 19 13:42 .. +-rw-r----- 1 root root 804 Nov 25 11:01 auditd.conf +-rw-r----- 1 root root 9128 Dec 27 09:56 audit.rules +-rw-r----- 1 root root 9373 Dec 27 09:56 audit.rules.prev +-rw-r----- 1 root root 127 Feb 7 2018 audit-stop.rules +drwxr-x--- 2 root root 4096 Dec 27 09:56 rules.d +/etc/audit/rules.d/: +drwxr-x--- 2 root root 4096 Dec 27 09:56 . +drwxr-x--- 3 root root 4096 Nov 25 11:02 .. +-rw-r----- 1 root root 10357 Dec 27 09:56 stig.rules +``` + +如所有文件的所有者均为`root`,则视为通过此项检查。 + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.7-ensure-only-authorized-groups-own-the-audit-configuration-files.md b/benchmarks/logging-and-auditing/2.7-ensure-only-authorized-groups-own-the-audit-configuration-files.md new file mode 100644 index 0000000..95dbf5e --- /dev/null +++ b/benchmarks/logging-and-auditing/2.7-ensure-only-authorized-groups-own-the-audit-configuration-files.md @@ -0,0 +1,47 @@ +# 2.7 确保审计配置文件的所属组为已授权的用户组 + +## 安全等级 + +Level 1 + +## 描述 + +审计配置文件影响审计的内容、审计的事件、日志保存路径等。如不对其所属组进行限制,未经授权的人员可能会篡改审计配置文件,阻止其对关键事件的审计。破坏审计信息的准确性,影响系统管理人员对恶意活动的发现和判断。 + +错误的审计配置也可能会导致审计日志过载,从而降低系统性能。 + +通过对审计配置文件的**所属组**进行配置,确保其不被非授权用户篡改或删除。 + +## 修复建议 + +目标:确保审计配置文件的所属组为`root` + +1. 设置 `/etc/audit/audit.rules`, `/etc/audit/rules.d/*`, `/etc/audit/auditd.conf` 文件的所属组为`root`: + +```shell +# chown :root /etc/audit/audit*.{rules,conf} /etc/audit/rules.d/* +``` + +## 扫描检测 + +确保审计配置文件所属组为`root` + +1. 执行以下命令,确认 `/etc/audit/audit.rules`, `/etc/audit/rules.d/*`, `/etc/audit/auditd.conf` 文件的所属组为`root`: + +```shell +# ls -al /etc/audit/ /etc/audit/rules.d/ +/etc/audit/: +-rw-r----- 1 root root 804 Nov 25 11:01 auditd.conf +-rw-r----- 1 root root 9128 Dec 27 09:56 audit.rules +-rw-r----- 1 root root 9373 Dec 27 09:56 audit.rules.prev +-rw-r----- 1 root root 127 Feb 7 2018 audit-stop.rules +drwxr-x--- 2 root root 4096 Dec 27 09:56 rules.d +/etc/audit/rules.d/: +-rw-r----- 1 root root 10357 Dec 27 09:56 stig.rules +``` + +如所有文件的所属组均为`root`,则视为通过此项检查。 + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.8-ensure-audit-tools-are-mode-of-0755-or-more-restrictive.md b/benchmarks/logging-and-auditing/2.8-ensure-audit-tools-are-mode-of-0755-or-more-restrictive.md new file mode 100644 index 0000000..74ce631 --- /dev/null +++ b/benchmarks/logging-and-auditing/2.8-ensure-audit-tools-are-mode-of-0755-or-more-restrictive.md @@ -0,0 +1,48 @@ +# 2.8 确保审计工具的权限为 0755 或更低 + +## 安全等级 + +Level 1 + +## 描述 + +审计工具包括但不限于:查看和操作审计信息所需的供应商或开源工具,如自定义查询和报告生成器等。因此,对审计工具的保护是非常必要的,以防未经授权的用户对审计信息进行提取或操作。 + +**审计工具**的权限必须为`0755`或更低。 + +## 修复建议 + +目标:确保审计工具的权限为`0755`或更低。 + +1. 使用以下命令将审计工具的权限设置为`0755`或更低: + +```shell +# chmod 0755 /sbin/auditctl +# chmod 0755 /sbin/aureport +# chmod 0755 /sbin/ausearch +# chmod 0755 /sbin/autrace +# chmod 0755 /sbin/auditd +# chmod 0755 /sbin/augenrules +``` + +## 扫描检测 + +确保审计工具的权限为`0755`或更低。 + +1. 执行以下命令,检查审计工具的权限是否为`0755`或更低: + +```shell +# stat -c "%n %a" /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace /sbin/auditd /sbin/augenrules +/sbin/auditctl 755 +/sbin/aureport 755 +/sbin/ausearch 755 +/sbin/autrace 750 +/sbin/auditd 755 +/sbin/augenrules 755 +``` + +如所有审计工具的权限均为`0755`或更低,则视为通过此项检查。 + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file diff --git a/benchmarks/logging-and-auditing/2.9-ensure-audit-tools-are-owned-by-root.md b/benchmarks/logging-and-auditing/2.9-ensure-audit-tools-are-owned-by-root.md new file mode 100644 index 0000000..5fc4c04 --- /dev/null +++ b/benchmarks/logging-and-auditing/2.9-ensure-audit-tools-are-owned-by-root.md @@ -0,0 +1,48 @@ +# 2.9 确保审计工具属于root用户 + +## 安全等级 + +Level 1 + +## 描述 + +审计工具包括但不限于:查看和操作审计信息所需的供应商或开源工具,如自定义查询和报告生成器等。因此,对审计工具的保护是非常必要的,以防未经授权的用户对审计信息进行提取或操作。 + +**审计工具**的所有者应为`root` + +## 修复建议 + +目标:确保审计工具的所有者为`root`。 + +1. 使用以下命令将审计工具的所有者设置为`root`: + +```shell +# chown root /sbin/auditctl +# chown root /sbin/aureport +# chown root /sbin/ausearch +# chown root /sbin/autrace +# chown root /sbin/auditd +# chown root /sbin/augenrules +``` + +## 扫描检测 + +确保审计工具的所有者为`root`。 + +1. 执行以下命令,检查审计工具的所有者是否为`root`: + +```shell +# stat -c "%n %U" /sbin/auditctl /sbin/aureport /sbin/ausearch /sbin/autrace /sbin/auditd /sbin/augenrules +/sbin/auditctl root +/sbin/aureport root +/sbin/ausearch root +/sbin/autrace root +/sbin/auditd root +/sbin/augenrules root +``` + +如所有审计工具的所有者均为`root`,则视为通过此项检查。 + +## 参考 + +- cis: 'https://www.cisecurity.org/benchmark/aliyun_linux' \ No newline at end of file -- Gitee