[安全] OpenSCAP 系统漏洞扫描及加固解决方案
![[安全] OpenSCAP 系统漏洞扫描及加固解决方案](../joshua-sortino-LqKhnDzSF-8-unsplash.jpg)
OpenSCAP 系统漏洞扫描及加固解决方案
为什么需要漏洞扫描
- 需要周期性的对EC2进行漏洞扫描,并需要打补丁。
- 操作系统多, Linux (Amzn2 Linux, Centos, Redhat, Ubuntu, Windows..)
- 多种合规性框架,例如PCI-DSS, GDPR等。
- Inspector 中国没有GA。
- 需要开源-白盒规则,并且规则可扩充。
- 方案低成本。
什么是SCAP
SCAP 的全称是Security Content Automation Protocol, 翻译过来就是安全内容自动化协议,它其实是一套由美国国家标准与技术研究院(NIST)提出来的信息安全评估标准体系及维护的一系列规范。
SCAP (安全内容自动化协议)标准的。SCAP 是一种综合的可互操作的规范,这种规范对格式与术语进行了标准化,通过这种标准化的规范向人类和机器传达软件缺陷以及安全配置信息。SCAP 是一种多用途的框架规范,它支持自动化配置、漏洞和补丁检查、技术控制达标活动以及安全性度量。
SCAP 是一个独立于供应商外用于表达安全策略的方式,因此它被广泛的应用于现代企业中。 SCAP 的规格打造了一个生态系统,其中安全性内容的格式著名且标准,同时扫描或者策略编辑的执行也不是强制性的。
建议对使用SCAP (安全内容自动化协议)标准针对服务器进行漏洞扫描以用于合规审计。 期望通过SCAP解决如下三个问题:
- 实现政策法规及合规框架的实际落地,例如ISO27000等。
- 希望将信息安全所涉及的各个要素标准化,例如统一的漏洞命令,危害程度度量。
- 尽可能的将系统的漏洞扫描机配置工作自动化。
什么是OpenScap
虽然市场上有各种各样的基础设施扫描工具,但其中大部分是商业的,但如果希望使用任何企业都可以采用的开源解决方案,我们将考虑免费提供的 OpenSCAP 工具。
OpenSCAP 被设计为在本地系统上执行配置和漏洞扫描,验证安全合规性内容,以及生成基于这些扫描与评估的报告和指南,OpenSCAP基本上是一种用开放性标准实现自动化脆弱性管理、衡量和策略 符合性评估的方法。 OpenSCAP由Redhat主导开发,是一个整合了SCAP中各标准的开源框架,其为SCAP的使用者提供了一套简单易用的接口。 已被包括 Red Hat 在内的企业 Linux 供应商广泛采用。因此,我们将探索为合规性扫描和报告设置您自己的 OpenSCAP 基础设施的过程。反过来,这将使所有对基础设施安全有既得利益的团队能够监督合规性水平。
SCAP代表安全内容自动化协议,它是一个标准化的解决方案,用于检查 Linux 基础设施是否符合给定的安全策略(在我们的例子中是 CIS)。
System Context
方案逻辑架构
方案详细架构
OpenSCAP 所能检测的范围
OpenSCAP 扫描结果例子
OpenSCAP 逻辑关系
SCAP 组件
SCAP 规范可以分为三个部分
- 检查表和测试规范语言及报告
- 安全信息的枚举(字典)
- 漏洞测量及评分系统。
SCAP包含了Protocol(协议)与Content(内容),协议是指SCAP由一系列现有的公开标准构成,这些公开标准被称为SCAP Element(SCAP元素),Protocol规范了这些Element之间如何协同工作。Content指按照Protocol的约定,利用Element描述的生成应用于实际检查工作的数据。
SCAP元素的三种类型: 1、语言类,用来描述评估内容和评估方法的标准,包括了XCCDF和OVAL(1.2版SCAP添加了OCIL)。 2、枚举类,描述对评估对象或配置项命名格式,并提供遵循这些命名的库,包括了CVE、CCE、CPE; 3、度量类,提供了对评估结果进行量化评分的度量方法,对应的元素是CVSS(1.2版SCAP添加了CCSS)。
From http://www.what21.com/a/view/it_3_1470365835242.html
SCAP包含六个SCAP元素:XCCDF、OVAL、CVE、CCE、CPE、CVSS。
XCCDF元素: XCCDF是由NSA(National Security Agency:美国国家安全局)与NIST共同开发,是一种用来定义安全检查单、安全基线、以及其他类似文档的一种描述语言。XCCDF使用标准的XML语言格式按照一定的格式(Schema)对其内容进行描述。在SCAP中,XCCDF完成两件工作:一是描述自动化的配置检查单(Checkilist),二是描述安全配置指南和安全扫描报告。一个XCCDF 文档包含一个或多个Profile,每个Profile可以理解为一个检查单。
OVAL元素: OVAL由MITRE公司开发,是一种用来定义检查项、脆弱点等技术细节的一种描述语言。OVAL使用了标准的XML格式内容。可以用于分析Windows、Linux等各种操作系统的系统状态、漏洞、配置、补丁等情况,而且还能用于描述测试报告。OVAL的本质是Open(公开)。
CVE元素: CVE(Common Vulnerabilities andExposures:通用漏洞及披露)是包含了公众已知的信息安全漏洞的信息和披露的集合。CCE(Common Configuration Enumeration:通用配置枚举)是用于描述计算机及设备配置的标准化语言。CPE(Common Platform Enumeration:通用平台枚举)是一种对应用程序、操作系统以及硬件设备进行描述和标识的标准化方案。
CVSS元素: CVSS(Common Vulnerability Scoring System:通用漏洞评分系统)是一个行业公开标准,其被设计用来评测漏洞的严重程度,并帮助确定其紧急度和重要度。在SCAP版本1.2中,引入了另外两个新标准:OCIL(Open Checklist Interactive Language:开放检查单交互语言)和CCSS(Common Configuration Scoring System:通用配置评分系统)。OCIL能够用来处理安全检查中需要人工交互反馈才能完成的检查项,CCSS作用与CVSS类似,不过CCSS关注的是系统配置缺陷的严重程度。
SCAP内容: SCAP Content指的是遵照SCAP Protocol标准设计制作的用于自动化评估的数据,其实体是一个或多个XML文件。一般来说正式发布的SCAP Content至少包含两个XML文件,一个是XCCDF,另一个是OVAL,这些文件能够直接输入到各类安全工具中执行实际的系统扫描。Content中也可以包含描述其他SCAPElement的XML文件。按照SCAP Protocol标准组织的多个XML 文件也被称为SCAP Data Stream(SCAP数据流)。
概述
oscap 工具可以针对由两方代表的 SCAP 内容扫描系统,这两方包括XCCDF
(可扩展的配置检查清单描述格式)基准和 OVAL
(开放弱点评估语言)定义。安全策略可以以单独的OVAL文件或者XCCDF文件的形式存在,也可以以多个单独的 XML 文件的形式存在 ,这里每个 XML 文件代表了不同的组件(XCCDF, OVAL, CPE, CVE, 还有其他)。扫描结果可以打印为两种,标准输出和 XML 文件。结果文件可以经由 oscap 做进一步处理以便生成可读的报告。
- 语言 — 这组由 SCAP 语言组成,为表达合规策略定义了标准的词汇和约定。
- 拓展配置清单描述格式 (XCCDF) — 一种为表达、组织和管理安全指导的语言。
- 开放脆弱性和评估语言 (OVAL) — 一种被开发出来为已经过扫描的系统执行逻辑声明的语言。
- 开放清单互动语言 (OCIL) — 一种被设计用来为查询用户提供标准方法,解读用户对于给定问题的反馈的语言。
- 资产识别 (AI) — 一种被开发用于提供数据模型、研究方法以及引导鉴别安全资产的语言。
- 资产报告格式 (ARF) — 一种经过设计的语言,主要用来表达信息的传输格式,而这些信息则包含了收集好的安全资源,以及资源和安全报告之间的关系。
- 枚举 — 本组包含 SCAP 标准定义的命名格式,以及从某些与安全相关领域利益相关而产生的项目的官方清单或者字典。
- 普通参数枚举 (CCE) — 一种为应用程序和操作系统的安全相关的配置元素所列出的枚举。
- 普通平台枚举 (CPE) — 一种结构化的命名方案,通常用来识别信息技术(IT)系统、平台以及软件包。
- 普通漏洞与危险性 (CVE) — 一种可用于参考公开的软件漏洞与风险集的方法。
- 度量 — 这组由一系列框架组成,用于识别和评估安全风险。
- 普通参数划分系统(CCSS) — 一种用于评估与安全相关的配置元素的度量系统,同时它也可以以打分的方式帮助用户优先考虑适当的应对措施。
- 普通漏洞划分系统 (CVSS) — 一种用于评估软件安全隐患的度量系统,同时它也可以以打分的方式帮助用户优先应对安全风险。
- 完整性 — 一种维护 SCAP 内容与扫描结果完整性的 SCAP 规范。
- 信任模型的安全自动化数据 (TMSAD) — 一组建议,这些推荐解释了现有规范的使用方法,在安全自动化领域里的 XML 文件上下文环境中,用来代表签名、哈希值、关键信息以及身份信息。
每个 SCAP 组件都有自己的基于 XML 的文档格式及 XML 名称空间。一个 SCAP 中所表达的合规策略既可以采用单个 OVAL 定义的 XML 文件、数据流文件和单个 zip 档案的方式,又可以采用一组各自包含表示策略清单的 XCCDF 文件的 XML 文件集这样的方式。
SCAP组件除其他外包括:
- CVE - Common Vulnerabilities and Exposures 常见脆弱性和暴露
- CPE- Common Platform Enumeration 公共平台枚举
- CCE - Common Platform Enumeration 常见配置枚举
- CVSS - Common Vulnerability Scoring System 通用漏洞评分系统
- OVAL - Open Vulnerability and Assessment Language 开放漏洞和评估语言
- OCIL - Open Checklist Interactive Language 开放核对表交互式语言
- XCCDFn - Extensible Configuration Checklist Description Format可扩展配置清单描述格式
XCCDF与OVAL
XCCDF 是由NSA(National Security Agency:美国国家安全局)与NIST共同开发,是一种用来定义安全检查单、安全基线、以及其他类似文档的一种描述语言。XCCDF使用标准的XML语言格式按照一定的格式(Schema)对其内容进行描述。在SCAP中,XCCDF完成两件工作:一是描述自动化的配置检查单(Checkilist),二是描述安全配置指南和安全扫描报告。一个XCCDF 文档包含一个或多个Profile,每个Profile可以理解为一个检查单。
使用XCCDF无疑有许多好处,通过标准化能够让工具间的数据交换变得更加容易,能够很方便地根据目标系统的不同情况对检查项进行裁剪,而且无论是检查单还是检查结果能够很容易地转换成机器或人工能够读取的格式。
OVAL由MITRE公司开发,是一种用来定义检查项、脆弱点等技术细节的一种描述语言。OVAL同样使用标准的XML格式来组织其内容。OVAL语言提供了足够的灵活性,可以用于分析Windows、Linux等各种操作系统的系统状态、漏洞、配置、补丁等情况,而且还能用于描述测试报告。OVAL使用简洁的XML格式清晰地对与安全相关的系统检查点作出描述,并且这种描述是机器可读的,能够直接应用到自动化的安全扫描中。OVAL的本质是Open(公开),这就意味着任何人都可以为OVAL的发展作出自己的贡献,共享知识和经验,避免重复劳动。
XCCDF设计的目标是能够支持与多种基础配置检查技术交互。其中推荐的、默认的检查技术是MITRE公司的OVAL。在实际的SCAP应用中,XCCDF和OVAL往往是成对出现。
开放式漏洞评估语言 (OVAL) 文件
OVAL(开放式漏洞评估语言)是 SCAP 中必不可少的和最初始的组成部分。OVAL 标准的主要目标是开启安全产品之间的互通互用能力。这由下面三个领域的标准化实现:
- 目标系统配置的表现。
- 为特定机器状态的存在而对目标系统所做的分析。
- 报告指定机器状态和受观测机器状态之间的比较结果。
有别于其他工具或者自定义脚本,OVAL 语言以声明的形式描述了资源的理想状态。OVAL 语言代码不能被直接执行,而是依靠一个叫做 扫描软件的 OVAL 解释工具去执行。OVAL 所具备的声明性质保证了受评估系统的状态不会被意外地改变,这一点是非常重要的,因为安全扫描工具通常运行在可能获取的最高权限上。
OVAL 规范对公众意见与贡献、各类与 MITRE 合作的 IT 公司,以及由联邦政府资助的非营利组织开放。OVAL 规范一直在持续地进化中,不同版本间通过版本号进行区分。当前版本5.10.1发布于2012年1月。
类似所有其他的 SCAP 组件,OVAL 基于 XML 。OVAL 标准定义了几种文档格式。它们各自包含了不同种类的信息,服务于不同的目的。 OVAL 文档格式
- OVAL Definitions 格式是最常见的 OVAL 文件格式,直接用于系统扫描。OVAL定义文档描述了目标系统的理想状态。
- OVAL Variables 格式定义了一些变量用于修改 OVAL 定义文档。OVAL 变量文档通常与 OVAL 定义文件一起使用,以调整目标系统在运行时的安全内容。
- OVAL System Characteristics 格式保存有关评估系统的信息。OVAL 系统特性文档通常用于实际系统状态与 OVAL 定义文档中所定义的预期状态进行比对。
- OVAL Results 是用来报告系统评估结果的最全面的 OVAL 格式。OVAL 结果文档通常包括受评估 OVAL 定义的副本、受约束的 OVAL 变量、OVAL 系统特性以及经过计算的基于系统特性和定义的测试结果。
- OVAL Directives 格式通过包括或者排除某些细节的方式对 OVAL 结果文档中的冗余部分加以调整。
- OVAL Common Model 格式包含了用于其他几种 OVAL 方案中的构造和枚举的定义。它被用来再次利用 OVAL 定义,这样就可以避免在多个文档中发生重复的现象。
OVAL定义文档由一组配置需求所组成,每组需求在以下五个基本层面做了定义:定义、 测试、目标、声明, 和 变量。 定义部分内的元素描述了哪些测试应该被实现以便满足给定的定义。测试元素将对象与状态联系在了一起。在系统评估过程中,当一个受评估系统的资源可以用给定对象元素符合给定状态元素来表示,那么这个测试就会被认为是通过的。 变量部分定义了外部变量,这些外部变量可能被用于调整来自状态部分的元素。除了这些部分以外, OVAL 定义文档通常也包括 发生器 和 签名 部分。发生器 部分保存有关文档来源的信息以及各种与自身内容相关的额外信息。
XCCDF - 拓展配置清单描述格式
XCCDF 语言被设计为支持信息交换、文档生成、组织化和情境化调整、自动一致性测试以及符合性评分。该语言主要是描述性质的,并不包含任何用来执行安全扫描的命令。然而,XCCDF 文档可以作为其他 SCAP 组件的参考,而且就其本身而言,它也可以被用于制作合规策略,移植到除相关的评估文档(OVAL、 OCIL)以外的所有目标平台。
通常,可以用一组 XML 文件中包含一个 XCCDF 清单的方法来表示合规策略。该 XCCDF 文件通常指向了评估资源、多重 OVAL,OCIL 以及脚本检查引擎(SCE)文件。此外,该文件集可以包含有 CPE 字典文件和为此字典定义了对象的 OVAL 文件。
作为一种基于 XML 的语言,XCCDF 定义并使用了大量可供选择的 XML 元素以及特性。下表简要介绍了主要的 XCCDF 元素;有关 XCCDF 更多的细节,请查阅 NIST跨机构报告7275 第 4修订版.
OpenScap 构成
SCAP workbench
SCAP Workbench (scap-workbench) 是一个图形化的工具,它允许用户在本地或远程系统上执行配置和漏洞扫描,实现系统的修复,以及生成基于扫描评估的报告。需要注意的是,与 oscap 命令行实用工具比起来,SCAP 工作台只具备有限的功能。SCAP 工作台也可以处理只以 XCCDF 文件和数据流文件形式存在的安全内容。
SCAP Workbench — scap-workbench
图形化工具被设计为在单一的本地或者远程系统上执行配置和漏洞扫描。此外该工具也可以被用来生成基于这些扫描与评估的安全报告。
OSCAP
要使用OpenSCAP执行任何任务,你还需要具有 SCAP格式的安全策略。
1yum install scap-security-guide
oscap 命令行工具允许用户扫描本地系统, 验证安全合规内容,生成基于这些系统扫描与评估的报告和指南。该工具作为一个 OpenSCAP 库的前端,基于它处理的一种类型的 SCAP 内容,将其功能分组模块化(子命令)。
OpenSCAP — oscap 命令行实用工具被设计为在本地系统上执行配置和漏洞扫描,验证安全合规性内容,以及生成基于这些扫描与评估的报告和指南。
oscap 命令行工具允许用户扫描本地系统, 验证安全合规内容,生成基于这些系统扫描与评估的报告和指南。该工具作为一个 OpenSCAP 库的前端,基于它处理的一种类型的 SCAP 内容,将其功能分组模块化(子命令)。
OS | FileName | ||
---|---|---|---|
Amazon Linux 2 | ssg-amzn2-ds.xml | ||
Amazon Linux 2 | ssg-amzn2-xccdf.xml | ||
CentOS 6 | ssg-centos6-ds.xml | ||
CentOS 6 | ssg-centos6-xccdf.xml | ||
CentOS 7 | ssg-centos7-ds.xml | ||
CentOS 7 | ssg-centos7-xccdf.xml | ||
Firefox | ssg-firefox-cpe-dictionary.xml | ||
Firefox | ssg-firefox-cpe-oval.xml | ||
Firefox | ssg-firefox-ds.xml | ||
Firefox | ssg-firefox-ocil.xml | ||
Firefox | ssg-firefox-oval.xml | ||
Firefox | ssg-firefox-xccdf.xml | ||
Java JRE | ssg-jre-cpe-dictionary.xml | ||
Java JRE | ssg-jre-cpe-oval.xml | ||
Java JRE | ssg-jre-ds.xml | ||
Java JRE | ssg-jre-ocil.xml | ||
Java JRE | ssg-jre-oval.xml | ||
Java JRE | ssg-jre-xccdf.xml | ||
Redhat 6 | ssg-rhel6-cpe-dictionary.xml | ||
Redhat 6 | ssg-rhel6-cpe-oval.xml | ||
Redhat 6 | ssg-rhel6-ds.xml | ||
Redhat 6 | ssg-rhel6-ocil.xml | ||
Redhat 6 | ssg-rhel6-oval.xml | ||
Redhat 6 | ssg-rhel6-xccdf.xml | ||
Redhat 7 | ssg-rhel7-cpe-dictionary.xml | ||
Redhat 7 | ssg-rhel7-cpe-oval.xml | ||
Redhat 7 | ssg-rhel7-ds.xml | ||
Redhat 7 | ssg-rhel7-ocil.xml | ||
Redhat 7 | ssg-rhel7-oval.xml | ||
Redhat 7 | ssg-rhel7-xccdf.xml |
OSCAP 安装
此命令允许您安装保证 oscap 正常运行所需的所有安装包,包括提供实用工具自身的 openscap 软件包。如果您想编写您自己的安全内容,您也应该安装 openscap-engine-sce 包,这个安装包提供了脚本检查引擎(SCE)。SCE 是 SCAP 的一个扩展协议,允许内容作者使用脚本语言去编写自己的安全内容,例如 Bash 语言,Python 语言或者 Ruby 语言。该安装包可以以和 openscap-utils 软件包同样的方式进行安装。
根据需要,在安装完 oscap 后,您可以检查您所安装 oscap 版本的功能,比如它支持什么样的规格,某个 oscap文件储存在什么位置,能使用什么样的 SCAP 对象,以及其他有用的信息。
为了安装 oscap 到您的系统中,需要以 root
用户身份运行以下命令:
1`yum install openscap``-``utils`
2`yum install openscap``-``scanner
3yum install scap-security-guide
4`
ubuntu 安装 openscap
1apt-get install libopenscap8
扫描
1
SCAP内容将安装在***/usr/share/xml/scap/ssg/content/中***。当SCAP内容导入或安装在您的系统上时,oscap
可以通过指定内容的文件路径来处理内容。oscap
支持SCAP 1.2,并向后兼容SCAP 1.1和SCAP 1.0。导入和处理SCAP内容的早期版本不需要特殊处理。
验证 OSCAP 是否安装成功
1oscap -V
输出
1OpenSCAP command line tool (oscap) 1.2.17
2Copyright 2009--2017 Red Hat Inc., Durham, North Carolina.
3
4==== Supported specifications ====
5XCCDF Version: 1.2
6OVAL Version: 5.11.1
7CPE Version: 2.3
8CVSS Version: 2.0
9CVE Version: 2.0
10Asset Identification Version: 1.1
11Asset Reporting Format Version: 1.1
12CVRF Version: 1.1
13
14==== Capabilities added by auto-loaded plugins ====
15No plugins have been auto-loaded...
16
17==== Paths ====
18Schema files: /usr/share/openscap/schemas
19Default CPE files: /usr/share/openscap/cpe
20Probes: /usr/libexec/openscap
21
22==== Inbuilt CPE names ====
23Red Hat Enterprise Linux - cpe:/o:redhat:enterprise_linux
24Red Hat Enterprise Linux 5 - cpe:/o:redhat:enterprise_linux:5
25Red Hat Enterprise Linux 6 - cpe:/o:redhat:enterprise_linux:6
26Red Hat Enterprise Linux 7 - cpe:/o:redhat:enterprise_linux:7
27Oracle Linux 5 - cpe:/o:oracle:linux:5
28Oracle Linux 6 - cpe:/o:oracle:linux:6
29Oracle Linux 7 - cpe:/o:oracle:linux:7
30Community Enterprise Operating System 5 - cpe:/o:centos:centos:5
31Community Enterprise Operating System 6 - cpe:/o:centos:centos:6
32Community Enterprise Operating System 7 - cpe:/o:centos:centos:7
33Amazon Linux 2 - cpe:/o:amazon:amazon_linux:2
34Scientific Linux 5 - cpe:/o:scientificlinux:scientificlinux:5
35Scientific Linux 6 - cpe:/o:scientificlinux:scientificlinux:6
36Scientific Linux 7 - cpe:/o:scientificlinux:scientificlinux:7
37Fedora 16 - cpe:/o:fedoraproject:fedora:16
38Fedora 17 - cpe:/o:fedoraproject:fedora:17
39Fedora 18 - cpe:/o:fedoraproject:fedora:18
40Fedora 19 - cpe:/o:fedoraproject:fedora:19
41Fedora 20 - cpe:/o:fedoraproject:fedora:20
42Fedora 21 - cpe:/o:fedoraproject:fedora:21
43Fedora 22 - cpe:/o:fedoraproject:fedora:22
44Fedora 23 - cpe:/o:fedoraproject:fedora:23
45Fedora 24 - cpe:/o:fedoraproject:fedora:24
46Fedora 25 - cpe:/o:fedoraproject:fedora:25
47Fedora 26 - cpe:/o:fedoraproject:fedora:26
48Fedora 27 - cpe:/o:fedoraproject:fedora:27
49Fedora 28 - cpe:/o:fedoraproject:fedora:28
50Fedora 29 - cpe:/o:fedoraproject:fedora:29
51SUSE Linux Enterprise all versions - cpe:/o:suse:sle
52SUSE Linux Enterprise Server 10 - cpe:/o:suse:sles:10
53SUSE Linux Enterprise Desktop 10 - cpe:/o:suse:sled:10
54SUSE Linux Enterprise Server 11 - cpe:/o:suse:linux_enterprise_server:11
55SUSE Linux Enterprise Desktop 11 - cpe:/o:suse:linux_enterprise_desktop:11
56SUSE Linux Enterprise Server 12 - cpe:/o:suse:sles:12
57SUSE Linux Enterprise Desktop 12 - cpe:/o:suse:sled:12
58openSUSE 11.4 - cpe:/o:opensuse:opensuse:11.4
59openSUSE 13.1 - cpe:/o:opensuse:opensuse:13.1
60openSUSE 13.2 - cpe:/o:opensuse:opensuse:13.2
61openSUSE 42.1 - cpe:/o:novell:leap:42.1
62openSUSE 42.2 - cpe:/o:novell:leap:42.2
63openSUSE All Versions - cpe:/o:opensuse:opensuse
64Red Hat Enterprise Linux Optional Productivity Applications - cpe:/a:redhat:rhel_productivity
65Red Hat Enterprise Linux Optional Productivity Applications 5 - cpe:/a:redhat:rhel_productivity:5
66Wind River Linux all versions - cpe:/o:windriver:wrlinux
67Wind River Linux 8 - cpe:/o:windriver:wrlinux:8
68
69==== Supported OVAL objects and associated OpenSCAP probes ====
70OVAL family OVAL object OpenSCAP probe
71---------- ---------- ----------
72(null) system_info probe_system_info
73independent family probe_family
74independent filehash probe_filehash
75independent environmentvariable probe_environmentvariable
76independent textfilecontent54 probe_textfilecontent54
77independent textfilecontent probe_textfilecontent
78independent variable probe_variable
79independent xmlfilecontent probe_xmlfilecontent
80independent environmentvariable58 probe_environmentvariable58
81independent filehash58 probe_filehash58
82linux inetlisteningservers probe_inetlisteningservers
83linux rpminfo probe_rpminfo
84linux partition probe_partition
85linux iflisteners probe_iflisteners
86linux rpmverify probe_rpmverify
87linux rpmverifyfile probe_rpmverifyfile
88linux rpmverifypackage probe_rpmverifypackage
89linux selinuxboolean probe_selinuxboolean
90linux selinuxsecuritycontext probe_selinuxsecuritycontext
91linux systemdunitproperty probe_systemdunitproperty
92linux systemdunitdependency probe_systemdunitdependency
93unix file probe_file
94unix interface probe_interface
95unix password probe_password
96unix process probe_process
97unix runlevel probe_runlevel
98unix shadow probe_shadow
99unix uname probe_uname
100unix xinetd probe_xinetd
101unix sysctl probe_sysctl
102unix process58 probe_process58
103unix fileextendedattribute probe_fileextendedattribute
104unix routingtable probe_routingtable
105unix symlink probe_symlink
显示SCAP内容信息
oscap
的功能之一是在文件中显示有关SCAP内容的信息。运行oscap info
命令允许检查SCAP文档的内部结构,并显示文档类型、规范版本、状态、文档发布日期(生成)和文档复制到文件系统(导入)的日期等信息。在检查XCCDF文档或SCAP数据流时,通常,最有用的信息是关于配置文件、清单和流的信息。
下面以Amazon Linux2 为例,列出所能运行的
1oscap info /usr/share/xml/scap/ssg/content/ssg-amzn2-ds.xml
输出
1Document type: Source Data Stream
2Imported: 2021-10-19T14:12:24
3
4Stream: scap_org.open-scap_datastream_from_xccdf_ssg-rhel7-xccdf-1.2.xml
5Generated: (null)
6Version: 1.2
7Checklists:
8 Ref-Id: scap_org.open-scap_cref_ssg-rhel7-xccdf-1.2.xml
9 Status: draft
10 Generated: 2019-04-19
11 Resolved: true
12 Profiles:
13 Title: C2S for Amazon Linux 2
14 Id: xccdf_org.ssgproject.content_profile_C2S
15 Title: Criminal Justice Information Services (CJIS) Security Policy
16 Id: xccdf_org.ssgproject.content_profile_cjis
17 Title: Health Insurance Portability and Accountability Act (HIPAA)
18 Id: xccdf_org.ssgproject.content_profile_hipaa
19 Title: Unclassified Information in Non-federal Information Systems and Organizations (NIST 800-171)
20 Id: xccdf_org.ssgproject.content_profile_nist-800-171-cui
21 Title: United States Government Configuration Baseline
22 Id: xccdf_org.ssgproject.content_profile_ospp
23 Title: PCI-DSS v3 Control Baseline for Amazon Linux 2
24 Id: xccdf_org.ssgproject.content_profile_pci-dss
25 Title: Red Hat Corporate Profile for Certified Cloud Providers (RH CCP)
26 Id: xccdf_org.ssgproject.content_profile_rht-ccp
27 Title: Standard System Security Profile for Amazon Linux 2
28 Id: xccdf_org.ssgproject.content_profile_standard
29 Title: DISA STIG for Amazon Linux 2
30 Id: xccdf_org.ssgproject.content_profile_stig-rhel7-disa
31 Title: OSPP - Protection Profile for General Purpose Operating Systems v. 4.2
32 Id: xccdf_org.ssgproject.content_profile_ospp42
33 Referenced check files:
34 ssg-rhel7-oval.xml
35 system: http://oval.mitre.org/XMLSchema/oval-definitions-5
36 ssg-rhel7-ocil.xml
37 system: http://scap.nist.gov/schema/ocil/2
38 https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL7.xml.bz2
39 system: http://oval.mitre.org/XMLSchema/oval-definitions-5
40 Ref-Id: scap_org.open-scap_cref_ssg-rhel7-pcidss-xccdf-1.2.xml
41 Status: draft
42 Generated: 2019-04-19
43 Resolved: true
44 Profiles:
45 Title: PCI-DSS v3 Control Baseline for Amazon Linux 2
46 Id: xccdf_org.ssgproject.content_profile_pci-dss_centric
47 Referenced check files:
48 ssg-rhel7-oval.xml
49 system: http://oval.mitre.org/XMLSchema/oval-definitions-5
50 ssg-rhel7-ocil.xml
51 system: http://scap.nist.gov/schema/ocil/2
52 https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL7.xml.bz2
53 system: http://oval.mitre.org/XMLSchema/oval-definitions-5
54Checks:
55 Ref-Id: scap_org.open-scap_cref_ssg-rhel7-oval.xml
56 Ref-Id: scap_org.open-scap_cref_ssg-rhel7-ocil.xml
57 Ref-Id: scap_org.open-scap_cref_ssg-rhel7-cpe-oval.xml
58 Ref-Id: scap_org.open-scap_cref_ssg-rhel7-oval.xml000
59 Ref-Id: scap_org.open-scap_cref_ssg-rhel7-ocil.xml000
60Dictionaries:
61 Ref-Id: scap_org.open-scap_cref_ssg-rhel7-cpe-dictionary.xml
再看一下 ssg-amazn2-xccdf.xml
1oscap info /usr/share/xml/scap/ssg/content/ssg-amzn2-xccdf.xml
输出
1Document type: XCCDF Checklist
2Checklist version: 1.1
3Imported: 2019-04-19T05:58:32
4Status: draft
5Generated: 2019-04-19
6Resolved: true
7Profiles:
8Title: C2S for Amazon Linux 2
9Id: C2S
10Title: Criminal Justice Information Services (CJIS) Security Policy
11Id: cjis
12Title: Health Insurance Portability and Accountability Act (HIPAA)
13Id: hipaa
14Title: Unclassified Information in Non-federal Information Systems and Organizations (NIST 800-171)
15Id: nist-800-171-cui
16Title: United States Government Configuration Baseline
17Id: ospp
18Title: PCI-DSS v3 Control Baseline for Amazon Linux 2
19Id: pci-dss
20Title: Red Hat Corporate Profile for Certified Cloud Providers (RH CCP)
21Id: rht-ccp
22Title: Standard System Security Profile for Amazon Linux 2
23Id: standard
24Title: DISA STIG for Amazon Linux 2
25Id: stig-rhel7-disa
26Title: OSPP - Protection Profile for General Purpose Operating Systems v. 4.2
27Id: ospp42
28Referenced check files:
29ssg-rhel7-oval.xml
30system: http://oval.mitre.org/XMLSchema/oval-definitions-5
31ssg-rhel7-ocil.xml
32system: http://scap.nist.gov/schema/ocil/2
33https://www.redhat.com/security/data/oval/com.redhat.rhsa-RHEL7.xml.bz2
34system: http://oval.mitre.org/XMLSchema/oval-definitions-5
OSCAP运行
oscap xccdf eval --profile standard --results-arf arf_standard.xml --results-arf arf_amzn2_ds.xml --report report_standard_ds.html /usr/share/xml/scap/ssg/content/ssg-amzn2-ds.xml
生成guide文件 oscap xccdf generate guide /usr/share/xml/scap/ssg/content/ssg-amzn2-xccdf.xml > guide.html
生成check list 文件 (HIPAA)
SCAP Profile
Ubuntu 使用 OVAL
Using OpenSCAP
Download the compressed XML:
wget https://security-metadata.canonical.com/oval/com.ubuntu.$(lsb_release -cs).usn.oval.xml.bz2
Uncompress the data:
bunzip2 com.ubuntu.$(lsb_release -cs).usn.oval.xml.bz2
Use OpenSCAP to evaluate the OVAL and generate an html report:
oscap oval eval --report report.html com.ubuntu.$(lsb_release -cs).usn.oval.xml
The output is generated in the file report.html, open it using your browser:
xdg-open report.html
File naming convention:
com.ubuntu.
系统修复
Remediate System
OpenSCAP allows to automatically remediate systems that have been found in a non-compliant state. For system remediation, an XCCDF file with instructions is required. The scap-security-guide package contains certain remediation instructions. System remediation consists of the following steps:
oscap
performs a regular XCCDF evaluation.- An assessment of the results is performed by evaluating the OVAL definitions. Each rule that has failed is marked as a candidate for remediation.
oscap
searches for an appropriate fix element, resolves it, prepares the environment, and executes the fix script.- Any output of the fix script is captured by
oscap
and stored within the rule-result element. The return value of the fix script is stored as well. - Whenever
oscap
executes a fix script, it immediately evaluates the OVAL definition again (to verify that the fix script has been applied correctly). During this second run, if the OVAL evaluation returns success, the result of the rule is fixed, otherwise it is an error. - Detailed results of the remediation are stored in an output XCCDF file. It contains two TestResult elements. The first TestResult element represents the scan prior to the remediation. The second TestResult is derived from the first one and contains remediation results.
1[root@ip-172-31-1-94 ec2-user]# ./amzn2-fix-script.sh
2Remediating rule 1/30: 'xccdf_org.ssgproject.content_rule_service_atd_disabled'
3Removed symlink /etc/systemd/system/multi-user.target.wants/atd.service.
4Failed to reset failed state of unit atd.service: Unit atd.service is not loaded.
5Remediating rule 2/30: 'xccdf_org.ssgproject.content_rule_partition_for_var_log_audit'
6FIX FOR THIS RULE 'xccdf_org.ssgproject.content_rule_partition_for_var_log_audit' IS MISSING!
7Remediating rule 3/30: 'xccdf_org.ssgproject.content_rule_partition_for_var_log'
8FIX FOR THIS RULE 'xccdf_org.ssgproject.content_rule_partition_for_var_log' IS MISSING!
9Remediating rule 4/30: 'xccdf_org.ssgproject.content_rule_audit_rules_kernel_module_loading'
10Remediating rule 5/30: 'xccdf_org.ssgproject.content_rule_audit_rules_time_stime'
11Remediating rule 6/30: 'xccdf_org.ssgproject.content_rule_audit_rules_time_settimeofday'
12Remediating rule 7/30: 'xccdf_org.ssgproject.content_rule_audit_rules_time_watch_localtime'
13Remediating rule 8/30: 'xccdf_org.ssgproject.content_rule_audit_rules_time_clock_settime'
14Remediating rule 9/30: 'xccdf_org.ssgproject.content_rule_audit_rules_time_adjtimex'
15Remediating rule 10/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_fchown'
16Remediating rule 11/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_setxattr'
17Remediating rule 12/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_chown'
18Remediating rule 13/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_removexattr'
19Remediating rule 14/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_fchownat'
20Remediating rule 15/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_chmod'
21Remediating rule 16/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_fsetxattr'
22Remediating rule 17/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_fchmod'
23Remediating rule 18/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_lsetxattr'
24Remediating rule 19/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_fremovexattr'
25Remediating rule 20/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_lchown'
26Remediating rule 21/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_fchmodat'
27Remediating rule 22/30: 'xccdf_org.ssgproject.content_rule_audit_rules_dac_modification_lremovexattr'
28Remediating rule 23/30: 'xccdf_org.ssgproject.content_rule_audit_rules_file_deletion_events'
29Remediating rule 24/30: 'xccdf_org.ssgproject.content_rule_audit_rules_privileged_commands'
30Remediating rule 25/30: 'xccdf_org.ssgproject.content_rule_audit_rules_unsuccessful_file_modification'
31Remediating rule 26/30: 'xccdf_org.ssgproject.content_rule_audit_rules_sysadmin_actions'
32Remediating rule 27/30: 'xccdf_org.ssgproject.content_rule_audit_rules_networkconfig_modification'
33Remediating rule 28/30: 'xccdf_org.ssgproject.content_rule_audit_rules_usergroup_modification'
34Remediating rule 29/30: 'xccdf_org.ssgproject.content_rule_audit_rules_media_export'
系统部署
该方案采用CloudFormation 自动部署的方式,如下资源会被自动创建
- S3 Bucket
- DynamoDB
- IAM Role
- Lambda
- System Manager Association
- System Manager
- parameter
使用CloudFormation部署成功
最终结果,所有不符合检查条件的结果日志被集成到SecurityHub中。