LoginSignup
10

More than 5 years have passed since last update.

OpenSCAP

Last updated at Posted at 2017-06-04

OpenSCAP

https://www.open-scap.org/
OpenSCAP は SCAP を実装しているオープンソースプロジェクトで、XCCDF または OVAL で記述されたチェックリストに従ってシステムを検証してレポートを作成する。

SCAPアメリカ国立標準技術研究所 (NIST) によって開発された情報セキュリティ対策の自動化と標準化のための規格で、製品についてのID (CPE)、 脆弱性についてのID (CVE)、設定についてのID (CCE), 脆弱性の深刻さのスコアづけ (CVSS)、自動チェックのための言語 (OVAL)、チェックリストのフォーマット (XCCDF) などが標準化されている。

インストール

OpenSCAP

yum -y install openscap-utils

依存関係で openscap, openscap-scanner パッケージもインストールされる。

CentOS 6.x で存在した、 scap-oval.xml, scap-rhel6-oval.xml, scap-rhel6-xccdf.xml, scap-xccdf.xml の4ファイルがインストールされる openscap-content パッケージは廃止された。

SCAP Security Guide

yum -y install scap-security-guide

updates リポジトリから scap-security-guide パッケージがインストールできる。ただし2016年6月にリリースされた少し古いバージョンの 0.1.30 になる。

インストールされる XML ファイル

/usr/share/xml/scap/ssg/content/ssg-centos6-ds.xml
/usr/share/xml/scap/ssg/content/ssg-centos7-ds.xml
/usr/share/xml/scap/ssg/content/ssg-centos7-xccdf.xml
/usr/share/xml/scap/ssg/content/ssg-firefox-ds.xml
/usr/share/xml/scap/ssg/content/ssg-jre-ds.xml
/usr/share/xml/scap/ssg/content/ssg-rhel7-cpe-dictionary.xml
/usr/share/xml/scap/ssg/content/ssg-rhel7-cpe-oval.xml
/usr/share/xml/scap/ssg/content/ssg-rhel7-oval.xml

インストールされる XML ファイルは上記の通り。

最新版

curl -LO https://github.com/OpenSCAP/scap-security-guide/releases/download/v0.1.33/scap-security-guide-0.1.33.zip
unzip scap-security-guide-0.1.33.zip

scap-security-guide パッケージでインストールされる 0.1.30 の ssg-centos7-ds.xml は 4,976,999 バイトおよび定義数 504 で、GitHub にある 0.1.33 では 11,840,154 バイトおよび定義数 908 と大きく開きがある。

Red Hat Product Security

curl -LO http://www.redhat.com/security/data/metrics/com.redhat.rhsa-all.xccdf.xml 
curl -LO http://www.redhat.com/security/data/oval/com.redhat.rhsa-all.xml 

スキャン実行

oscap xccdf eval --profile standard --report ssg-centos7-xccdf-standard.html /usr/share/xml/scap/ssg/content/ssg-centos7-xccdf.xml
oscap xccdf eval --profile common --report ssg-centos7-xccdf-common.html /usr/share/xml/scap/ssg/content/ssg-centos7-xccdf.xml
oscap xccdf eval --profile C2S --report ssg-centos7-xccdf-C2S.html /usr/share/xml/scap/ssg/content/ssg-centos7-xccdf.xml
oscap xccdf eval --profile ospp-rhel7-server --report ssg-centos7-xccdf-ospp-rhel7-server.html /usr/share/xml/scap/ssg/content/ssg-centos7-xccdf.xml
oscap xccdf eval --profile nist-cl-il-al --report ssg-centos7-xccdf-nist-cl-il-al.html /usr/share/xml/scap/ssg/content/ssg-centos7-xccdf.xml
oscap xccdf eval --profile cjis-rhel7-server --report ssg-centos7-xccdf-cjis-rhel7-server.html /usr/share/xml/scap/ssg/content/ssg-centos7-xccdf.xml
oscap xccdf eval --report com.redhat.rhsa-all.xccdf.html com.redhat.rhsa-all.xccdf.xml
oscap oval eval --report ssg-centos7-ds.html /usr/share/xml/scap/ssg/content/ssg-centos7-ds.xml
oscap oval eval --report ssg-centos7-ds-0.1.33.html scap-security-guide-0.1.33/ssg-centos7-ds.xml
oscap oval eval --report com.redhat.rhsa-all.html com.redhat.rhsa-all.xml

--report オプションでファイルを指定すると HTML ファイルでレポートが生成される。

対策

Standard System Security Profile

Verify and Correct File Permissions with RPM

rpm --setperms binutils

Prevent Log In to Accounts With Empty Password

sed -i 's/\<nullok\>//g' /etc/pam.d/system-auth

Common Profile for General-Purpose Systems

C2S for CentOS Linux 7

Restrict Dynamic Mounting and Unmounting of Filesystems

echo "install cramfs /bin/true" > /etc/modprobe.d/cramfs.conf
echo "install freevxfs /bin/true" > /etc/modprobe.d/freevxfs.conf
echo "install jffs2 /bin/true" > /etc/modprobe.d/jffs2.conf
echo "install hfs /bin/true" > /etc/modprobe.d/hfs.conf
echo "install hfsplus /bin/true" > /etc/modprobe.d/hfsplus.conf
echo "install squashfs /bin/true" > /etc/modprobe.d/squashfs.conf
echo "install udf /bin/true" > /etc/modprobe.d/udf.conf

Disable Core Dumps for All Users

echo '*               hard    core            0' >> /etc/security/limits.conf

Disable Core Dumps for SUID programs

sysctl -q -n -w fs.suid_dumpable=0
echo -e "\n# Set fs.suid_dumpable to 0 per security requirements" >> /etc/sysctl.conf
echo 'fs.suid_dumpable=0' >> /etc/sysctl.conf

Enable Randomized Layout of Virtual Address Space

sysctl -w kernel.randomize_va_space=2
echo 'kernel.randomize_va_space=2' >> /etc/sysctl.conf

Verify /boot/grub2/grub.cfg Permissions

chmod 600 /boot/grub2/grub.cfg

Disable Kernel Parameter for Sending ICMP Redirects by Default

sysctl -w net.ipv4.conf.default.send_redirects=0
echo -e "\n# Set net.ipv4.conf.default.send_redirects to 0 per security requirements" >> /etc/sysctl.conf
echo 'net.ipv4.conf.default.send_redirects=0' >> /etc/sysctl.conf

Disable Kernel Parameter for IP Forwarding

sysctl -w net.ipv4.ip_forward=0
echo -e "\n# Set net.ipv4.ip_forward to 0 per security requirements" >> /etc/sysctl.conf
echo "net.ipv4.ip_forward = 0" >> /etc/sysctl.conf

Configure Kernel Parameter for Accepting Secure Redirects for All Interfaces

sysctl -w net.ipv4.conf.all.secure_redirects=0
echo -e "\n# Set net.ipv4.conf.all.secure_redirects to 0 per security requirements" >> /etc/sysctl.conf
echo "net.ipv4.conf.all.secure_redirects=0" >> /etc/sysctl.conf

Configure Kernel Parameter for Accepting Secure Redirects By Default

sysctl -w net.ipv4.conf.default.secure_redirects=0
echo -e "\n# Set net.ipv4.conf.default.secure_redirects to 0 per security requirements" >> /etc/sysctl.conf
echo 'net.ipv4.conf.default.secure_redirects=0' >> /etc/sysctl.conf

関連パッケージ

パッケージ 概要
openscap
openscap-scanner oscap
openscap-utils oscap-chroot, oscap-docker, oscap-ssh, oscap-vm, scap-as-rpm
openscap-extra-probes probe_gconf, probe_ldap57
openscap-daemon EPEL リポジトリに存在する
scap-security-guide 少し古い 0.1.30 がインストールされる
openscap-engine-sce
openscap-python

参照ドキュメント

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10