第8章 RHEL Image Builder OpenSCAP 統合によるハードニング済みイメージの作成
OpenSCAP 統合の RHEL Image Builder オンプレミスサポートを使用すると、特定のセキュリティープロファイルを使用してカスタマイズしたブループリントを作成し、そのブループリントを使用してハードニング済みイメージをビルドできます。このハードニング済みイメージを使用して、特定のプロファイルに準拠させる必要があるシステムをデプロイできます。ブループリントは、パッケージやアドオンファイルのセットを追加してカスタマイズできます。これにより、カスタマイズしたハードニング済み RHEL イメージをビルドし、プロファイルに準拠したシステムをデプロイする準備を整えることができます。
イメージのビルドプロセス中に、OSBuild oscap.remediation
ステージが、ファイルシステムツリー上の chroot
環境で OpenSCAP ツールを実行します。OpenSCAP ツールは、選択したプロファイルの標準評価を実行し、修復をイメージに適用します。これにより、イメージを初めて起動する前でも、セキュリティープロファイルの要件に従って設定されたイメージをビルドできます。
Red Hat は、現在のデプロイメントガイドラインを満たすことができるように、システムを構築するときに選択できるセキュリティーハードニングプロファイルの定期的に更新されたバージョンを提供します。
8.1. OpenSCAP ブループリントのカスタマイズ
OpenSCAP によるブループリントのカスタマイズのサポートにより、特定のセキュリティープロファイルの `scap-security-guide` コンテンツからブループリントを生成し、そのブループリントを使用して独自のハードニング済みイメージをビルドできます。
OpenSCAP を使用してカスタマイズしたブループリントを作成するには、次の主な手順を実行します。
- 特定の要件に応じてマウントポイントを変更し、ファイルシステムレイアウトを設定します。
- ブループリントで、OpenSCAP プロファイルを選択します。これにより、選択したプロファイルに従って、イメージのビルド中に修復をトリガーするようにイメージが設定されます。また、イメージのビルド中に、OpenSCAP が初回起動前の修復を適用します。
イメージブループリントで OpenSCAP
ブループリントのカスタマイズを使用するには、次の情報を提供する必要があります。
-
datastream
修復手順へのデータストリームパス。scap-security-guide
パッケージのデータストリームファイルは、/usr/share/xml/scap/ssg/content/
ディレクトリーにあります。 -
必要なセキュリティープロファイルの
profile_id
。profile_id
フィールドの値は、長い形式と短い形式の両方を受け入れます。たとえば、cis
やxccdf_org.ssgproject.content_profile_cis
を受け入れることができます。詳細は、RHEL 10 でサポートされている SCAP Security Guide プロファイル を参照してください。
次の例は、OpenSCAP
修復ステージのスニペットです。
[customizations.openscap] # If you want to use the data stream from the 'scap-security-guide' package # the 'datastream' key could be omitted. # datastream = "/usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml" profile_id = "xccdf_org.ssgproject.content_profile_cis"
[customizations.openscap]
# If you want to use the data stream from the 'scap-security-guide' package
# the 'datastream' key could be omitted.
# datastream = "/usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml"
profile_id = "xccdf_org.ssgproject.content_profile_cis"
次のコマンドを使用すると、scap-security-guide
パッケージの SCAP
ソースデータストリームの詳細 (データストリームによって提供されるセキュリティープロファイルのリストを含む) を確認できます。
oscap info /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
# oscap info /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
ユーザーの便宜のために、OpenSCAP
ツールでは、scap-security-guide
データストリームで利用可能な任意のプロファイルのハードニングブループリントを生成できます。
たとえば、次のコマンドを実行します。
oscap xccdf generate fix --profile=cis --fix-type=blueprint /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
# oscap xccdf generate fix --profile=cis --fix-type=blueprint /usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xml
次のような CIS プロファイルのブループリントを生成します。
Blueprint for CIS Red Hat Enterprise Linux 8 Benchmark for Level 2 - Server Profile Description: This profile defines a baseline that aligns to the "Level 2 - Server" configuration from the Center for Internet Security® Red Hat Enterprise Linux 8 Benchmark™, v3.0.0, released 2023-10-30. This profile includes Center for Internet Security® Red Hat Enterprise Linux 8 CIS Benchmarks™ content. Profile ID: xccdf_org.ssgproject.content_profile_cis Benchmark ID: xccdf_org.ssgproject.content_benchmark_RHEL-8 Benchmark Version: 0.1.74 XCCDF Version: 1.2 If your hardening data stream is not part of the 'scap-security-guide' package provide the absolute path to it (from the root of the image filesystem). datastream = "/usr/share/xml/scap/ssg/content/ssg-xxxxx-ds.xml"
# Blueprint for CIS Red Hat Enterprise Linux 8 Benchmark for Level 2 - Server
#
# Profile Description:
# This profile defines a baseline that aligns to the "Level 2 - Server"
# configuration from the Center for Internet Security® Red Hat Enterprise
# Linux 8 Benchmark™, v3.0.0, released 2023-10-30.
# This profile includes Center for Internet Security®
# Red Hat Enterprise Linux 8 CIS Benchmarks™ content.
#
# Profile ID: xccdf_org.ssgproject.content_profile_cis
# Benchmark ID: xccdf_org.ssgproject.content_benchmark_RHEL-8
# Benchmark Version: 0.1.74
# XCCDF Version: 1.2
name = "hardened_xccdf_org.ssgproject.content_profile_cis"
description = "CIS Red Hat Enterprise Linux 8 Benchmark for Level 2 - Server"
version = "0.1.74"
[customizations.openscap]
profile_id = "xccdf_org.ssgproject.content_profile_cis"
# If your hardening data stream is not part of the 'scap-security-guide' package
# provide the absolute path to it (from the root of the image filesystem).
# datastream = "/usr/share/xml/scap/ssg/content/ssg-xxxxx-ds.xml"
[[customizations.filesystem]]
mountpoint = "/home"
size = 1073741824
[[customizations.filesystem]]
mountpoint = "/tmp"
size = 1073741824
[[customizations.filesystem]]
mountpoint = "/var"
size = 3221225472
[[customizations.filesystem]]
mountpoint = "/var/tmp"
size = 1073741824
[[packages]]
name = "aide"
version = "*"
[[packages]]
name = "libselinux"
version = "*"
[[packages]]
name = "audit"
version = "*"
[customizations.kernel]
append = "audit_backlog_limit=8192 audit=1"
[customizations.services]
enabled = ["auditd","crond","firewalld","systemd-journald","rsyslog"]
disabled = []
masked = ["nfs-server","rpcbind","autofs","bluetooth","nftables"]
このブループリントスニペットは、イメージのハードニングにそのまま使用しないでください。完全なプロファイルを反映するものではありません。Red Hat は scap-security-guide
パッケージ内の各プロファイルのセキュリティー要件を継続的に更新および改良しています。そのため、システムに提供されるデータストリームの最新バージョンを使用して初期テンプレートを常に再生成することを推奨します。
これで、ブループリントをカスタマイズすることも、そのまま使用してイメージをビルドすることもできます。
RHEL Image Builder は、ブループリントのカスタマイズに基づいて、osbuild
ステージに必要な設定を生成します。さらに、RHEL Image Builder は 2 つのパッケージをイメージに追加します。
-
openscap-scanner
-OpenSCAP
ツール。 scap-security-guide
- 修復および評価の手順が含まれるパッケージ。注記このパッケージはデフォルトでイメージにインストールされるため、修復ステージではデータストリームに
scap-security-guide
パッケージを使用します。別のデータストリームを使用する場合は、必要なパッケージをブループリントに追加し、oscap
設定でデータストリームへのパスを指定します。