1、简介
OpenSCAP 是一个开源的项目,该项目包括一系列的工具及大量的安全策略。SCAP 协议是一个由美国 NIST 维护的标准,OpenSCAP 项目是一组使用和实施该标准的开源工具,在 2014 年获得了 NIST 颁发的 SCAP1.2 认证。使用 OpenSCAP 可以进行安全合规检查修复以及脆弱性评估。
2、术语介绍
- Security Content Automation Protocol(SCAP),安全内容自动化协议,目前 SCAP 协议技术规范是 SCAP 1.3。SCAP是一套用于交换安全自动化内容的规范,用于评估配置遵从性和检测易受攻击软件版本。
参考链接: https://csrc.nist.gov/Projects/Security-Content-Automation-Protocol/SCAP-Releases/scap-1-3 - Common Configuration Enumeration(CCE):通用配置枚举,CCE 清单为安全相关的系统配置问题提供了一个唯一的标识符用于改进工作流,通过在大量信息源及工具中的配置数据促进快速和精确的关联。
参考链接: https://csrc.nist.gov/Projects/Security-Content-Automation-Protocol/Specifications/Common-Configuration-Enumeration-(CCE) - Common Platform Enumeration(CPE):通用平台枚举,是一个描述及标识应用、操作系统及硬件设备在当前企业计算资产中的标准方法。CPE 不描述一个系统中特定的产品实例,相反,它描述的是一个抽象的类别。
参考链接: https://csrc.nist.gov/Projects/Security-Content-Automation-Protocol/Specifications/cpe - Common Weakness Enumeration(CWE):CWE 称为通用脆弱性枚举,是由社区开发的软件脆弱性清单。CWE 致力于详细描述已知安全脆弱性及缺陷。同时也提供了阻止、实施及减少脆弱性的相关信息。
参考链接: https://cwe.mitre.org/index.html - The Script Check Engine(SCE):SCAP 的扩展,用于允许 SCAP 策略执行脚本
参考链接: http://www.open-scap.org/features/other-standards/sce/
Open Vulnerability and Assessment Language(OVAL):开放漏洞评估语言,在国际范围内,免费给公众使用,OVAL 是一个信息安全社区致力于标准化如何评估及报告计算机系统的机器状态。OVAL 包括了一种用于编码系统细节的语言,以及社区所维护的内容集。
参考链接: https://oval.mitre.org/ - The Extensible ConfigurationChecklist Description Format(XCCDF):可扩展配置清单描述格式,是一种特别的语言用于编写安全检查清单、基线以及类似相关的文档。一个 XCCDF 文档代表了一些目标系统的安全配置规则的结构化集合。
参考链接: https://csrc.nist.gov/Projects/Security-Content-Automation-Protocol/Specifications/xccdf - Center for Internet Security(CIS):互联网安全中心
参考链接: https://www.cisecurity.org/ - DataStream(DS):一种用于将 SCAP 组件打包到一个文件的格式,是最常见的一种 SCAP 文件类型,其文件后缀名通常为 ds.xml 。
- Asset Reporting Format(ARF):资产报告格式,合并了多个结果的文件,包括OVAL结果及XCCDF结果,通常也被称为结果数据流(Result DataStream)
- SCAP Security Guide(SSG):SSG 是一种使用 SCAP 文档形式写的安全策略。在 SSG 中创建的安全策略包括了很多计算机安全领域以及最佳实践解决方案。包含了描述得非常详细的规则以及证明过的修复脚本。SSG 中的安全策略有各种平台的系统,包括 Fedora、Red Hat、Enterprise Linux、Mozilla Firefox and others。注意,现在没有 CentOS,我在百度上找了一个适合 CentOS 的安全策略。
参考链接: http://www.open-scap.org/security-policies/scap-security-guide/ - Security Policy 也被称为 SCAP content,或者被称为 content,是所有合规策略的中心,他决定了应该如何设置以及检查什么内容。
参考链接: http://www.open-scap.org/security-policies/choosing-policy/
3、工具介绍
SCAP scanner 也称为 Tool,通过读取 SCAP 安全策略来检查系统是否合规。Scanner 会逐条读取策略中所有的规则,并且报告该规则是否满足,如果所有的规则都检查通过,则说明系统与该策略合规。OpenSCAP 的工具较多,这里截取官网上的一张图片如下图所示:
相关的工具包括OpenSCAP Base、SCAP Workbench、OSCAP Anaconda Addon、OpenSCAP Daemon、SCAPtimony 等,相关的工具以“分层”的方式构成了OpenSCAP的生态系统。
- OpenSCAPBase 是最底层的一个工具,可以用于在单个系统上进行合规扫描。
- SCAPWorkbench 是一个图形化界面的工具,其主要使用的是OpenSCAP Base的相关功能。
- OSCAP Anaconda Addon用于当系统需要高级的安全级别时,在系统初始化的时候就进行合规基线检查及修复。最简单的使用OSCAP Anaconda Addon的方法是使用内置该功能的Linux发行版本,目前只有 Red Hat Enterprise Linux 7 Update 2支持,其他的版本需要自已构建该功能及策略。
- OpenSCAPDaemon 用于持续的扫描多个系统,不管是运行在裸金属上的还是虚拟机上的,甚至可以执行容器的合规扫描。
相关的链接可参考: http://www.open-scap.org/tools/
4、安全策略介绍
在术语部分讲到 Security Policy 也称为 SCAP content,通常我们不需要精通如何写一个安全策略,很多策略都在线可获取,并且以标准的 SCAP 检查清单形式。但是没有任何策略可以在所有的地方都完全适用,这需要我们根据自身的安全风险以及业务需求,另外我们也可以根据已经有的安全策略进行修改调整为适合我们自身使用的策略。
(1)策略规范
A、SecurityTechnical Implementation Guides(STIGs):美国国防部指定的政府计算机如何进行配置及管理的安全技术实施指南。
B、The United States GovernmentConfiguration Baseline(USGCB):美国政府配置基线,是美国联邦的一个倡议,用于为各政府机构提供应该做什么的指导,指导如何提高和维护一个聚焦于安全的有效的配置设置。
C、Payment CardIndustry Data Security Standard(PCI DSS):处理信用卡信息及支付信息的安全标准,这是一个专用的信息安全标准用于处理信用卡的组织。
(2)SCAP Content
A、SCAP Secruity Guide
B、NIST SCAP Content,国家漏洞数据库中的国家检查程序(NCP)仓库为广泛范围的产品提供了大众可以使用的安全策略,在NIST SP800-70中进行定义。参考链接: https://ncp.nist.gov/repository
C、Red Hat 的 OVAL 仓库包含了与 RedHat 相关的安全公告,参考链接: https://www.redhat.com/security/data/oval/
D、SUSE linux 的 OVAL 信息数据库提供了通过产品、RPM 包名称以及版本的已修复的安全事故的索引,用于安全合规检查。参考链接: http://ftp.suse.com/pub/projects/security/oval/
(3)SSG 中可用的安全策略
SSG 中并不是只有一个安全策略,而是包含了一系列的策略,这里不再列举,具体可以参考下面的链接:
http://www.open-scap.org/security-policies/choosing-policy/
5、安装
yum install scap-workbench
6、简单使用
SCAP版本1.0包含以下六个SCAP元素:XCCDF、OVAL、CVE、CCE、CPE、CVSS。这些标准在SCAP产生之前都已经存在,并在各自的领域发挥着重要作用。其中一些标准我们可能之前有所了解,如CVE、CVSS。当SCAP将它们整合后,其整体标准化的优势变得十分明显。SCAP为安全工具实现标准化提供了解决方案:标准的输入数据格式、标准的处理方法和标准的输出数据格式,这非常有利于安全工具之间实现数据交换。
通用配置列举(CCE: Common Configuration Enumeration)定义了与安全相关的系统配置项标准
通用平台列举(CPE: Common Platform Enumeration) 定义了平台及版本的标准
通用脆弱性与漏洞列举(CVE: Common Vulnerabilities and Exposures) 定义了与软件缺陷相关的标准
通用脆弱性评分系统(CVSS: Common Vulnerability Scoring System)定义了脆弱性对系统影响的评分
可扩展配置检查列表描述格式(XCCDF: Extensible Configuration Checklist Description Format) 定义了检查列表与检查报告的XML描述格式
开放脆弱性评估描述格式(OVAL: Open Vulnerability and Assessment Language) 定义了用于检查列表的测试过程
SCAP内容存放在/usr/share/xml/scap/ssg/content/下,可以通过命令查看
[root@vpn2 sqlmapproject-sqlmap-2f01cbf]# oscap info /usr/share/xml/scap/ssg/content/ssg-rhel7-xccdf.xml
Document type: XCCDF Checklist
Checklist version: 1.2
Imported: 2024-03-05T17:43:04
Status: draft
Generated: 2024-03-05
Resolved: true
Profiles:
Title: C2S for Red Hat Enterprise Linux 7
Id: xccdf_org.ssgproject.content_profile_C2S
Title: ANSSI-BP-028 (enhanced)
Id: xccdf_org.ssgproject.content_profile_anssi_nt28_enhanced
Title: ANSSI-BP-028 (high)
Id: xccdf_org.ssgproject.content_profile_anssi_nt28_high
Title: ANSSI-BP-028 (intermediary)
Id: xccdf_org.ssgproject.content_profile_anssi_nt28_intermediary
Title: ANSSI-BP-028 (minimal)
Id: xccdf_org.ssgproject.content_profile_anssi_nt28_minimal
Title: CIS Red Hat Enterprise Linux 7 Benchmark for Level 2 - Server
Id: xccdf_org.ssgproject.content_profile_cis
Title: CIS Red Hat Enterprise Linux 7 Benchmark for Level 1 - Server
Id: xccdf_org.ssgproject.content_profile_cis_server_l1
Title: CIS Red Hat Enterprise Linux 7 Benchmark for Level 1 - Workstation
Id: xccdf_org.ssgproject.content_profile_cis_workstation_l1
Title: CIS Red Hat Enterprise Linux 7 Benchmark for Level 2 - Workstation
Id: xccdf_org.ssgproject.content_profile_cis_workstation_l2
Title: Criminal Justice Information Services (CJIS) Security Policy
Id: xccdf_org.ssgproject.content_profile_cjis
Title: Unclassified Information in Non-federal Information Systems and Organizations (NIST 800-171)
Id: xccdf_org.ssgproject.content_profile_cui
Title: Australian Cyber Security Centre (ACSC) Essential Eight
Id: xccdf_org.ssgproject.content_profile_e8
Title: Health Insurance Portability and Accountability Act (HIPAA)
Id: xccdf_org.ssgproject.content_profile_hipaa
Title: NIST National Checklist Program Security Guide
Id: xccdf_org.ssgproject.content_profile_ncp
Title: OSPP - Protection Profile for General Purpose Operating Systems v4.2.1
Id: xccdf_org.ssgproject.content_profile_ospp
Title: PCI-DSS v4.0 Control Baseline for Red Hat Enterprise Linux 7
Id: xccdf_org.ssgproject.content_profile_pci-dss
Title: RHV hardening based on STIG for Red Hat Enterprise Linux 7
Id: xccdf_org.ssgproject.content_profile_rhelh-stig
Title: VPP - Protection Profile for Virtualization v. 1.0 for Red Hat Virtualization
Id: xccdf_org.ssgproject.content_profile_rhelh-vpp
Title: Red Hat Corporate Profile for Certified Cloud Providers (RH CCP)
Id: xccdf_org.ssgproject.content_profile_rht-ccp
Title: Standard System Security Profile for Red Hat Enterprise Linux 7
Id: xccdf_org.ssgproject.content_profile_standard
Title: DISA STIG for Red Hat Enterprise Linux 7
Id: xccdf_org.ssgproject.content_profile_stig
Title: DISA STIG with GUI for Red Hat Enterprise Linux 7
Id: xccdf_org.ssgproject.content_profile_stig_gui
Referenced check files:
ssg-rhel7-oval.xml
system: http://oval.mitre.org/XMLSchema/oval-definitions-5
ssg-rhel7-ocil.xml
system: http://scap.nist.gov/schema/ocil/2
https://access.redhat.com/security/data/oval/v2/RHEL7/rhel-7.oval.xml.bz2
system: http://oval.mitre.org/XMLSchema/oval-definitions-5
[root@vpn2 sqlmapproject-sqlmap-2f01cbf]#
其中,字段的具体含义为:
(以下为代码块:发布时删掉此句)
- Document type: 文档类型
- Imported: 文档导入时间
- Stream: 数据流ID
- Version: SCAP标准的版本
- Checklists: 可用检查的列表
- Status: XCCDF基准状态。常用的值包括“accepted已接受”、“draft草案”、“deprecated已弃用”和“incomplete不完整”
- Profiles: 可用的配置文件
- Checks: 数据流中的OVAL检查组件
- Dictionaries: 数据流中的CPE字典组件
注意,请稍加留意上图中被框起来的Id字段(Profiles.Title.Id),后面会用到。
同样的,可以根据这个Id,查看对应的Profile信息。
进行合规检查命令格式如下:
oscap xccdf eval --profile [profile.title.id] --results [result xml 文件] --report [report html 文件] [SCAP内容xml文件]
测试了一个
oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_C2S --results /root/oscap/results.xml --report /root/oscap/report.html ssg-rhel7-xccdf.xml
结果
......
Title Ensure All SUID Executables Are Authorized
Rule xccdf_org.ssgproject.content_rule_file_permissions_unauthorized_suid
Ident CCE-80133-2
Result notapplicable
......
.
可以得到两个文件
可以查看报告内容