mcpField
H
hardening-linux-endpoint-with-cis-benchmark

hardening-linux-endpoint-with-cis-benchmark

github.com/mukul975セキュリティ35.2k152 回インストール8 週間前に更新
リポジトリ

hardening-linux-endpoint-with-cis-benchmark について

CIS ベンチマークに沿って Linux エンドポイントを強化する、管理者向けのスキルです。ファイルシステム、サービス、ネットワーク、アクセス制御、監査、ログの設定手順に加え、OpenSCAP による評価と任意の Ansible 修正を扱います。

主な機能

  1. 01CIS 準拠の Linux 強化ワークフロー
  2. 02ファイルシステムとサービスの設定
  3. 03SSH とアクセス制御の設定
  4. 04監査とログの構成
  5. 05OpenSCAP によるベンチマーク評価
  6. 06任意の Ansible 修正

活用シーン

  1. 01CIS ベンチマークに沿った Linux サーバー強化
  2. 02Linux エンドポイントのコンプライアンス審査準備
  3. 03セキュリティ監査での指摘事項の修正
  4. 04Ansible によるベースライン変更の自動化

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill hardening-linux-endpoint-with-cis-benchmark

インストール後、Claude Code で/hardening-linux-endpoint-with-cis-benchmarkを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

LICENSE
assets/
template.md
references/
api-reference.md
standards.md
workflows.md
scripts/
agent.py
process.py

詳細

CIS ベンチマークによる Linux エンドポイントの強化

使用する場面

次の場合にこのスキルを使用します:

  • Linux サーバー(Ubuntu、RHEL、CentOS、Debian)を CIS ベンチマークに準拠するよう強化する場合
  • Ansible、OpenSCAP、またはシェルスクリプトを使用して Linux のセキュリティベースラインを自動化する場合
  • Linux エンドポイントに関するコンプライアンス要件(PCI DSS、HIPAA、SOC 2)を満たす場合
  • 脆弱性スキャンやセキュリティ監査で検出された問題を修正する場合

Windows の強化には使用しないでください(hardening-windows-endpoint-with-cis-benchmark を使用してください)。

前提条件

  • 対象の Linux エンドポイントでの root または sudo アクセス
  • 対象ディストリビューションの CIS ベンチマーク PDF(cisecurity.org から入手)
  • 自動評価用の OpenSCAP または CIS-CAT
  • 大規模な組織での修正用の Ansible(任意)

ワークフロー

ステップ 1:ファイルシステムの設定(セクション 1)
# 1.1.1 Disable unused filesystems
cat >> /etc/modprobe.d/CIS.conf << 'EOF'
install cramfs /bin/true
install freevxfs /bin/true
install jffs2 /bin/true
install hfs /bin/true
install hfsplus /bin/true
install squashfs /bin/true
install udf /bin/true
EOF

# 1.1.2 Ensure /tmp is a separate partition with nodev,nosuid,noexec
# /etc/fstab entry:
# tmpfs /tmp tmpfs defaults,rw,nosuid,nodev,noexec,relatime 0 0
systemctl unmask tmp.mount
systemctl enable tmp.mount

# 1.1.8 Ensure nodev option on /dev/shm
mount -o remount,nodev,nosuid,noexec /dev/shm
echo "tmpfs /dev/shm tmpfs defaults,nodev,nosuid,noexec 0 0" >> /etc/fstab

# 1.4 Secure boot settings
chown root:root /boot/grub/grub.cfg
chmod 600 /boot/grub/grub.cfg
# Set GRUB password
grub-mkpasswd-pbkdf2  # Generate hash, add to /etc/grub.d/40_custom
ステップ 2:サービスとネットワーク(セクション 2~3)
# 2.1 Disable unnecessary services
systemctl disable --now avahi-daemon
systemctl disable --now cups
systemctl disable --now rpcbind
systemctl disable --now xinetd

# 2.2 Ensure NTP is configured
apt install chrony -y  # or systemd-timesyncd
systemctl enable --now chrony

# 3.1 Network parameters (host only, not router)
cat >> /etc/sysctl.d/99-cis.conf << 'EOF'
net.ipv4.ip_forward = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.tcp_syncookies = 1
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0
EOF
sysctl --system

# 3.4 Configure firewall (UFW or firewalld)
ufw enable
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ステップ 3:アクセス制御(セクション 4~5)
# 5.2 SSH Server Configuration (/etc/ssh/sshd_config)
sed -i 's/#Protocol 2/Protocol 2/' /etc/ssh/sshd_config
cat >> /etc/ssh/sshd_config << 'EOF'
LogLevel VERBOSE
MaxAuthTries 4
PermitRootLogin no
PermitEmptyPasswords no
PasswordAuthentication no
X11Forwarding no
MaxStartups 10:30:60
LoginGraceTime 60
AllowTcpForwarding no
ClientAliveInterval 300
ClientAliveCountMax 3
EOF
systemctl restart sshd

# 5.3 Password policy (PAM)
# /etc/security/pwquality.conf
minlen = 14
dcredit = -1
ucredit = -1
ocredit = -1
lcredit = -1

# 5.4 User account settings
# /etc/login.defs
PASS_MAX_DAYS 365
PASS_MIN_DAYS 1
PASS_WARN_AGE 7

# Lock inactive accounts
useradd -D -f 30
ステップ 4:監査とログ記録(セクション 4)
# Install and configure auditd
apt install auditd audispd-plugins -y
systemctl enable --now auditd

# /etc/audit/rules.d/cis.rules
cat > /etc/audit/rules.d/cis.rules << 'EOF'
-w /etc/sudoers -p wa -k scope
-w /etc/sudoers.d/ -p wa -k scope
-w /var/log/sudo.log -p wa -k actions
-a always,exit -F arch=b64 -S adjtimex -S settimeofday -k time-change
-a always,exit -F arch=b64 -S sethostname -S setdomainname -k system-locale
-w /etc/group -p wa -k identity
-w /etc/passwd -p wa -k identity
-w /etc/shadow -p wa -k identity
-w /var/log/faillog -p wa -k logins
-w /var/log/lastlog -p wa -k logins
-a always,exit -F arch=b64 -S chmod -S fchmod -S fchmodat -k perm_mod
-a always,exit -F arch=b64 -S unlink -S rmdir -S rename -k delete
-w /sbin/insmod -p x -k modules
-w /sbin/modprobe -p x -k modules
-e 2
EOF
augenrules --load

# Configure rsyslog for remote logging
echo "*.* @@syslog-server.corp.com:514" >> /etc/rsyslog.d/50-remote.conf
systemctl restart rsyslog
ステップ 5:OpenSCAP による評価
# Install OpenSCAP
apt install openscap-scanner scap-security-guide -y

# Run CIS benchmark assessment
oscap xccdf eval \
  --profile xccdf_org.ssgproject.content_profile_cis_level1_server \
  --results /tmp/cis_results.xml \
  --report /tmp/cis_report.html \
  /usr/share/xml/scap/ssg/content/ssg-ubuntu2204-ds.xml

# View HTML report in browser for detailed results

重要な概念

用語定義
OpenSCAPコンプライアンスの自動化に使用する、オープンソースの SCAP(Security Content Automation Protocol)スキャナー
auditdシステムコールとファイルアクセスを監視する Linux 監査フレームワーク
PAMPluggable Authentication Modules。Linux 用に設定可能な認証フレームワーク
sysctlネットワークとシステムのセキュリティ調整に使用する Linux カーネルパラメーターの設定
AIDEAdvanced Intrusion Detection Environment。Linux 用のファイル整合性チェッカー

ツールとシステム

  • OpenSCAP:Linux の CIS ベンチマークを自動評価します
  • Ansible Lockdown:CIS ベンチマークの修正を自動化する Ansible ロール
  • Lynis:Linux/Unix システム用のオープンソースのセキュリティ監査ツール
  • AIDE:Linux エンドポイントのファイル整合性を監視します
  • auditd:システムコールを監視する Linux 監査フレームワーク

よくある落とし穴

  • サーバー用ベンチマークをワークステーションに適用する:CIS では、サーバーとワークステーションのプロファイルに個別のベンチマークが用意されています。サーバー用ベンチマークでは、デスクトップサービスが無効になります。
  • SSH アクセスを遮断する:sshd_config(特に PermitRootLogin、PasswordAuthentication)の設定を誤ると、管理者がアクセスできなくなることがあります。SSH の設定変更は、必ず別のセッションからテストしてください。
  • ファイアウォールルールをテストしない:SSH を先に許可せずに UFW を有効にすると、リモートセッションが永久に切断されます。
  • テストせずにカーネルパラメーターを変更する:sysctl の設定によっては、アプリケーションのネットワーク接続に問題が発生することがあります。まずステージング環境でテストしてください。

コメント