RHEL 10 OpenSCAP 基线扫描:CIS Server L1 实测
OpenSCAP 在 RHEL 10 上仍是“SCAP 数据流 + oscap 扫描”这套:装 scap-security-guide 拿到 RHEL 10 的规则,装 openscap-scanner 拿到 oscap。本页跑一遍 CIS Server L1,并把结果怎么读、哪里会踩坑讲清。
在 PVE 390 rhel10-lab(RHEL 10.2 x86_64)上实际执行:
sudo dnf -y install scap-security-guide openscap-scannerrpm -q scap-security-guide openscap-scanneroscap info /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml | grep 'Id:'sudo oscap xccdf eval \ --profile xccdf_org.ssgproject.content_profile_cis_server_l1 \ --results /tmp/oscap-cis.xml \ --report /tmp/oscap-cis.html \ /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xmlE3 记录:plans/content-expansion/evidence/rhel/rhel-openscap-baseline/run.json(7 步,含扫描日志/XML/HTML 的 sha256)。
先给结论:扫描 ≠ 合规认证
Section titled “先给结论:扫描 ≠ 合规认证”OpenSCAP 给的是某一时刻的配置快照:
- 扫的是本机当前状态,不覆盖网络、流程、人员;
- 规则通过不等于审计通过,规则失败也不等于系统“不能用”;
- 扫描本身不改系统(除非加
--remediate); - 结果要结合业务豁免与风险接受记录,不能只报一个分数。
安装与数据流
Section titled “安装与数据流”scap-security-guide-0.1.82-2.el10_2.noarchopenscap-scanner-1.4.4-1.el10_2.x86_64/usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml数据流里有 17 个 profile,常用的包括:
| Profile | 用途 |
|---|---|
cis | CIS 综合 |
cis_server_l1 | CIS Server Level 1 |
cis_workstation_l1/l2 | CIS 工作站 |
stig / stig_gui | DISA STIG |
pci-dss | PCI DSS |
anssi_bp28_* / bsi / e8 | 各国/行业基线 |
用 oscap info ... | grep 'Id:' 看完整列表,不要凭记忆拼 profile id。
跑 CIS Server L1
Section titled “跑 CIS Server L1”sudo oscap xccdf eval \ --profile xccdf_org.ssgproject.content_profile_cis_server_l1 \ --results /tmp/oscap-cis.xml \ --report /tmp/oscap-cis.html \ /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xmlecho $? # 2实测结果:
| 结果 | 数量 |
|---|---|
| pass | 170 |
| fail | 120 |
| notapplicable | 34 |
| error / unknown | 0 |
| score | 69.089 / 100 |
产物:
-rw-r--r-- 3.6M /tmp/oscap-cis.html-rw-r--r-- 15M /tmp/oscap-cis.xml退出码与产物怎么读
Section titled “退出码与产物怎么读”| 退出码 | 含义 |
|---|---|
| 0 | 所有适用规则通过 |
| 2 | 有规则失败(本次就是 2) |
| 1 | 扫描本身出错 |
自动化脚本要把“扫描失败(1)”和“规则不通过(2)”分开处理;不要把 2 当异常直接重试。--results 的 XML 适合做 diff/入库,--report 的 HTML 适合给人看;两者都应归档,并记录 profile、数据流版本、扫描时间。
remediation:先审再改
Section titled “remediation:先审再改”# 只生成修复脚本,不执行oscap xccdf generate fix \ --profile xccdf_org.ssgproject.content_profile_cis_server_l1 \ --output /tmp/cis-fix.sh \ /usr/share/xml/scap/ssg/content/ssg-rhel10-ds.xml--remediate 会直接改 sshd、audit、挂载选项等,可能中断 SSH 或业务。生产上的顺序是:快照 → 测试机 --remediate → 审 diff → 变更窗口执行 → 复扫。不要在远程生产机上一次梭哈。
- 数据流版本与 RHEL minor 匹配(
ssg-rhel10-ds.xml); - profile id 从
oscap info复制,不手写; - 保存 XML + HTML + 日志 + 扫描时间;
- 退出码 1/2 分开处理;
-
--remediate前有快照/测试机/变更单; - 失败项有豁免/修复记录,不只看 score。
未实测与边界
Section titled “未实测与边界”- 未测试
--remediate的实际改动(避免污染 390); - 未测试 STIG/PCI-DSS profile 的完整扫描;
- 未测试
oscap-docker/容器镜像扫描; - 未测试 SCAP 工作台(scap-workbench)与远程扫描;
- 未做合规认证结论。
- RHEL 10 文件完整性:AIDE 基线与检查 — 文件完整性
- RHEL 安全基线与加固 — 加固项
- RHEL 10 系统加密策略 — 加密基线
- 官方:Security hardening