iam-audit
Skill0 starsChanged 4 months agoMITView on GitHub
Audit IAM bindings on a GCP project for overly broad roles and stale service account keys. Use when the user asks to review IAM on a project, find who has owner or editor, find unused service account keys, or assess the least-privilege posture of a GCP project before a security review.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- imMamdouhaboammar/cybersecurity-skillstheir own version, first seen Sep 5, 2026
- briiirussell/cybersecurity-skillstheir own version, first seen May 27, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- briiirussell/cybersecurity-skills★ 410same name
- imMamdouhaboammar/cybersecurity-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- cloud-run-deploySkill
- firestore-rulesSkill
- gcloud-debugSkill
- gke-manifestSkill
- terraform-gcpSkill
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 7 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 31
Read the command output and index bindings by role, then by member.
- Distinctive: line 47
Default service accounts used outside of their intended scope:
- Distinctive: line 59
Read the list of permissions.
- Very specific: line 84
Do not list keys with --managed-by=system.
- Distinctive: line 88
If the user has audit logs, check for service accounts that have not authenticated in the last 90 days:
- Distinctive: line 181
Delete user-managed keys and switch to Workload Identity or Workload Identity Federation.
- Very specific: line 185
When flagging a broad predefined role, consult reference/iam-common-roles.md in the plugin root for narrower alternatives.
- Distinctive: line 189
Do not modify any binding yourself.
- Very specific: line 190
Do not print the contents of any gcloud iam service-accounts keys create output or any key file the user references.
- Distinctive: line 191
Do not flag every role as critical.
- Very specific: line 192
Do not list keys with --managed-by=system.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Audit GCP IAM
Review project IAM bindings and service account keys. Flag roles and bindings that violate least privilege.
Inputs
$ARGUMENTS is the GCP project id. If empty, run:
gcloud config get-value projectand confirm with the user before continuing.
Workflow
Step 1: pull the project IAM policy
gcloud projects get-iam-policy <project-id> \
--format=jsonRead the command output and index bindings by role, then by member. Do not write policy output to the user's working tree.
Step 2: flag broad roles
For each binding, check the role. Red flags:
roles/owneron any member other than a known human admin group. Owner can grant any role to any identity, including itself.roles/editoron a service account. Editor can read and write most resources in the project.roles/iam.securityAdminorroles/resourcemanager.projectIamAdminon anything other than a dedicated break-glass identity.roles/iam.serviceAccountUserorroles/iam.serviceAccountTokenCreatorat the project level. These let the member impersonate every service account in the project. Grant them on a specific service account, not project-wide.- Custom roles that include wildcard permissions like
*.setIamPolicy,*.actAs, oriam.*.
Step 3: flag risky members
allUsersorallAuthenticatedUsersbound to anything other than public-readable resources. These grant access to the entire internet.- External Google accounts (
user:someone@gmail.com) on production projects when SSO exists. - Default service accounts used outside of their intended scope:
<project-number>-compute@developer.gserviceaccount.com(Compute default SA) with roles beyondroles/logging.logWriterandroles/monitoring.metricWriter.<project-number>@cloudservices.gserviceaccount.comwith non-default roles.
Step 4: audit custom roles
gcloud iam roles list --project <project-id> --format jsonFor each custom role:
- Read the list of permissions.
- Flag any permission ending in
.setIamPolicy,.actAs, or any wildcard. - Flag roles that duplicate a predefined role (the user should use the predefined role).
Step 5: audit service account keys
gcloud iam service-accounts list --project <project-id> --format jsonFor each service account, list its keys:
gcloud iam service-accounts keys list \
--iam-account=<sa-email> \
--managed-by=user \
--format=jsonFlag:
- Any user-managed key older than 90 days.
- Service accounts with more than one user-managed key.
- Service accounts with a user-managed key that could use Workload Identity Federation instead (a key tied to a workload running on GKE, Cloud Run, GitHub Actions, or another supported platform).
Do not list keys with --managed-by=system. Those are rotated by Google.
Step 6: cross-reference with Cloud Audit Logs (optional)
If the user has audit logs, check for service accounts that have not authenticated in the last 90 days:
gcloud logging read 'protoPayload.authenticationInfo.principalEmail="<sa-email>"' \
--project <project-id> --limit 1 --freshness 90dAn empty result is strong evidence the account and its keys are unused.
Output
Group findings by severity. Each finding has the binding, the concrete risk, and a concrete fix.
Project: <project-id>
## Critical
- <member> has <role> at project scope. Risk: <what they can do that they should not>. Fix: <replacement role or removal command>.
## High
- <...>
## Medium
- <...>
## Info
- <N> service accounts with unused keys older than 90 days.For each finding, include the exact command the user must run to fix it. Do not run it yourself.
Example findings
Critical: the service account ci-runner@my-project.iam.gserviceaccount.com has roles/owner at the project level. A compromise of this account would give an attacker full control of the project, including the ability to exfiltrate data from every bucket and delete every resource.
Fix: replace with the specific roles CI actually needs. Common minimum set for CI running container builds and deploys:
gcloud projects remove-iam-policy-binding my-project \
--member=serviceAccount:ci-runner@my-project.iam.gserviceaccount.com \
--role=roles/owner
gcloud projects add-iam-policy-binding my-project \
--member=serviceAccount:ci-runner@my-project.iam.gserviceaccount.com \
--role=roles/artifactregistry.writer
gcloud projects add-iam-policy-binding my-project \
--member=serviceAccount:ci-runner@my-project.iam.gserviceaccount.com \
--role=roles/run.admin
gcloud projects add-iam-policy-binding my-project \
--member=serviceAccount:ci-runner@my-project.iam.gserviceaccount.com \
--role=roles/iam.serviceAccountUserThe last role is scoped below to only the runtime service account:
gcloud iam service-accounts add-iam-policy-binding \
api-runtime@my-project.iam.gserviceaccount.com \
--member=serviceAccount:ci-runner@my-project.iam.gserviceaccount.com \
--role=roles/iam.serviceAccountUserHigh: allUsers is bound to roles/storage.objectViewer at the project level. Every bucket in the project is world-readable.
Fix: remove the binding. If a single bucket should be public, set uniform bucket-level access and bind the role on that bucket only.
gcloud projects remove-iam-policy-binding my-project \
--member=allUsers \
--role=roles/storage.objectViewerHigh: service account data-export@my-project.iam.gserviceaccount.com has two user-managed keys. The oldest is 412 days old.
Fix: delete the old key and rotate the workload to Workload Identity Federation if it runs on a supported platform.
gcloud iam service-accounts keys delete <key-id> \
--iam-account=data-export@my-project.iam.gserviceaccount.comCommon fixes
- Replace
roles/ownerwith a scoped set of specific roles. - Replace
roles/editoron a service account with only the resource types it actually writes. - Move
roles/iam.serviceAccountUserfrom project scope to a single service account resource. - Convert a custom role with wildcards into a curated list of permissions.
- Delete user-managed keys and switch to Workload Identity or Workload Identity Federation.
Reference
When flagging a broad predefined role, consult reference/iam-common-roles.md in the plugin root for narrower alternatives. It is a tiered catalog (basic roles, cross-project, service-specific admin, viewer) with risk ratings, recommended replacements, and a custom-role template. Read on-demand only when suggesting a fix.
Do not
- Do not modify any binding yourself. The audit is read-only. Only propose the commands and let the user run them.
- Do not print the contents of any
gcloud iam service-accounts keys createoutput or any key file the user references. - Do not flag every role as critical. Calibrate severity: data exfiltration and IAM self-escalation are critical, read access to non-sensitive resources is info.
- Do not list keys with
--managed-by=system. Those are Google-managed and cannot be rotated by the user.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

