使用 OpenSCAP 确保系统安全

SUSE Manager 使用 OpenSCAP 来审计客户端。它允许您为任何客户端安排合规性扫描并查看扫描结果。

1. 关于 SCAP

安全内容自动化协议 (SCAP) 是根据社区观点衍生出的一套综合性可互操作规范。它是由美国国家标准与技术研究院 (NIST) 维护的一系列规范,用于维持企业系统的系统安全性。

制定 SCAP 的目的是提供一种标准化方法来维持系统安全性,并且使用的标准会根据社区和企业的需求不断变化。新规范根据 NIST 的 SCAP 发布周期进行控制,以提供一致且可重复的修订工作流程。有关详细信息,请参见:

SUSE Manager 使用 OpenSCAP 来实现 SCAP 规范。OpenSCAP 是一个利用可扩展配置清单描述格式 (XCCDF) 的审计工具。XCCDF 是表达清单内容和定义安全清单的标准方式。它还结合了其他规范,例如通用平台枚举 (CPE)、通用配置枚举 (CCE) 及开放漏洞和评估语言 (OVAL),以创建 SCAP 表达的、可由 SCAP 验证过的产品处理的清单。

OpenSCAP 使用 SUSE 安全团队生成的内容来验证补丁是否存在。OpenSCAP 使用基于标准和规范的规则来检查系统安全配置设置,并检查系统是否存在遭受入侵的迹象。有关 SUSE 安全团队的详细信息,请参见 https://www.suse.com/support/security

2. 为客户端的 SCAP 扫描做好准备

在开始之前,需要为客户端系统的 SCAP 扫描做好准备。

OpenSCAP 审计在使用 SSH 联系方法的 Salt 客户端上不可用。

扫描客户端可能会消耗被扫描客户端的大量内存和计算能力。对于 Red Hat 客户端,请确保每个要扫描的客户端上至少有 2 GB 可用 RAM。

对于传统客户端和 Salt 客户端,请在开始之前安装 OpenSCAP 扫描程序和 SCAP 安全指南(内容)软件包。根据操作系统,这些软件包要么包含在基本操作系统中,要么包含在 SUSE Manager 客户端工具中。

下表根据客户端操作系统列出了所需的软件包:

Table 1. OpenSCAP 软件包
操作系统 扫描程序 内容

SLES

openscap-utils

scap-security-guide

openSUSE

openscap-utils

scap-security-guide

RHEL

openscap-utils

scap-security-guide-redhat

CentOS

openscap-utils

scap-security-guide-redhat

Oracle Linux

openscap-utils

scap-security-guide-redhat

Ubuntu

libopenscap8

scap-security-guide-ubuntu

Debian

libopenscap8

scap-security-guide-debian

RHEL 7 和兼容系统提供了一个 scap-security-guide 软件包,其中包含已过时的内容。建议您使用 SUSE Manager 客户端工具中的 scap-security-guide-redhat 软件包。

SUSE 为不同的 openscap 配置文件提供了 scap-security-guide 软件包。在当前版本的 scap-security-guide 中,SUSE 支持以下配置文件:

  • 适用于 SUSE Linux Enterprise Server 12 和 15 的 DISA STIG 配置文件

  • 适用于 SUSE Linux Enterprise Server 12 和 15 的 PCI-DSS 配置文件

  • 适用于 SUSE Linux Enterprise Server 12 和 15 的 HIPAA 配置文件

其他配置文件(例如 CIS 配置文件)由社区提供,SUSE 不为其提供官方支持。

对于非 SUSE 操作系统,包含的配置文件由社区提供。SUSE 不为其提供官方支持。

3. OpenSCAP 内容文件

OpenSCAP 使用 SCAP 内容文件来定义测试规则。这些内容文件是根据 XCCDF 或 OVAL 标准创建的。除了 SCAP 安全指南之外,您还可以下载公开的内容文件并根据要求对其进行自定义。可为默认内容文件模板安装 SCAP 安全指南软件包。或者,如果您熟悉 XCCDF 或 OVAL 的话,可以创建自己的内容文件。

我们建议您使用模板来创建自己的 SCAP 内容文件。如果您创建并使用自己的自定义内容文件,需要自负风险。如果您的系统因使用自定义内容文件而损坏,SUSE 可能不会为您提供支持。

创建内容文件后,需要将该文件传输到客户端。可以像移动任何其他文件一样,使用物理存储媒体传输该文件,或者使用 Salt(例如 salt-cpSalt 文件服务器)在网络上通过 ftpscp 传输该文件。

我们建议您创建一个软件包以将内容文件分发到使用 SUSE Manager 管理的客户端。可将软件包签名并对其进行校验以确保其完整性。有关详细信息,请参见 自定义通道

4. 查找 OpenSCAP 配置文件

不同的操作系统提供不同的 OpenSCAP 内容文件和配置文件。一个内容文件可以包含多个配置文件。

在基于 RPM 的操作系统上,可使用以下命令确定可用 SCAP 文件的位置:

rpm -ql <表中的 SCAP 安全指南软件包名称>

在基于 DEB 的操作系统上,可使用以下命令确定可用 SCAP 文件的位置:

dpkg -L <表中的 SCAP 安全指南软件包名称>

确定了一个符合您需求的 SCAP 内容文件后,列出客户端上可用的配置文件:

oscap info /usr/share/xml/scap/ssg/content/ssg-sle15-ds-1.2.xml
Document type: Source Data Stream
Imported: 2021-03-24T18:14:45

Stream: scap_org.open-scap_datastream_from_xccdf_ssg-sle15-xccdf-1.2.xml
Generated: (null)
Version: 1.2
Checklists:
        Ref-Id: scap_org.open-scap_cref_ssg-sle15-xccdf-1.2.xml
                Status: draft
                Generated: 2021-03-24
                Resolved: true
                Profiles:
                        Title: CIS SUSE Linux Enterprise 15 Benchmark
                                Id: xccdf_org.ssgproject.content_profile_cis
                        Title: Standard System Security Profile for SUSE Linux Enterprise 15
                                Id: xccdf_org.ssgproject.content_profile_standard
                        Title: DISA STIG for SUSE Linux Enterprise 15
                                Id: xccdf_org.ssgproject.content_profile_stig
                Referenced check files:
                        ssg-sle15-oval.xml
                                system: http://oval.mitre.org/XMLSchema/oval-definitions-5
                        ssg-sle15-ocil.xml
                                system: http://scap.nist.gov/schema/ocil/2
                        https://ftp.suse.com/pub/projects/security/oval/suse.linux.enterprise.15.xml
                                system: http://oval.mitre.org/XMLSchema/oval-definitions-5
Checks:
        Ref-Id: scap_org.open-scap_cref_ssg-sle15-oval.xml
        Ref-Id: scap_org.open-scap_cref_ssg-sle15-ocil.xml
        Ref-Id: scap_org.open-scap_cref_ssg-sle15-cpe-oval.xml
Dictionaries:
        Ref-Id: scap_org.open-scap_cref_ssg-sle15-cpe-dictionary.xml

记下用于执行扫描的文件路径和配置文件。

5. 执行审计扫描

安装或传输内容文件后,可以执行审计扫描。可以使用 SUSE Manager Web UI 触发审计扫描。还可以使用 SUSE Manager API 来安排定期扫描。

过程:从 Web UI 运行审计扫描
  1. 在 SUSE Manager Web UI 中,导航到系统  系统列表,然后选择要扫描的客户端。

  2. 依次导航到审计选项卡和日程安排子选项卡。

  3. XCCDF 文档的路径字段中,输入要在客户端上使用的 SCAP 模板和配置文件的参数。例如:

      命令:/usr/bin/oscap xccdf eval
      命令行参数:--profile xccdf_org.ssgproject.content_profile_stig
      XCCDF 文档的路径:/usr/share/xml/scap/ssg/content/ssg-sle15-ds-1.2.xml

    如果使用 --fetch-remote-resources 参数,将需要大量 RAM。此外,可能还需增加 file_recv_max_size 的值。

  4. 扫描将在客户端进行下一次安排的同步时运行。

XCCDF 内容文件在远程系统上运行之前会经过验证。如果内容文件包含无效参数,则测试将会失败。

过程:从 API 运行审计扫描
  1. 在开始之前,请确保要扫描的客户端上已安装 Python 和 XML-RPC 库。

  2. 选择现有的脚本或创建一个脚本,用于通过 system.scap.scheduleXccdfScan 安排系统扫描。例如:

    #!/usr/bin/python3
    client = xmlrpc.client.ServerProxy('https://server.example.com/rpc/api')
    key = client.auth.login('username', 'password')
    client.system.scap.scheduleXccdfScan(key, <1000010001>,
        '<path_to_xccdf_file.xml>',
        '--profile <profile_name>')

    在此示例中: * <1000010001> 是系统 ID (sid)。 * <path_to_xccdf_file.xml> 是指向客户端上的内容文件位置的路径。例如,/usr/share/xml/scap/ssg/content/ssg-sle15-ds-1.2.xml。 * <profile_name>oscap 命令的附加参数。例如,使用 united_states_government_configuration_baseline (USGCB)。

  3. 在命令提示符下,对您要扫描的客户端运行该脚本。

6. 扫描结果

有关已运行的扫描的信息将显示在 SUSE Manager Web UI 中。导航到审计  OpenSCAP  所有扫描可查看结果表。有关此表中的数据的详细信息,请参见 All Scans

为确保提供有关扫描的详细信息,需要在客户端上启用相应设置。在 SUSE Manager Web UI 中,导航到管理  组织并单击客户端所在的组织。导航到配置选项卡,并选中启用详细 SCAP 文件上载选项。启用后,每次扫描时都会额外生成一个包含附加信息的 HTML 文件。结果中会显示如下所示的附加行:

详细结果:xccdf-report.html xccdf-results.xml scap-yast2sec-oval.xml.result.xml

要从命令行检索扫描信息,请使用 spacewalk-report 命令:

spacewalk-report system-history-scap
spacewalk-report scap-scan
spacewalk-report scap-scan-results

还可以使用 SUSE Manager API 通过 system.scap 处理程序来查看结果。

7. 修复

相同 SCAP 安全指南软件包中提供了修复 Bash 脚本和 Ansible 剧本,以强化客户端系统。例如:

Listing 1. bash 脚本
/usr/share/scap-security-guide/bash/sle15-script-cis.sh
/usr/share/scap-security-guide/bash/sle15-script-standard.sh
/usr/share/scap-security-guide/bash/sle15-script-stig.sh
Listing 2. Ansible 剧本
/usr/share/scap-security-guide/ansible/sle15-playbook-cis.yml
/usr/share/scap-security-guide/ansible/sle15-playbook-standard.yml
/usr/share/scap-security-guide/ansible/sle15-playbook-stig.yml

在客户端系统中启用 Ansible 后,可以使用远程命令或 Ansible 运行这些脚本和剧本。

7.1. 使用 Bash 脚本运行修复

在所有目标系统上安装 scap-security-guide 软件包。有关详细信息,请参见 设置 Ansible 控制节点

用于每个操作系统和发行套件的软件包、通道和脚本都不同。修复 Bash 脚本示例 一节中列出了示例。

7.1.1. 在单个系统上将 Bash 脚本作为远程命令运行

在单个系统上将 Bash 脚本作为远程命令运行。

  1. 系统  概览选项卡中选择您的实例。然后在细节  远程命令中编写一个 Bash 脚本,例如:

    #!/bin/bash
    chmod +x -R /usr/share/scap-security-guide/bash
    /usr/share/scap-security-guide/bash/sle15-script-stig.sh
  2. 单击 日程安排

文件夹和脚本名称在每个发行套件和版本中有差别。修复 Bash 脚本示例 一节列出了示例。

7.1.2. 在多个系统上使用系统集管理器运行 Bash 脚本

一次性在多个系统上将 Bash 脚本作为远程命令运行。

  1. 创建系统组后,单击系统组并从表中选择在 SSM 中使用

  2. 系统集管理器中的其他  远程命令下编写一个 Bash 脚本,例如:

    #!/bin/bash
    chmod +x -R /usr/share/scap-security-guide/bash
    /usr/share/scap-security-guide/bash/sle15-script-stig.sh
  3. 单击 日程安排

7.2. 修复 Bash 脚本示例

7.2.1. SUSE Linux Enterprise openSUSE 和变体

SUSE Linux Enterprise 和 openSUSE 脚本数据示例。

软件包

scap-security-guide

通道
  • SLE12:SLES12 更新

  • SLE15:SLES15 模块 Basesystem 更新

Bash 脚本目录

/usr/share/scap-security-guide/bash/

Bash 脚本
opensuse-script-standard.sh
sle12-script-standard.sh
sle12-script-stig.sh
sle15-script-cis.sh
sle15-script-standard.sh
sle15-script-stig.sh

7.2.2. Red Hat Enterprise Linux 和 CentOS Bash 脚本数据

Red Hat Enterprise Linux 和 CentOS 脚本数据示例。

centos7-updates 中的 scap-security-guide 仅包含 Red Hat Enterprise Linux 脚本。

软件包

scap-security-guide-redhat

通道
  • SUSE Manager 工具

Bash 脚本目录

/usr/share/scap-security-guide/bash/

Bash 脚本
centos7-script-pci-dss.sh
centos7-script-standard.sh
centos8-script-pci-dss.sh
centos8-script-standard.sh
fedora-script-ospp.sh
fedora-script-pci-dss.sh
fedora-script-standard.sh
ol7-script-anssi_nt28_enhanced.sh
ol7-script-anssi_nt28_high.sh
ol7-script-anssi_nt28_intermediary.sh
ol7-script-anssi_nt28_minimal.sh
ol7-script-cjis.sh
ol7-script-cui.sh
ol7-script-e8.sh
ol7-script-hipaa.sh
ol7-script-ospp.sh
ol7-script-pci-dss.sh
ol7-script-sap.sh
ol7-script-standard.sh
ol7-script-stig.sh
ol8-script-anssi_bp28_enhanced.sh
ol8-script-anssi_bp28_high.sh
ol8-script-anssi_bp28_intermediary.sh
ol8-script-anssi_bp28_minimal.sh
ol8-script-cjis.sh
ol8-script-cui.sh
ol8-script-e8.sh
ol8-script-hipaa.sh
ol8-script-ospp.sh
ol8-script-pci-dss.sh
ol8-script-standard.sh
rhel7-script-anssi_nt28_enhanced.sh
rhel7-script-anssi_nt28_high.sh
rhel7-script-anssi_nt28_intermediary.sh
rhel7-script-anssi_nt28_minimal.sh
rhel7-script-C2S.sh
rhel7-script-cis.sh
rhel7-script-cjis.sh
rhel7-script-cui.sh
rhel7-script-e8.sh
rhel7-script-hipaa.sh
rhel7-script-ncp.sh
rhel7-script-ospp.sh
rhel7-script-pci-dss.sh
rhel7-script-rhelh-stig.sh
rhel7-script-rhelh-vpp.sh
rhel7-script-rht-ccp.sh
rhel7-script-standard.sh
rhel7-script-stig_gui.sh
rhel7-script-stig.sh
rhel8-script-anssi_bp28_enhanced.sh
rhel8-script-anssi_bp28_high.sh
rhel8-script-anssi_bp28_intermediary.sh
rhel8-script-anssi_bp28_minimal.sh
rhel8-script-cis.sh
rhel8-script-cjis.sh
rhel8-script-cui.sh
rhel8-script-e8.sh
rhel8-script-hipaa.sh
rhel8-script-ism_o.sh
rhel8-script-ospp.sh
rhel8-script-pci-dss.sh
rhel8-script-rhelh-stig.sh
rhel8-script-rhelh-vpp.sh
rhel8-script-rht-ccp.sh
rhel8-script-standard.sh
rhel8-script-stig_gui.sh
rhel8-script-stig.sh
rhel9-script-pci-dss.sh
rhosp10-script-cui.sh
rhosp10-script-stig.sh
rhosp13-script-stig.sh
rhv4-script-pci-dss.sh
rhv4-script-rhvh-stig.sh
rhv4-script-rhvh-vpp.sh
sl7-script-pci-dss.sh
sl7-script-standard.sh

7.2.3. Ubuntu Bash 脚本数据

Ubuntu 脚本数据示例。

软件包

scap-security-guide-ubuntu

通道
  • SUSE Manager 工具

Bash 脚本目录

/usr/share/scap-security-guide/

Bash 脚本
ubuntu1804-script-anssi_np_nt28_average.sh
ubuntu1804-script-anssi_np_nt28_high.sh
ubuntu1804-script-anssi_np_nt28_minimal.sh
ubuntu1804-script-anssi_np_nt28_restrictive.sh
ubuntu1804-script-cis.sh
ubuntu1804-script-standard.sh
ubuntu2004-script-standard.sh

7.2.4. Debian Bash 脚本数据

Debian 脚本数据示例。

软件包

scap-security-guide-debian

通道
  • SUSE Manager 工具

Bash 脚本目录

/usr/share/scap-security-guide/bash/

Bash 脚本
debian10-script-anssi_np_nt28_average.sh
debian10-script-anssi_np_nt28_high.sh
debian10-script-anssi_np_nt28_minimal.sh
debian10-script-anssi_np_nt28_restrictive.sh
debian10-script-standard.sh
debian11-script-anssi_np_nt28_average.sh
debian11-script-anssi_np_nt28_high.sh
debian11-script-anssi_np_nt28_minimal.sh
debian11-script-anssi_np_nt28_restrictive.sh
debian11-script-standard.sh