[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HC6FY83T8DPDXWBVC5R2VJ":3,"skill-same:01M6HC6FY83T8DPDXWBVC5R2VJ":98},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":59,"commitSha":60,"skillDirectory":61,"forksCount":62,"repositoryHtmlUrl":63,"repositoryHomepageUrl":6,"ownerHtmlUrl":64,"ownerBlogUrl":6,"ownerDescription":65,"updatedAt":66,"install":67,"resources":80},"01M6HC6FY83T8DPDXWBVC5R2VJ","auditing-gcp-iam-permissions",null,"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.","HenriqueMC17\u002Fagente-core","HenriqueMC17","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F206460478?v=4","01M6HB63HBBF18AC4H09XTB549","Henrique Monteiro Cardoso","01M6HB63NGSQXWKWCFWW2B20W0",1,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fauditing-gcp-iam-permissions\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"permissions","gcp","iam","auditing gcp iam permissions","permissions-audit","de","project","cm","access","t1098","t1078","policy-analyzer","service-accounts","google","cloud-security","audit","cybersecurity","security","google cloud","cli","2026-11-10 10:12:30",false,"---\nname: auditing-gcp-iam-permissions\ndescription: '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.\n\n  '\ndomain: cybersecurity\nsubdomain: cloud-security\ntags:\n- cloud-security\n- gcp\n- iam\n- permissions-audit\n- service-accounts\n- policy-analyzer\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.IR-01\n- ID.AM-08\n- GV.SC-06\n- DE.CM-01\nmitre_attack:\n- T1078.004\n- T1098.003\n- T1528\n- T1548.005\n- T1580\ncategory: auditing-gcp-iam-permissions\n---\n# Auditing GCP IAM Permissions\n\n## When to Use\n\n- When performing security assessments of GCP organization or project IAM configurations\n- When identifying service accounts with excessive permissions or unused access\n- When compliance requirements mandate review of access controls and role assignments\n- When investigating potential lateral movement through IAM misconfigurations\n- When reducing the blast radius of compromised credentials by scoping down permissions\n\n**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).\n\n## Prerequisites\n\n- GCP organization or project with `roles\u002Fiam.securityReviewer` and `roles\u002FcloudAsset.viewer`\n- gcloud CLI authenticated with appropriate permissions\n- Cloud Asset API enabled (`gcloud services enable cloudasset.googleapis.com`)\n- IAM Recommender API enabled (`gcloud services enable recommender.googleapis.com`)\n- Policy Analyzer API enabled (`gcloud services enable policyanalyzer.googleapis.com`)\n\n## Workflow\n\n### Step 1: Enumerate IAM Bindings Across the Organization\n\nList all IAM bindings at organization, folder, and project levels to understand the full access landscape.\n\n```bash\n# Organization-level IAM bindings\ngcloud organizations get-iam-policy ORG_ID \\\n  --format=json > org-iam-policy.json\n\n# Search all IAM policies across the organization\ngcloud asset search-all-iam-policies \\\n  --scope=organizations\u002FORG_ID \\\n  --format=\"table(resource, policy.bindings.role, policy.bindings.members)\" \\\n  --limit=500\n\n# Find all users and service accounts with Owner role\ngcloud asset search-all-iam-policies \\\n  --scope=organizations\u002FORG_ID \\\n  --query=\"policy:roles\u002Fowner\" \\\n  --format=\"table(resource, policy.bindings.members)\"\n\n# Find all bindings using primitive roles (Owner, Editor, Viewer)\ngcloud asset search-all-iam-policies \\\n  --scope=organizations\u002FORG_ID \\\n  --query=\"policy:roles\u002Fowner OR policy:roles\u002Feditor\" \\\n  --format=json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor result in data:\n    resource = result.get('resource', '')\n    for binding in result.get('policy', {}).get('bindings', []):\n        role = binding.get('role', '')\n        if role in ['roles\u002Fowner', 'roles\u002Feditor']:\n            for member in binding.get('members', []):\n                print(f'{resource} | {role} | {member}')\n\"\n```\n\n### Step 2: Audit Service Accounts and Their Keys\n\nIdentify service accounts with excessive permissions, user-managed keys, and unused accounts.\n\n```bash\n# List all service accounts in a project\ngcloud iam service-accounts list \\\n  --project=PROJECT_ID \\\n  --format=\"table(email, displayName, disabled)\"\n\n# Check for user-managed keys (should be minimized)\nfor sa in $(gcloud iam service-accounts list --project=PROJECT_ID --format=\"value(email)\"); do\n  keys=$(gcloud iam service-accounts keys list \\\n    --iam-account=\"$sa\" \\\n    --managed-by=user \\\n    --format=\"table(name.basename(),validAfterTime,validBeforeTime)\")\n  if [ -n \"$keys\" ]; then\n    echo \"=== $sa ===\"\n    echo \"$keys\"\n  fi\ndone\n\n# Find service accounts with admin roles across all projects\ngcloud asset search-all-iam-policies \\\n  --scope=organizations\u002FORG_ID \\\n  --query=\"policy.bindings.members:serviceAccount AND (policy:roles\u002Fowner OR policy:roles\u002Feditor OR policy:admin)\" \\\n  --format=\"table(resource, policy.bindings.role, policy.bindings.members)\"\n\n# Check service account IAM policies (who can impersonate)\nfor sa in $(gcloud iam service-accounts list --project=PROJECT_ID --format=\"value(email)\"); do\n  echo \"=== $sa ===\"\n  gcloud iam service-accounts get-iam-policy \"$sa\" --format=json 2>\u002Fdev\u002Fnull\ndone\n```\n\n### Step 3: Use IAM Recommender to Identify Excess Permissions\n\nLeverage GCP's IAM Recommender to find roles that grant more access than actually used.\n\n```bash\n# List IAM role recommendations for a project\ngcloud recommender recommendations list \\\n  --project=PROJECT_ID \\\n  --recommender=google.iam.policy.Recommender \\\n  --location=global \\\n  --format=\"table(name, description, priority, stateInfo.state)\"\n\n# Get detailed recommendation\ngcloud recommender recommendations describe RECOMMENDATION_ID \\\n  --project=PROJECT_ID \\\n  --recommender=google.iam.policy.Recommender \\\n  --location=global \\\n  --format=json\n\n# List insights about IAM usage\ngcloud recommender insights list \\\n  --project=PROJECT_ID \\\n  --insight-type=google.iam.policy.Insight \\\n  --location=global \\\n  --format=\"table(name, description, severity, category)\"\n\n# Apply a recommendation (after review)\ngcloud recommender recommendations mark-claimed RECOMMENDATION_ID \\\n  --project=PROJECT_ID \\\n  --recommender=google.iam.policy.Recommender \\\n  --location=global \\\n  --etag=ETAG\n```\n\n### Step 4: Analyze Effective Permissions with Policy Analyzer\n\nUse Policy Analyzer to determine effective access for specific principals or resources.\n\n```bash\n# Check who has access to a specific resource\ngcloud asset analyze-iam-policy \\\n  --organization=ORG_ID \\\n  --full-resource-name=\"\u002F\u002Fstorage.googleapis.com\u002Fprojects\u002F_\u002Fbuckets\u002Fsensitive-data-bucket\" \\\n  --format=\"table(identityList.identities, accessControlLists.accesses.role)\"\n\n# Check what resources a specific user can access\ngcloud asset analyze-iam-policy \\\n  --organization=ORG_ID \\\n  --identity=\"user:developer@company.com\" \\\n  --format=\"table(accessControlLists.resources.fullResourceName, accessControlLists.accesses.role)\"\n\n# Check who can perform a specific action\ngcloud asset analyze-iam-policy \\\n  --organization=ORG_ID \\\n  --full-resource-name=\"\u002F\u002Fcloudresourcemanager.googleapis.com\u002Fprojects\u002FPROJECT_ID\" \\\n  --permissions=\"iam.serviceAccounts.actAs,iam.serviceAccountKeys.create\" \\\n  --format=\"table(identityList.identities, accessControlLists.accesses.permission)\"\n\n# Find all principals with allUsers or allAuthenticatedUsers access\ngcloud asset search-all-iam-policies \\\n  --scope=organizations\u002FORG_ID \\\n  --query=\"policy:allUsers OR policy:allAuthenticatedUsers\" \\\n  --format=\"table(resource, policy.bindings.role, policy.bindings.members)\"\n```\n\n### Step 5: Check for Domain-Wide Delegation and Impersonation Risks\n\nIdentify service accounts with domain-wide delegation and impersonation capabilities.\n\n```bash\n# Check for service accounts with domain-wide delegation\n# (Requires Admin SDK access to list delegated accounts)\ngcloud iam service-accounts list --project=PROJECT_ID --format=json | python3 -c \"\nimport json, sys\naccounts = json.load(sys.stdin)\nfor sa in accounts:\n    email = sa.get('email', '')\n    # Check if the SA has domain-wide delegation enabled\n    # This requires Admin SDK API access\n    print(f'SA: {email} - Check admin.google.com for delegation status')\n\"\n\n# Find service accounts that other identities can impersonate\nfor sa in $(gcloud iam service-accounts list --project=PROJECT_ID --format=\"value(email)\"); do\n  policy=$(gcloud iam service-accounts get-iam-policy \"$sa\" --format=json 2>\u002Fdev\u002Fnull)\n  if echo \"$policy\" | python3 -c \"\nimport json, sys\np = json.load(sys.stdin)\nfor b in p.get('bindings', []):\n    if b['role'] in ['roles\u002Fiam.serviceAccountTokenCreator', 'roles\u002Fiam.serviceAccountUser']:\n        print(f'  {b[\\\"role\\\"]}: {b[\\\"members\\\"]}')\n\" 2>\u002Fdev\u002Fnull; then\n    echo \"=== Impersonation risk: $sa ===\"\n  fi\ndone\n```\n\n### Step 6: Generate Audit Report and Apply Remediation\n\nCompile findings and implement recommended permission reductions.\n\n```bash\n# Remove primitive role and replace with predefined role\ngcloud projects remove-iam-policy-binding PROJECT_ID \\\n  --member=\"user:developer@company.com\" \\\n  --role=\"roles\u002Feditor\"\n\ngcloud projects add-iam-policy-binding PROJECT_ID \\\n  --member=\"user:developer@company.com\" \\\n  --role=\"roles\u002Fcompute.viewer\"\n\ngcloud projects add-iam-policy-binding PROJECT_ID \\\n  --member=\"user:developer@company.com\" \\\n  --role=\"roles\u002Fstorage.objectViewer\"\n\n# Delete unused service account keys\ngcloud iam service-accounts keys delete KEY_ID \\\n  --iam-account=SA_EMAIL\n\n# Disable unused service accounts\ngcloud iam service-accounts disable SA_EMAIL --project=PROJECT_ID\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| Primitive Role | Legacy GCP roles (Owner, Editor, Viewer) that grant broad permissions across all services, not recommended for production |\n| Predefined Role | GCP-managed role scoped to specific services and actions, providing more granular access than primitive roles |\n| IAM Recommender | GCP ML-based service that analyzes actual permission usage and suggests role reductions to achieve least privilege |\n| Policy Analyzer | Tool for analyzing effective IAM access across the organization hierarchy, answering who-can-access-what queries |\n| Service Account Key | User-managed credential for service account authentication, a security risk as keys can be exported and do not auto-expire |\n| Domain-Wide Delegation | Grants a service account the ability to impersonate any user in the Google Workspace domain, a significant privilege escalation risk |\n\n## Tools & Systems\n\n- **gcloud CLI**: Primary tool for querying and managing GCP IAM policies, service accounts, and role bindings\n- **IAM Recommender**: ML-based recommendation engine for reducing excessive permissions based on actual usage\n- **Policy Analyzer**: Organization-wide effective access analysis tool for understanding who can access what\n- **Cloud Asset Inventory**: Cross-project search for IAM policies and resource metadata\n- **ScoutSuite**: Multi-cloud auditing tool with GCP IAM-specific checks for role assignments and service accounts\n\n## Common Scenarios\n\n### Scenario: Reducing Primitive Role Usage Across a GCP Organization\n\n**Context**: An audit reveals that 60% of IAM bindings across the organization use primitive roles (Owner\u002FEditor). The security team needs to migrate to predefined roles without disrupting developer workflows.\n\n**Approach**:\n1. Run `gcloud asset search-all-iam-policies` to inventory all primitive role bindings\n2. Use IAM Recommender to get ML-based suggestions for replacement predefined roles\n3. For each binding, use Policy Analyzer to understand what the principal actually accesses\n4. Create a mapping document: primitive role -> specific predefined roles needed\n5. Apply predefined roles alongside primitive roles for a testing period\n6. Monitor for access denied errors using Cloud Audit Logs\n7. Remove primitive roles after confirming no access issues over 2 weeks\n\n**Pitfalls**: Primitive roles include permissions across all GCP services, so replacing them requires multiple predefined roles. The Recommender may suggest overly restrictive roles if the observation period does not capture all use cases. Custom roles can fill gaps where no predefined role matches the exact permission set needed.\n\n## Output Format\n\n```\nGCP IAM Permissions Audit Report\n===================================\nOrganization: acme-org (ORG_ID: 123456789)\nProjects Audited: 25\nAudit Date: 2026-02-23\n\nIAM BINDING SUMMARY:\n  Total bindings:                    342\n  Using primitive roles:             205 (60%)\n  Using predefined roles:            112 (33%)\n  Using custom roles:                 25 (7%)\n\nCRITICAL FINDINGS:\n[IAM-001] Service Account with Owner Role\n  SA: admin-sa@prod-project.iam.gserviceaccount.com\n  Role: roles\u002Fowner on project prod-project\n  User-Managed Keys: 3 (oldest: 14 months)\n  Remediation: Replace with specific predefined roles, delete old keys\n\n[IAM-002] allAuthenticatedUsers Binding\n  Resource: gs:\u002F\u002Fpublic-data-bucket\n  Role: roles\u002Fstorage.objectViewer\n  Risk: Any Google account holder can read bucket contents\n  Remediation: Restrict to specific user groups or service accounts\n\nSERVICE ACCOUNT HEALTH:\n  Total service accounts:            67\n  With user-managed keys:            23\n  Keys older than 90 days:           18\n  Unused accounts (90+ days):        12\n  With domain-wide delegation:        2\n\nRECOMMENDER SUGGESTIONS:\n  Total recommendations:             45\n  Priority HIGH:                     12\n  Estimated permissions reduced:     2,847 individual permissions\n```\n","# Auditing GCP IAM Permissions\n\n## When to Use\n\n- When performing security assessments of GCP organization or project IAM configurations\n- When identifying service accounts with excessive permissions or unused access\n- When compliance requirements mandate review of access controls and role assignments\n- When investigating potential lateral movement through IAM misconfigurations\n- When reducing the blast radius of compromised credentials by scoping down permissions\n\n**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).\n\n## Prerequisites\n\n- GCP organization or project with `roles\u002Fiam.securityReviewer` and `roles\u002FcloudAsset.viewer`\n- gcloud CLI authenticated with appropriate permissions\n- Cloud Asset API enabled (`gcloud services enable cloudasset.googleapis.com`)\n- IAM Recommender API enabled (`gcloud services enable recommender.googleapis.com`)\n- Policy Analyzer API enabled (`gcloud services enable policyanalyzer.googleapis.com`)\n\n## Workflow\n\n### Step 1: Enumerate IAM Bindings Across the Organization\n\nList all IAM bindings at organization, folder, and project levels to understand the full access landscape.\n\n```bash\n# Organization-level IAM bindings\ngcloud organizations get-iam-policy ORG_ID \\\n  --format=json > org-iam-policy.json\n\n# Search all IAM policies across the organization\ngcloud asset search-all-iam-policies \\\n  --scope=organizations\u002FORG_ID \\\n  --format=\"table(resource, policy.bindings.role, policy.bindings.members)\" \\\n  --limit=500\n\n# Find all users and service accounts with Owner role\ngcloud asset search-all-iam-policies \\\n  --scope=organizations\u002FORG_ID \\\n  --query=\"policy:roles\u002Fowner\" \\\n  --format=\"table(resource, policy.bindings.members)\"\n\n# Find all bindings using primitive roles (Owner, Editor, Viewer)\ngcloud asset search-all-iam-policies \\\n  --scope=organizations\u002FORG_ID \\\n  --query=\"policy:roles\u002Fowner OR policy:roles\u002Feditor\" \\\n  --format=json | python3 -c \"\nimport json, sys\ndata = json.load(sys.stdin)\nfor result in data:\n    resource = result.get('resource', '')\n    for binding in result.get('policy', {}).get('bindings', []):\n        role = binding.get('role', '')\n        if role in ['roles\u002Fowner', 'roles\u002Feditor']:\n            for member in binding.get('members', []):\n                print(f'{resource} | {role} | {member}')\n\"\n```\n\n### Step 2: Audit Service Accounts and Their Keys\n\nIdentify service accounts with excessive permissions, user-managed keys, and unused accounts.\n\n```bash\n# List all service accounts in a project\ngcloud iam service-accounts list \\\n  --project=PROJECT_ID \\\n  --format=\"table(email, displayName, disabled)\"\n\n# Check for user-managed keys (should be minimized)\nfor sa in $(gcloud iam service-accounts list --project=PROJECT_ID --format=\"value(email)\"); do\n  keys=$(gcloud iam service-accounts keys list \\\n    --iam-account=\"$sa\" \\\n    --managed-by=user \\\n    --format=\"table(name.basename(),validAfterTime,validBeforeTime)\")\n  if [ -n \"$keys\" ]; then\n    echo \"=== $sa ===\"\n    echo \"$keys\"\n  fi\ndone\n\n# Find service accounts with admin roles across all projects\ngcloud asset search-all-iam-policies \\\n  --scope=organizations\u002FORG_ID \\\n  --query=\"policy.bindings.members:serviceAccount AND (policy:roles\u002Fowner OR policy:roles\u002Feditor OR policy:admin)\" \\\n  --format=\"table(resource, policy.bindings.role, policy.bindings.members)\"\n\n# Check service account IAM policies (who can impersonate)\nfor sa in $(gcloud iam service-accounts list --project=PROJECT_ID --format=\"value(email)\"); do\n  echo \"=== $sa ===\"\n  gcloud iam service-accounts get-iam-policy \"$sa\" --format=json 2>\u002Fdev\u002Fnull\ndone\n```\n\n### Step 3: Use IAM Recommender to Identify Excess Permissions\n\nLeverage GCP's IAM Recommender to find roles that grant more access than actually used.\n\n```bash\n# List IAM role recommendations for a project\ngcloud recommender recommendations list \\\n  --project=PROJECT_ID \\\n  --recommender=google.iam.policy.Recommender \\\n  --location=global \\\n  --format=\"table(name, description, priority, stateInfo.state)\"\n\n# Get detailed recommendation\ngcloud recommender recommendations describe RECOMMENDATION_ID \\\n  --project=PROJECT_ID \\\n  --recommender=google.iam.policy.Recommender \\\n  --location=global \\\n  --format=json\n\n# List insights about IAM usage\ngcloud recommender insights list \\\n  --project=PROJECT_ID \\\n  --insight-type=google.iam.policy.Insight \\\n  --location=global \\\n  --format=\"table(name, description, severity, category)\"\n\n# Apply a recommendation (after review)\ngcloud recommender recommendations mark-claimed RECOMMENDATION_ID \\\n  --project=PROJECT_ID \\\n  --recommender=google.iam.policy.Recommender \\\n  --location=global \\\n  --etag=ETAG\n```\n\n### Step 4: Analyze Effective Permissions with Policy Analyzer\n\nUse Policy Analyzer to determine effective access for specific principals or resources.\n\n```bash\n# Check who has access to a specific resource\ngcloud asset analyze-iam-policy \\\n  --organization=ORG_ID \\\n  --full-resource-name=\"\u002F\u002Fstorage.googleapis.com\u002Fprojects\u002F_\u002Fbuckets\u002Fsensitive-data-bucket\" \\\n  --format=\"table(identityList.identities, accessControlLists.accesses.role)\"\n\n# Check what resources a specific user can access\ngcloud asset analyze-iam-policy \\\n  --organization=ORG_ID \\\n  --identity=\"user:developer@company.com\" \\\n  --format=\"table(accessControlLists.resources.fullResourceName, accessControlLists.accesses.role)\"\n\n# Check who can perform a specific action\ngcloud asset analyze-iam-policy \\\n  --organization=ORG_ID \\\n  --full-resource-name=\"\u002F\u002Fcloudresourcemanager.googleapis.com\u002Fprojects\u002FPROJECT_ID\" \\\n  --permissions=\"iam.serviceAccounts.actAs,iam.serviceAccountKeys.create\" \\\n  --format=\"table(identityList.identities, accessControlLists.accesses.permission)\"\n\n# Find all principals with allUsers or allAuthenticatedUsers access\ngcloud asset search-all-iam-policies \\\n  --scope=organizations\u002FORG_ID \\\n  --query=\"policy:allUsers OR policy:allAuthenticatedUsers\" \\\n  --format=\"table(resource, policy.bindings.role, policy.bindings.members)\"\n```\n\n### Step 5: Check for Domain-Wide Delegation and Impersonation Risks\n\nIdentify service accounts with domain-wide delegation and impersonation capabilities.\n\n```bash\n# Check for service accounts with domain-wide delegation\n# (Requires Admin SDK access to list delegated accounts)\ngcloud iam service-accounts list --project=PROJECT_ID --format=json | python3 -c \"\nimport json, sys\naccounts = json.load(sys.stdin)\nfor sa in accounts:\n    email = sa.get('email', '')\n    # Check if the SA has domain-wide delegation enabled\n    # This requires Admin SDK API access\n    print(f'SA: {email} - Check admin.google.com for delegation status')\n\"\n\n# Find service accounts that other identities can impersonate\nfor sa in $(gcloud iam service-accounts list --project=PROJECT_ID --format=\"value(email)\"); do\n  policy=$(gcloud iam service-accounts get-iam-policy \"$sa\" --format=json 2>\u002Fdev\u002Fnull)\n  if echo \"$policy\" | python3 -c \"\nimport json, sys\np = json.load(sys.stdin)\nfor b in p.get('bindings', []):\n    if b['role'] in ['roles\u002Fiam.serviceAccountTokenCreator', 'roles\u002Fiam.serviceAccountUser']:\n        print(f'  {b[\\\"role\\\"]}: {b[\\\"members\\\"]}')\n\" 2>\u002Fdev\u002Fnull; then\n    echo \"=== Impersonation risk: $sa ===\"\n  fi\ndone\n```\n\n### Step 6: Generate Audit Report and Apply Remediation\n\nCompile findings and implement recommended permission reductions.\n\n```bash\n# Remove primitive role and replace with predefined role\ngcloud projects remove-iam-policy-binding PROJECT_ID \\\n  --member=\"user:developer@company.com\" \\\n  --role=\"roles\u002Feditor\"\n\ngcloud projects add-iam-policy-binding PROJECT_ID \\\n  --member=\"user:developer@company.com\" \\\n  --role=\"roles\u002Fcompute.viewer\"\n\ngcloud projects add-iam-policy-binding PROJECT_ID \\\n  --member=\"user:developer@company.com\" \\\n  --role=\"roles\u002Fstorage.objectViewer\"\n\n# Delete unused service account keys\ngcloud iam service-accounts keys delete KEY_ID \\\n  --iam-account=SA_EMAIL\n\n# Disable unused service accounts\ngcloud iam service-accounts disable SA_EMAIL --project=PROJECT_ID\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| Primitive Role | Legacy GCP roles (Owner, Editor, Viewer) that grant broad permissions across all services, not recommended for production |\n| Predefined Role | GCP-managed role scoped to specific services and actions, providing more granular access than primitive roles |\n| IAM Recommender | GCP ML-based service that analyzes actual permission usage and suggests role reductions to achieve least privilege |\n| Policy Analyzer | Tool for analyzing effective IAM access across the organization hierarchy, answering who-can-access-what queries |\n| Service Account Key | User-managed credential for service account authentication, a security risk as keys can be exported and do not auto-expire |\n| Domain-Wide Delegation | Grants a service account the ability to impersonate any user in the Google Workspace domain, a significant privilege escalation risk |\n\n## Tools & Systems\n\n- **gcloud CLI**: Primary tool for querying and managing GCP IAM policies, service accounts, and role bindings\n- **IAM Recommender**: ML-based recommendation engine for reducing excessive permissions based on actual usage\n- **Policy Analyzer**: Organization-wide effective access analysis tool for understanding who can access what\n- **Cloud Asset Inventory**: Cross-project search for IAM policies and resource metadata\n- **ScoutSuite**: Multi-cloud auditing tool with GCP IAM-specific checks for role assignments and service accounts\n\n## Common Scenarios\n\n### Scenario: Reducing Primitive Role Usage Across a GCP Organization\n\n**Context**: An audit reveals that 60% of IAM bindings across the organization use primitive roles (Owner\u002FEditor). The security team needs to migrate to predefined roles without disrupting developer workflows.\n\n**Approach**:\n1. Run `gcloud asset search-all-iam-policies` to inventory all primitive role bindings\n2. Use IAM Recommender to get ML-based suggestions for replacement predefined roles\n3. For each binding, use Policy Analyzer to understand what the principal actually accesses\n4. Create a mapping document: primitive role -> specific predefined roles needed\n5. Apply predefined roles alongside primitive roles for a testing period\n6. Monitor for access denied errors using Cloud Audit Logs\n7. Remove primitive roles after confirming no access issues over 2 weeks\n\n**Pitfalls**: Primitive roles include permissions across all GCP services, so replacing them requires multiple predefined roles. The Recommender may suggest overly restrictive roles if the observation period does not capture all use cases. Custom roles can fill gaps where no predefined role matches the exact permission set needed.\n\n## Output Format\n\n```\nGCP IAM Permissions Audit Report\n===================================\nOrganization: acme-org (ORG_ID: 123456789)\nProjects Audited: 25\nAudit Date: 2026-02-23\n\nIAM BINDING SUMMARY:\n  Total bindings:                    342\n  Using primitive roles:             205 (60%)\n  Using predefined roles:            112 (33%)\n  Using custom roles:                 25 (7%)\n\nCRITICAL FINDINGS:\n[IAM-001] Service Account with Owner Role\n  SA: admin-sa@prod-project.iam.gserviceaccount.com\n  Role: roles\u002Fowner on project prod-project\n  User-Managed Keys: 3 (oldest: 14 months)\n  Remediation: Replace with specific predefined roles, delete old keys\n\n[IAM-002] allAuthenticatedUsers Binding\n  Resource: gs:\u002F\u002Fpublic-data-bucket\n  Role: roles\u002Fstorage.objectViewer\n  Risk: Any Google account holder can read bucket contents\n  Remediation: Restrict to specific user groups or service accounts\n\nSERVICE ACCOUNT HEALTH:\n  Total service accounts:            67\n  With user-managed keys:            23\n  Keys older than 90 days:           18\n  Unused accounts (90+ days):        12\n  With domain-wide delegation:        2\n\nRECOMMENDER SUGGESTIONS:\n  Total recommendations:             45\n  Priority HIGH:                     12\n  Estimated permissions reduced:     2,847 individual permissions\n```\n",{"name":5,"tags":44,"author":45,"domain":35,"license":15,"version":46,"category":5,"nist_csf":47,"subdomain":33,"description":52,"mitre_attack":53},[33,20,21,23,31,30],"mahipal","1.0",[48,49,50,51],"PR.IR-01","ID.AM-08","GV.SC-06","DE.CM-01","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.\n",[54,55,56,57,58],"T1078.004","T1098.003","T1528","T1548.005","T1580","main","5eea5b3296f4673b5f481e8bcc1ba76281149f16","modules\u002Fauditing-gcp-iam-permissions",0,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core","https:\u002F\u002Fgithub.com\u002FHenriqueMC17","Qualquer tecnologia suficientemente avançada é indistinguível da mágica.","2026-09-28 22:40:38",{"source":8,"skillName":5,"commands":68,"prompt":78,"zipAvailable":79},[69,72,75],{"tool":70,"command":71},"npx","npx skills add HenriqueMC17\u002Fagente-core --skill auditing-gcp-iam-permissions",{"tool":73,"command":74},"bunx","bunx skills add HenriqueMC17\u002Fagente-core --skill auditing-gcp-iam-permissions",{"tool":76,"command":77},"pnpm","pnpm dlx skills add HenriqueMC17\u002Fagente-core --skill auditing-gcp-iam-permissions","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fauditing-gcp-iam-permissions\u002FSKILL.md",true,[81,86,92],{"path":82,"resourceType":82,"resourceTypeDesc":83,"sizeBytes":84,"sourceHtmlUrl":85},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fauditing-gcp-iam-permissions\u002FLICENSE",{"path":87,"resourceType":88,"resourceTypeDesc":89,"sizeBytes":90,"sourceHtmlUrl":91},"references\u002Fapi-reference.md","REFERENCE","参考文档",2205,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fauditing-gcp-iam-permissions\u002Freferences\u002Fapi-reference.md",{"path":93,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":96,"sourceHtmlUrl":97},"scripts\u002Fagent.py","SCRIPT","脚本",6137,"https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fauditing-gcp-iam-permissions\u002Fscripts\u002Fagent.py",[99,129,155,177,193,212],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":110,"publishedAt":39},"01M6HPFF0RCN0X6WT5EBSV71GY","validating-backup-integrity-for-recovery","Validate backup integrity through cryptographic hash verification, automated restore testing, corruption detection, and recoverability checks to ensure backups are reliable for disaster recovery and ransomware response scenarios.","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Fvalidating-backup-integrity-for-recovery\u002FSKILL.md",[105],{"categoryNo":106,"categoryName":107,"taxonomyType":108,"taxonomyTypeDesc":109},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[111,112,113,114,115,116,35,117,118,119,120,121,122,29,123,124,125,126,127,128],"integrity","backup","recovery","validating backup integrity for recovery","for","testing","validate","verification","hash-verification","incident-response","ransomware","detection","t1490","disaster-recovery","restore","incident","disaster recovery","ransomware response",{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":135,"publishedAt":39},"01M6HPFAWJVFK25Q33K3T7WQ8G","triaging-vulnerabilities-with-ssvc-framework","Triage and prioritize vulnerabilities using CISA's Stakeholder-Specific Vulnerability Categorization (SSVC) decision tree framework to produce actionable remediation priorities.","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Ftriaging-vulnerabilities-with-ssvc-framework\u002FSKILL.md",[],[136,137,138,139,140,35,141,142,143,144,145,146,147,148,149,150,151,152,153,154],"vulnerabilities","framework","ssvc","triaging vulnerabilities with ssvc framework","with","triage and prioritize","CISA","vulnerability-management","risk-management","cvss","remediation","vulnerability","prioritization","decision-tree","prioritize","decision","priorities","actionable","tree",{"skillNo":156,"name":157,"nameZh":6,"description":158,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":159,"categories":160,"keywords":161,"publishedAt":39},"01M6HPF6JS9X72WP59094H3ASQ","triaging-security-incident","Performs initial triage of security incidents to determine severity, scope, and required response actions using the NIST SP 800-61r3 and SANS PICERL frameworks. Classifies incidents by type, assigns priority based on business impact, and routes...","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Ftriaging-security-incident\u002FSKILL.md",[],[36,162,126,35,163,164,165,29,123,166,167,168,169,170,171,172,173,174,175,176],"triaging security incident","actions","soc","NIST","analysis","severity-classification","incident-triage","SANS-PICERL","SOC-operations","picerl","conversion","isolation","scope","impact","consistency",{"skillNo":178,"name":179,"nameZh":6,"description":180,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":181,"categories":182,"keywords":183,"publishedAt":39},"01M6HPF2EX6ZYNYYHKBRJN7GEF","triaging-security-incident-with-ir-playbook","Classify and prioritize security incidents using structured IR playbooks to determine severity, assign response teams, and initiate appropriate response procedures.","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Ftriaging-security-incident-with-ir-playbook\u002FSKILL.md",[],[36,184,185,162,126,140,35,186,164,120,187,188,29,123,189,167,150,190,191,192],"playbook","triaging security incident with ir playbook","teams","IR-playbook","severity","classification","classify","incidents","initiate",{"skillNo":194,"name":195,"nameZh":6,"description":196,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":197,"categories":198,"keywords":199,"publishedAt":39},"01M6HPEY9XPGE7X95AG4XJFQAW","triaging-security-alerts-in-splunk","Triages security alerts in Splunk Enterprise Security by classifying severity, investigating notable events, correlating related telemetry, and making escalation or closure decisions using SPL queries and the Incident Review dashboard. Use when...","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Ftriaging-security-alerts-in-splunk\u002FSKILL.md",[],[36,200,201,202,203,204,35,205,206,207,164,208,29,209,210,211,170,26,126,24],"security alerts","splunk","triaging security alerts in splunk","alerts","review","siem","dashboard","search","correlation-search","t1566","notable-events","incident-review",{"skillNo":213,"name":214,"nameZh":6,"description":215,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":216,"categories":217,"keywords":218,"publishedAt":39},"01M6HPET6XGEPEJPN7V032JGZ0","tracking-threat-actor-infrastructure","Threat actor infrastructure tracking involves monitoring and mapping adversary-controlled assets including command-and-control (C2) servers, phishing domains, exploit kit hosts, bulletproof hosting, a","https:\u002F\u002Fgithub.com\u002FHenriqueMC17\u002Fagente-core\u002Fblob\u002Fmain\u002Fmodules\u002Ftracking-threat-actor-infrastructure\u002FSKILL.md",[],[219,220,221,222,35,223,224,225,226,227,228,209,229,230,26,231,24,232,233,234],"infrastructure","tracking threat actor infrastructure","tracking","threat","monitoring","mitre-attack","threat-actor","threat-intelligence","command-and-control","dns","command","exploit","intelligence","domains","kit","hosts"]