mcpField
I
implementing-aws-security-hub

implementing-aws-security-hub

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

implementing-aws-security-hub について

複数の AWS アカウントでセキュリティ検出結果とコンプライアンスチェックを集約するチーム向けに、AWS Security Hub CSPM の導入を解説します。サービス連携、自動修復、監査レポートを扱います。

主な機能

  1. 01セキュリティ標準を有効化
  2. 02アカウントとリージョン間で検出結果を集約
  3. 03AWS とサードパーティの検出結果を連携
  4. 04EventBridge と Lambda による修復の自動化
  5. 05コンプライアンススコアを監視しレポートを作成

活用シーン

  1. 01複数の AWS アカウントの検出結果を集約
  2. 02対応標準への準拠状況を確認
  3. 03繰り返す設定上の問題を修復
  4. 04コンプライアンス監査の証跡を準備

インストール

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

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill implementing-aws-security-hub

インストール後、Claude Code で/implementing-aws-security-hubを入力して読み込まれたか確認します。

同梱ファイル

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

LICENSE
references/
api-reference.md
scripts/
agent.py

詳細

AWS Security Hub の実装

使用する場面

  • 複数の AWS アカウントにわたるセキュリティ検出結果を一元管理するダッシュボードを構築する場合
  • CIS、PCI-DSS、NIST、AWS Foundational Security Best Practices に対するコンプライアンスチェックを自動化する場合
  • GuardDuty、Inspector、Macie、サードパーティ製セキュリティツールからの検出結果を統合する場合
  • 繰り返し発生するセキュリティ設定ミスに対する自動修復ワークフローを構築する場合
  • 継続的なセキュリティ態勢の監視を求める監査人向けに、コンプライアンスの証跡を準備する場合

次の場合は使用しないでください。リアルタイムの脅威検出(detecting-cloud-threats-with-guardduty を参照)、Azure のコンプライアンス監視(securing-azure-with-microsoft-defender を参照)、またはコンテナイメージの詳細な脆弱性スキャン(securing-container-registry を参照)。

前提条件

  • セキュリティ管理者アカウントを指定した AWS Organization
  • 対象となるすべてのアカウントとリージョンで AWS Config が有効になっていること
  • 検出結果を統合するために GuardDuty、Inspector、Macie が有効化されていること
  • 管理者アカウントでの securityhub:* および config:* に対する IAM 権限

ワークフロー

ステップ 1:Security Hub を有効化し、標準を設定する

委任管理者アカウントで Security Hub を有効化し、セキュリティ標準を設定します。AWS Security Hub CSPM は、CIS AWS Foundations Benchmark v5.0、AWS Foundational Security Best Practices、PCI DSS v3.2.1、NIST SP 800-53 をサポートしています。

# Enable Security Hub with standards
aws securityhub enable-security-hub \
  --enable-default-standards \
  --tags '{"Environment":"production","ManagedBy":"security-team"}'

# Enable CIS AWS Foundations Benchmark v5.0
aws securityhub batch-enable-standards \
  --standards-subscription-requests '[
    {"StandardsArn": "arn:aws:securityhub:::ruleset/cis-aws-foundations-benchmark/v/5.0.0"},
    {"StandardsArn": "arn:aws:securityhub:us-east-1::standards/aws-foundational-security-best-practices/v/1.0.0"},
    {"StandardsArn": "arn:aws:securityhub:us-east-1::standards/pci-dss/v/3.2.1"}
  ]'

# Verify enabled standards
aws securityhub get-enabled-standards \
  --query 'StandardsSubscriptions[*].[StandardsArn,StandardsStatus]' --output table
ステップ 2:マルチアカウント集約を設定する

Security Hub 管理者を指定し、組織のすべてのメンバーアカウントを自動的に登録します。クロスリージョン集約を設定して、検出結果を単一のリージョンに集約します。

# Designate delegated admin
aws securityhub enable-organization-admin-account \
  --admin-account-id 111122223333

# Auto-enable for all org members
aws securityhub update-organization-configuration \
  --auto-enable \
  --organization-configuration '{"ConfigurationType": "CENTRAL"}'

# Enable cross-region aggregation
aws securityhub create-finding-aggregator \
  --region-linking-mode ALL_REGIONS
ステップ 3:セキュリティサービスとサードパーティ製ツールを統合する

AWS サービスやパートナーのセキュリティツールから検出結果を受け取るよう、製品統合を設定します。サードパーティ製ツールの検出結果を AWS Security Finding Format(ASFF)にマッピングします。

# List available product integrations
aws securityhub describe-products \
  --query 'Products[*].[ProductName,CompanyName,ProductSubscriptionResourcePolicy]' --output table

# Enable specific integrations
aws securityhub enable-import-findings-for-product \
  --product-arn "arn:aws:securityhub:us-east-1::product/aws/guardduty"

aws securityhub enable-import-findings-for-product \
  --product-arn "arn:aws:securityhub:us-east-1::product/aws/inspector"

# Import custom findings using ASFF format
aws securityhub batch-import-findings --findings '[{
  "SchemaVersion": "2018-10-08",
  "Id": "custom-finding-001",
  "ProductArn": "arn:aws:securityhub:us-east-1:123456789012:product/123456789012/default",
  "GeneratorId": "custom-scanner",
  "AwsAccountId": "123456789012",
  "Types": ["Software and Configuration Checks/Vulnerabilities/CVE"],
  "Title": "Unpatched OpenSSL in production ALB backend",
  "Description": "CVE-2024-12345 detected on backend instances",
  "Severity": {"Label": "HIGH"},
  "Resources": [{"Type": "AwsEc2Instance", "Id": "arn:aws:ec2:us-east-1:123456789012:instance/i-0abc123"}]
}]'
ステップ 4:自動修復を構築する

EventBridge ルールや Lambda 関数に関連付けた Security Hub のカスタムアクションを作成し、一般的な検出結果をワンクリックまたは完全自動で修復できるようにします。

# Create a custom action for remediation
aws securityhub create-action-target \
  --name "IsolateInstance" \
  --description "Isolate EC2 instance by replacing security groups" \
  --id "IsolateInstance"

# EventBridge rule for automated remediation of specific controls
aws events put-rule \
  --name SecurityHubAutoRemediate \
  --event-pattern '{
    "source": ["aws.securityhub"],
    "detail-type": ["Security Hub Findings - Imported"],
    "detail": {
      "findings": {
        "Compliance": {"Status": ["FAILED"]},
        "Severity": {"Label": ["CRITICAL", "HIGH"]},
        "GeneratorId": ["aws-foundational-security-best-practices/v/1.0.0/S3.1"]
      }
    }
  }'
ステップ 5:コンプライアンススコアを監視し、レポートを生成する

標準ごとのセキュリティスコアを追跡し、時間の経過に伴うコンプライアンスの逸脱を監視して、監査証跡用のレポートを生成します。

# Get security score for a standard
aws securityhub get-security-control-definition \
  --security-control-id "S3.1"

# List all failed controls with counts
aws securityhub get-findings \
  --filters '{
    "ComplianceStatus": [{"Value": "FAILED", "Comparison": "EQUALS"}],
    "RecordState": [{"Value": "ACTIVE", "Comparison": "EQUALS"}]
  }' \
  --sort-criteria '{"Field": "SeverityLabel", "SortOrder": "desc"}' \
  --max-items 50

重要な概念

用語定義
セキュリティ標準CIS、PCI-DSS、NIST 800-53、AWS のベストプラクティスなどのコンプライアンスフレームワークに対応付けられた、事前構成済みのコントロール一式
セキュリティコントロール特定の AWS リソース設定をセキュリティ要件に照らして評価する、個別の自動チェック
ASFFAWS Security Finding Format。統合されたすべてのセキュリティ製品からの検出結果を正規化する、標準化された JSON スキーマ
コンプライアンススコア特定のセキュリティ標準で合格状態にあるコントロールの割合。アカウントごとに算出され、組織レベルで集約されます
検出結果アグリゲーター有効化されたすべてのリージョンの検出結果を、単一の管理者リージョンに集約するクロスリージョンの仕組み
カスタムアクションSecurity Hub コンソールから実行して EventBridge ルールを呼び出し、手動または自動の対応を行う、ユーザー定義のアクション

ツールとシステム

  • AWS Security Hub CSPM:セキュリティ態勢の自動チェックと検出結果の集約を行う中核プラットフォーム
  • AWS Config:リソースの評価に Security Hub が使用する、基盤となる設定レコーダー
  • Amazon EventBridge:Security Hub の検出結果を自動修復ワークフローに接続するイベントルーティングサービス
  • AWS Systems Manager:一般的な設定ミスの修復に Security Hub から呼び出せる自動化ドキュメント
  • AWS Audit Manager:Security Hub の検出結果を証跡として利用し、監査対応レポートを生成

一般的なシナリオ

シナリオ:50 個のアカウントで CIS Controls に不合格

コンテキスト:ある企業が CIS AWS Foundations Benchmark v5.0 を有効にしたところ、50 個のアカウントで 340 件のコントロールが不合格と判定されました。主な問題は、IAM パスワードポリシー、CloudTrail の設定、VPC フローログの有効化です。

アプローチ:

  1. 不合格の検出結果をコントロール ID ごとにグループ化してすべてエクスポートし、最も多く発生している問題を特定します
  2. 最も多くのアカウントに影響する、重大度が「Critical」および「High」のコントロールを優先します
  3. 繰り返し発生する上位 10 件の不合格に対して、Systems Manager Automation ドキュメントを作成します
  4. S3.1(パブリックアクセスをブロック)や CloudTrail.1(マルチリージョンの証跡を有効化)などのコントロールに対し、EventBridge を介して自動修復をデプロイします
  5. コンプライアンススコアのレビューを毎週実施するようスケジュールし、90 日間の修復期間を通じて改善状況を追跡します

落とし穴:すべてのコントロールに対して一度に自動修復を有効にすると、正当な理由でパブリック S3 アクセスや特定のネットワーク設定を必要とする本番ワークロードに支障をきたす可能性があります。修復を適用する前に、必ずステージングアカウントでテストしてください。

出力形式

AWS Security Hub Compliance Report
====================================
Organization: acme-corp
Administrator Account: 111122223333
Report Date: 2025-02-23
Standards Enabled: CIS v5.0, AWS FSBP v1.0, PCI DSS v3.2.1

COMPLIANCE SCORES:
  CIS AWS Foundations Benchmark v5.0: 78%
  AWS Foundational Security Best Practices: 85%
  PCI DSS v3.2.1: 72%

TOP FAILED CONTROLS (by account count):
  [S3.1]   Block public access settings enabled      - 23/50 accounts FAILED
  [CT.1]   CloudTrail multi-region enabled            - 12/50 accounts FAILED
  [IAM.4]  Root account has no access keys            -  3/50 accounts FAILED
  [EC2.19] Security groups restrict unrestricted ports- 31/50 accounts FAILED
  [RDS.3]  RDS encryption at rest enabled             - 18/50 accounts FAILED

FINDING SUMMARY:
  Total Active Findings: 1,247
  Critical: 34 | High: 189 | Medium: 567 | Low: 457
  Auto-Remediated This Month: 89
  Suppressed: 23

コメント