使用 OpenSCAP 确保系统安全

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

1. SCAP 简介

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

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

SUSE Multi-Linux 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。

在开始之前,请在客户端上安装 OpenSCAP 扫描程序和 SCAP 安全指南(内容)软件包。根据操作系统,这些软件包要么包含在基本操作系统中,要么包含在 SUSE Multi-Linux 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 and compatible systems provide a scap-security-guide package, which contains outdated contents. You are advised to use the scap-security-guide-redhat package you will find in the SUSE Multi-Linux Manager Client Tools.

SUSE provides the scap-security-guide package for different openscap profiles. In the current version of scap-security-guide, SUSE supports the following profiles:

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

  • 适用于 SUSE Linux Enterprise Server 12 和 15 的 ANSSI-BP-028 配置文件

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

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

  • SUSE Linux Enterprise Server for SAP Applications 15 的公有云映像强化

  • SUSE Linux Enterprise 15 的公有云强化

  • SLE 12 和 15 的标准系统安全性配置文件

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

3. OpenSCAP 内容文件

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

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

When you have created your content files, you need to transfer the file to the client. You can do this in the same way as you move any other file, using physical storage media, or across a network with Salt (for example, salt-cp or the Salt File Server), ftp or scp.

我们建议您创建一个软件包以将内容文件分发到使用 SUSE Multi-Linux 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.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 Multi-Linux Manager Web UI 触发审计扫描。还可以使用 SUSE Multi-Linux Manager API 来安排定期扫描。

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

  2. Navigate to the Audit tab, and the Schedule subtab.

  3. In the Path to XCCDF Document field, enter the parameters for the SCAP template and profile you want to use on the client. For example:

    • Command: /usr/bin/oscap xccdf eval

    • Command-line arguments: --profile xccdf_org.ssgproject.content_profile_stig

    • Path to XCCDF document: /usr/share/xml/scap/ssg/content/ssg-sle15-ds.xml

    If you use --fetch-remote-resources parameter a lot of RAM is required. In addition, you may need to increase the value of file_recv_max_size.

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

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

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

  2. Choose an existing script or create a script for scheduling a system scan through system.scap.scheduleXccdfScan. For example:

    #!/usr/bin/python3
    import xmlrpc.client
    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>')
    client.auth.logout(session_key)

    在此示例中:

    • <1000010001> is the system ID (sid).

    • <path_to_xccdf_file.xml> is the path to the content file location on the client. For example, /usr/share/xml/scap/ssg/content/ssg-sle15-ds.xml.

    • <profile_name> is an additional argument for the oscap command. For example, use united_states_government_configuration_baseline (USGCB).

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

6. 扫描结果

Information about the scans you have run is in the SUSE Multi-Linux Manager Web UI. Navigate to Audit  OpenSCAP  All Scans for a table of results. For more information about the data in this table, see All Scans.

To ensure that detailed information about scans is available, you need to enable it on the client. In the SUSE Multi-Linux Manager Web UI, navigate to Admin  Organizations and click on the organization the client is a part of. Navigate to the Configuration tab, and check the Enable Upload of Detailed SCAP Files option. When enabled, this generates an additional HTML file on every scan, which contains extra information. The results show an extra line similar to this:

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

To retrieve scan information from the command line, use the spacewalk-report command:

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

You can also use the SUSE Multi-Linux Manager API to view results, with the system.scap handler.

7. Removing SCAP Scan Results

Only SCAP scans that have passed the configured retention period can be deleted. You can configure the retention period in the Organization Configuration section.

Procedure: Configuring the SCAP results retention period
  1. Navigate to Home  My Organization  Configuration.

  2. Under SCAP, check Allow Deletion of SCAP Results.

  3. Enter a number of days in Allow Deletion After (default is 90).

Procedure: Deleting SCAP scan results
  1. Navigate to Audit  OpenSCAP  All Scans.

  2. Select the checkbox for the scan or scans you want to delete.

  3. Click Confirm.

8. 修复

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

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 运行这些脚本和剧本。

8.1. 使用 Bash 脚本运行修复

Install the scap-security-guide package on all your target systems. For more information, see 设置 Ansible 控制节点.

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

8.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 脚本示例 一节列出了示例。

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

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

  1. When a system group has been created click System Groups, select Use in SSM from the table.

  2. From the System Set Manager, under Misc  Remote Command, write a Bash script such as:

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

8.2. 修复 Bash 脚本示例

8.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

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

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

scap-security-guide in centos7-updates only contains the Red Hat Enterprise Linux script.

软件包

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

8.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

8.2.4. Debian Bash 脚本数据

Debian 脚本数据示例。

软件包

scap-security-guide-debian

通道
  • SUSE Manager 工具

Bash 脚本目录

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

Bash 脚本
# Debian 12
debian12-script-anssi_np_nt28_average.sh
debian12-script-anssi_np_nt28_high.sh
debian12-script-anssi_np_nt28_minimal.sh
debian12-script-anssi_np_nt28_restrictive.sh
debian12-script-standard.sh