本文へスキップ
Skillpedia
デプロイとクラウド(DevOps)35k · #7680

auditing-gcp-iam-permissions

できること

このツールは、Google Cloud内で誰が何にアクセスできるかを確認するためのものです。広すぎる権限、必要以上に多くのキーを持つサービスアカウントや不要なアクセス権、異なるプロジェクト間でリソースにアクセスできる人を探します。

使う場面

  • ✓Google Cloudで誰が何をできるかというセキュリティを見直すとき。
  • ✓過剰な権限を持つサービスアカウントや、もう使われていないサービスアカウントがないか確認したいとき。
  • ✓アクセスルールがセキュリティ基準に準拠していることを確認するため。

スキルのリンク

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/auditing-gcp-iam-permissions/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/auditing-gcp-iam-permissions/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“Google Cloudプロジェクトのアクセス権限を確認して、過剰なアクセス権がないか調べてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

特定のGoogle Cloudコマンドを使って、すべての権限を一覧表示し、サービスアカウントとそのキーを確認して、どのユーザーがどのリソースにアクセスできるかを分析します。その後、これらのアクセス権を減らす方法を提案します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Auditing GCP IAM Permissions

When to Use

  • When performing security assessments of GCP organization or project IAM configurations
  • When identifying service accounts with excessive permissions or unused access
  • When compliance requirements mandate review of access controls and role assignments
  • When investigating potential lateral movement through IAM misconfigurations
  • When reducing the blast radius of compromised credentials by scoping down permissions

Do not use for VPC firewall rule auditing (use network security tools), for GKE RBAC auditing (use Kubernetes-specific RBAC tools), or for real-time threat detection on IAM actions (use SCC Event Threat Detection).

Prerequisites

  • GCP organization or project with roles/iam.securityReviewer and roles/cloudAsset.viewer
  • gcloud CLI authenticated with appropriate permissions
  • Cloud Asset API enabled (gcloud services enable cloudasset.googleapis.com)
  • IAM Recommender API enabled (gcloud services enable recommender.googleapis.com)
  • Policy Analyzer API enabled (gcloud services enable policyanalyzer.googleapis.com)

Workflow

Step 1: Enumerate IAM Bindings Across the Organization

List all IAM bindings at organization, folder, and project levels to understand the full access landscape.

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

# Search all IAM policies across the organization
gcloud asset search-all-iam-policies \
  --scope=organizations/ORG_ID \
  --format="table(resource, policy.bindings.role, policy.bindings.members)" \
  --limit=500

# Find all users and service accounts with Owner role
gcloud asset search-all-iam-policies \
  --scope=organizations/ORG_ID \
  --query="policy:roles/owner" \
  --format="table(resource, policy.bindings.members)"

# Find all bindings using primitive roles (Owner, Editor, Viewer)
gcloud asset search-all-iam-policies \
  --scope=organizations/ORG_ID \
  --query="policy:roles/owner OR policy:roles/editor" \
  --format=json | python3 -c "
import json, sys
data = json.load(sys.stdin)
for result in data:
    resource = result.get('resource', '')
    for binding in result.get('policy', {}).get('bindings', []):
        role = binding.get('role', '')
        if role in ['roles/owner', 'roles/editor']:
            for member in binding.get('members', []):
                print(f'{resource} | {role} | {member}')
"

Step 2: Audit Service Accounts and Their Keys

Identify service accounts with excessive permissions, user-managed keys, and unused accounts.

# List all service accounts in a project
gcloud iam service-accounts list \
  --project=PROJECT_ID \
  --format="table(email, displayName, disabled)"

# Check for user-managed keys (should be minimized)
for sa in $(gcloud iam service-accounts list --project=PROJECT_ID --format="value(email)"); do
  keys=$(gcloud iam service-accounts keys list \
    --iam-account="$sa" \
    --managed-by=user \
    --format="table(name.basename(),validAfterTime,validBeforeTime)")
  if [ -n "$keys" ]; then
    echo "=== $sa ==="
    echo "$keys"
  fi
done

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

# Check service account IAM policies (who can impersonate)
for sa in $(gcloud iam service-accounts list --project=PROJECT_ID --format="value(email)"); do
  echo "=== $sa ==="
  gcloud iam service-accounts get-iam-policy "$sa" --format=json 2>/dev/null
done

Step 3: Use IAM Recommender to Identify Excess Permissions

Leverage GCP's IAM Recommender to find roles that grant more access than actually used.

# List IAM role recommendations for a project
gcloud recommender recommendations list \
  --project=PROJECT_ID \
  --recommender=google.iam.policy.Recommender \
  --location=global \
  --format="table(name, description, priority, stateInfo.state)"

# Get detailed recommendation
gcloud recommender recommendations describe RECOMMENDATION_ID \
  --project=PROJECT_ID \
  --recommender=google.iam.policy.Recommender \
  --location=global \
  --format=json

# List insights about IAM usage
gcloud recommender insights list \
  --project=PROJECT_ID \
  --insight-type=google.iam.policy.Insight \

…
よくある質問

何かインストールする必要がありますか?

はい。お使いのコンピューターに「gcloud CLI」ツールをインストールして設定しておく必要があります。また、Google Cloudアカウントで必要な権限も付与されている必要があります。

「プリミティブロール」とは何ですか?

「Owner」「Editor」「Viewer」などの汎用的なロールで、多くの権限を与えてしまいます。慎重に使い、より具体的なロールを選ぶことが推奨されます。

ファイアウォールの確認にも使えますか?

いいえ。このツールはGoogle CloudのIAM(アクセス権限)だけを対象としています。ファイアウォールについては、別のネットワークセキュリティツールを使う必要があります。

詳細

作者による元の説明

Auditing Google Cloud Platform IAM permissions to identify overly permissive bindings, primitive role usage, service account key proliferation, and cross-project access risks using gcloud CLI, Policy Analyzer, and IAM Recommender. '

repo: mukul975/Anthropic-Cybersecurity-Skills

人気

GitHubのスター
35k
ランキング
#7680
ライセンス
Apache-2.0
更新日
2026/8/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル