mcpField
P
performing-gcp-security-assessment-with-forseti

performing-gcp-security-assessment-with-forseti

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

performing-gcp-security-assessment-with-forseti について

GCP の組織やプロジェクトを評価するセキュリティスキルです。IAM、ネットワークルール、ストレージ権限、セキュリティ検出結果を確認し、Forseti は旧式ツールとして扱います。

主な機能

  1. 01組織・プロジェクトの IAM バインディング確認
  2. 02ファイアウォールルールとネットワーク公開の確認
  3. 03バケットの公開アクセス確認
  4. 04ScoutSuite による自動評価
  5. 05Security Command Center の検出結果確認

活用シーン

  1. 01GCP 組織の定期的なセキュリティ評価
  2. 02新規プロジェクトのセキュリティ基準設定
  3. 03複数プロジェクトの IAM とストレージ権限の監査
  4. 04GCP インフラ設定の継続的な監視

インストール

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

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill performing-gcp-security-assessment-with-forseti

インストール後、Claude Code で/performing-gcp-security-assessment-with-forsetiを入力して読み込まれたか確認します。

同梱ファイル

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

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

詳細

Forseti を使用した GCP セキュリティ評価の実施

使用するタイミング

  • GCP の組織およびプロジェクトに対して定期的なセキュリティ評価を実施するとき
  • 新しい GCP プロジェクトをオンボーディングし、セキュリティベースラインを確立するとき
  • コンプライアンス要件で CIS GCP Foundations Benchmark による評価が義務付けられているとき
  • 複数の GCP プロジェクトにわたって IAM バインディング、ファイアウォールルール、ストレージ ACL を監査するとき
  • GCP インフラストラクチャに対する継続的なセキュリティ監視を構築するとき

次の用途には使用しないでください: リアルタイムの脅威検出のための GCP Security Command Center Premium の代替、アプリケーションレベルの脆弱性スキャン(Web Security Scanner を使用)、または GKE 固有のセキュリティ(GKE Security Posture を使用)の代替。

前提条件

  • Organization Admin または Security Admin IAM ロールを持つ GCP 組織
  • 十分な権限で認証された gcloud CLI(roles/securitycenter.admin、roles/iam.securityReviewer)
  • 組織レベルで有効化された Security Command Center(SCC)
  • マルチクラウド比較のためにインストールされた ScoutSuite(pip install scoutsuite)
  • google-cloud-asset および google-cloud-securitycenter ライブラリを使用するカスタム監査スクリプト用の Python 3.8 以上

ワークフロー

ステップ 1: Security Command Center と Asset Inventory を有効化する

SCC を有効化し、包括的なリソース可視化のために Cloud Asset Inventory をセットアップします。

# Enable Security Command Center API
gcloud services enable securitycenter.googleapis.com \
  --project=PROJECT_ID

# Enable Cloud Asset API
gcloud services enable cloudasset.googleapis.com \
  --project=PROJECT_ID

# List all assets in the organization
gcloud asset search-all-resources \
  --scope=organizations/ORG_ID \
  --asset-types="compute.googleapis.com/Instance,storage.googleapis.com/Bucket,iam.googleapis.com/ServiceAccount" \
  --format="table(name, assetType, location, project)"

# Export asset inventory to BigQuery for analysis
gcloud asset export \
  --organization=ORG_ID \
  --output-bigquery-force \
  --output-bigquery-dataset=projects/PROJECT_ID/datasets/asset_inventory \
  --output-bigquery-table=resources \
  --content-type=resource
ステップ 2: IAM ポリシーとバインディングを監査する

組織全体の IAM ポリシーを確認し、過度に許可的なバインディング、プリミティブロール、サービスアカウントの不正使用を調査します。

# List all IAM policy bindings at org level
gcloud organizations get-iam-policy ORG_ID \
  --format=json > org-iam-policy.json

# Find all users with Owner or Editor roles across projects
gcloud asset search-all-iam-policies \
  --scope=organizations/ORG_ID \
  --query="policy:roles/owner OR policy:roles/editor" \
  --format="table(resource, policy.bindings.role, policy.bindings.members)"

# Identify service accounts with admin roles
gcloud asset search-all-iam-policies \
  --scope=organizations/ORG_ID \
  --query="policy.bindings.members:serviceAccount AND policy:roles/owner" \
  --format=json

# Check for allUsers or allAuthenticatedUsers bindings (public access)
gcloud asset search-all-iam-policies \
  --scope=organizations/ORG_ID \
  --query="policy:allUsers OR policy:allAuthenticatedUsers" \
  --format="table(resource, policy.bindings.role, policy.bindings.members)"

# List service account keys older than 90 days
gcloud iam service-accounts keys list \
  --iam-account=SA_EMAIL \
  --managed-by=user \
  --format="table(name,validAfterTime,validBeforeTime)"
ステップ 3: ファイアウォールルールとネットワーク構成を評価する

VPC ファイアウォールルールを監査し、過度に許可的なインバウンドルール、ロギングの欠如、ネットワークへの露出を確認します。

# List all firewall rules allowing ingress from 0.0.0.0/0
gcloud compute firewall-rules list \
  --filter="direction=INGRESS AND sourceRanges=0.0.0.0/0" \
  --format="table(name, network, allowed, sourceRanges, targetTags)"

# Find firewall rules allowing all protocols/ports
gcloud compute firewall-rules list \
  --filter="direction=INGRESS AND allowed[].IPProtocol=all" \
  --format="table(name, network, sourceRanges, targetTags)"

# Check for SSH (22) and RDP (3389) open to internet
gcloud compute firewall-rules list \
  --filter="direction=INGRESS AND sourceRanges=0.0.0.0/0 AND (allowed[].ports=22 OR allowed[].ports=3389)" \
  --format="table(name, network, allowed, sourceRanges)"

# Audit VPC flow log configuration
gcloud compute networks subnets list \
  --format="table(name, region, enableFlowLogs, logConfig.aggregationInterval)"
ステップ 4: Cloud Storage バケットの権限を監査する

一般公開されているストレージバケットと、暗号化設定の欠如を確認します。

# List all buckets in a project
gsutil ls -p PROJECT_ID

# Check bucket IAM for public access
for bucket in $(gsutil ls -p PROJECT_ID); do
  echo "=== $bucket ==="
  gsutil iam get "$bucket" | grep -E "allUsers|allAuthenticatedUsers" && \
    echo "  WARNING: PUBLIC ACCESS DETECTED" || \
    echo "  OK: No public access"
done

# Check bucket encryption configuration
for bucket in $(gsutil ls -p PROJECT_ID); do
  echo "=== $bucket ==="
  gsutil kms encryption "$bucket" 2>/dev/null || echo "  Using Google-managed encryption"
done

# Check uniform bucket-level access enforcement
for bucket in $(gsutil ls -p PROJECT_ID); do
  gsutil uniformbucketlevelaccess get "$bucket"
done
ステップ 5: ScoutSuite を実行して包括的な評価を行う

ScoutSuite を実行し、GCP 環境の自動化された複数チェックによるセキュリティ評価を行います。

# Run ScoutSuite against GCP
python3 -m ScoutSuite gcp \
  --user-account \
  --all-projects \
  --report-dir ./scoutsuite-gcp-report

# Run with service account credentials
python3 -m ScoutSuite gcp \
  --service-account /path/to/service-account-key.json \
  --all-projects \
  --report-dir ./scoutsuite-gcp-report

# Open the HTML report
open ./scoutsuite-gcp-report/gcp-report.html
ステップ 6: Security Command Center の検出結果を照会する

脆弱性、設定ミス、脅威に関する SCC の検出結果を取得して分析します。

# List active SCC findings
gcloud scc findings list ORG_ID \
  --filter="state=\"ACTIVE\" AND severity=\"CRITICAL\"" \
  --format="table(finding.category, finding.severity, finding.resourceName, finding.eventTime)"

# List findings by category
gcloud scc findings list ORG_ID \
  --filter="state=\"ACTIVE\" AND category=\"PUBLIC_BUCKET_ACL\"" \
  --format=json

# Get finding statistics grouped by category
gcloud scc findings group ORG_ID \
  --group-by="category" \
  --filter="state=\"ACTIVE\""

# List compliance violations from SCC
gcloud scc findings list ORG_ID \
  --filter="state=\"ACTIVE\" AND sourceProperties.compliance_standard=\"CIS\"" \
  --format="table(finding.category, finding.severity, finding.resourceName)"

主要な概念

用語定義
Security Command Centerアセットインベントリ、脆弱性検出、脅威監視を提供する GCP ネイティブのセキュリティおよびリスク管理プラットフォーム
Forseti SecuritySCC に置き換えられて現在は非推奨となったオープンソースの GCP セキュリティツールキット。インベントリ、スキャン、適用、通知機能を提供していた
Cloud Asset Inventoryメタデータ、IAM ポリシー、組織ポリシー構成を含むクラウドリソースの完全なインベントリを提供する GCP サービス
CIS GCP Foundations BenchmarkCenter for Internet Security が定める、Google Cloud Platform の構成に特化したセキュリティベストプラクティスのガイドライン
Uniform Bucket-Level Accessレガシー ACL を無効化し、一貫したアクセス制御のために IAM ポリシーのみでアクセスを強制する GCP ストレージの設定
Organization Policy組織の階層全体でリソース構成を制限する、制約ベースの GCP ガバナンスの仕組み

ツールとシステム

  • Security Command Center: アセットインベントリ、脆弱性の検出結果、コンプライアンススコアリングを提供する GCP ネイティブの CSPM
  • ScoutSuite: IAM、コンピュート、ストレージ、ネットワークに関する包括的な GCP チェックを備えたマルチクラウドのセキュリティ監査ツール
  • gcloud CLI: GCP リソースの構成とセキュリティ設定を照会するための主要なコマンドラインインターフェース
  • Cloud Asset Inventory: GCP プロジェクト全体にわたってリソースメタデータと IAM ポリシーを検索・エクスポートするための API
  • Forseti Security: SCC に取って代わられたものの、コンプライアンスフレームワークでは依然として参照されているレガシーのオープンソース GCP セキュリティツールキット

よくあるシナリオ

シナリオ: 新たに買収した GCP 組織のアセスメント

背景: 企業買収の後、セキュリティチームは 30 を超えるプロジェクトを持つ買収先企業の GCP 組織のセキュリティ態勢を評価する必要があります。

アプローチ:

  1. Cloud Asset API を有効化し、完全なリソースインベントリを分析用に BigQuery へエクスポートします
  2. gcloud asset search-all-iam-policies を実行し、すべての Owner/Editor バインディングとパブリックアクセス許可を見つけます
  3. すべてのプロジェクトにわたるファイアウォールルールを監査し、0.0.0.0/0 からの過度に許可的なイングレスがないか確認します
  4. gsutil iam get を使用して、すべてのストレージバケットにパブリックアクセスがないか確認します
  5. ScoutSuite を実行し、HTML レポート付きの包括的な自動アセスメントを行います
  6. SCC を有効化し、CRITICAL および HIGH のすべての検出結果を確認します
  7. 統合チーム向けに、リスクの優先度に基づいた是正ロードマップを作成します

落とし穴: GCP の IAM バインディングは、組織からフォルダ、そしてプロジェクトへと継承されます。組織レベルの許可的なバインディングは、配下のすべてのプロジェクトに影響します。プロジェクトレベルだけでなく、階層のすべてのレベルで IAM を必ず監査してください。

出力形式

GCP Security Assessment Report
=================================
Organization: acme-acquired-org (ORG_ID: 123456789)
Projects Assessed: 34
Assessment Date: 2026-02-23
Standards: CIS GCP Foundations 2.0

IAM FINDINGS:
  Users with Owner role at org level:       3
  Service accounts with Editor role:        12
  Resources with allUsers binding:           5
  Service account keys > 90 days:           18

NETWORK FINDINGS:
  Firewall rules allowing 0.0.0.0/0:       14
  SSH open to internet:                      7
  RDP open to internet:                      2
  Subnets without VPC flow logs:            22

STORAGE FINDINGS:
  Publicly accessible buckets:               5
  Buckets without CMEK encryption:          28
  Buckets without uniform access:           15

CRITICAL FINDINGS: 12
HIGH FINDINGS: 34
MEDIUM FINDINGS: 78
LOW FINDINGS: 145

TOP REMEDIATION PRIORITIES:
  1. Remove allUsers bindings from 5 storage buckets (CRITICAL)
  2. Restrict 0.0.0.0/0 firewall rules to specific CIDRs (HIGH)
  3. Rotate 18 service account keys older than 90 days (HIGH)
  4. Enable VPC flow logs on 22 subnets (MEDIUM)

コメント