Chuyển đến nội dung
Skillpedia
Triển khai và đám mây (DevOps)35k · #7680

auditing-gcp-iam-permissions

Skill này làm gì

Công cụ này giúp kiểm tra ai có quyền truy cập vào gì trong Google Cloud. Nó tìm các quyền quá rộng, tài khoản dịch vụ có quá nhiều khóa hoặc truy cập không cần thiết, và ai có thể truy cập tài nguyên qua các dự án khác nhau.

Khi nào nên dùng

  • ✓Khi xem xét bảo mật về việc ai được làm gì trong Google Cloud.
  • ✓Khi bạn muốn biết có tài khoản dịch vụ nào có quá nhiều quyền hoặc không còn được dùng hay không.
  • ✓Để đảm bảo các quy tắc truy cập tuân thủ tiêu chuẩn bảo mật.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/auditing-gcp-iam-permissions/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Kiểm tra quyền truy cập trong dự án Google Cloud của tôi để tìm truy cập quá mức.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ dùng các lệnh Google Cloud cụ thể để liệt kê mọi quyền, kiểm tra tài khoản dịch vụ và khóa của chúng, và phân tích ai có quyền truy cập tài nguyên nào. Sau đó, nó đề xuất cách giảm các quyền này.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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 \

…
Câu hỏi thường gặp

Tôi có cần cài đặt gì không?

Có. Bạn cần cài đặt và cấu hình công cụ “gcloud CLI” trên máy tính, cùng với các quyền cụ thể trong tài khoản Google Cloud.

“Primitive roles” là gì?

Đây là các vai trò chung chung như “Owner”, “Editor” và “Viewer” cấp rất nhiều quyền. Nên dùng cẩn thận và ưu tiên các vai trò cụ thể hơn.

Tôi có thể dùng công cụ này để kiểm tra tường lửa không?

Không. Công cụ này chỉ dành cho quyền truy cập (IAM) trong Google Cloud. Với tường lửa, bạn cần các công cụ bảo mật mạng khác.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
35k
Vị trí xếp hạng
#7680
Giấy phép
Apache-2.0
Cập nhật
31/8/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự