Event Information
-
Event meaning & scope
resourcemanager.projects.setIamPolicyis triggered when the IAM policy on a GCP project is set or replaced viaprojects.setIamPolicy.- This can add, remove, or modify bindings (roles → members) and organization policies attached at the project level.
-
Security / risk implications
- Potentially high‑impact: can grant or revoke broad access (e.g.,
roles/owner,roles/editor, custom roles) and can introduce privilege escalation if misused. - Monitor for changes that: add powerful roles, add external identities (e.g.,
*@gmail.com, external domains), or modify conditions that restrict access.
- Potentially high‑impact: can grant or revoke broad access (e.g.,
-
Practical monitoring & compliance actions
- Enable Cloud Audit Logs (Admin Activity) and route these events to SCC / SIEM; create alerts for:
- New owner/editor bindings; changes made by service accounts; changes from unusual IPs/regions.
- Periodically review
setIamPolicyevents for least‑privilege and alignment with standards like ISO 27001, SOC 2, and PCI DSS (access control, change management), and enforce approvals for high‑risk policy changes via change‑management workflows.
- Enable Cloud Audit Logs (Admin Activity) and route these events to SCC / SIEM; create alerts for:
Examples
-
Project-wide admin granted to broad principal (e.g.,
allAuthenticatedUsers/ entire domain)resourcemanager.projects.setIamPolicyused to addroles/ownerorroles/editorto a public or overly broad principal exposes all project resources (Compute, Storage, BigQuery, etc.) to misuse or data exfiltration, violating least privilege and compliance mandates (e.g., ISO 27001 A.9, SOC 2 CC6, CIS GCP 1.1).- Mitigation: Immediately revoke broad bindings via
gcloud projects get-iam-policy/set-iam-policy, enforce IAM Conditions, and use Org Policies to block public grants.
-
Privileged role escalation via custom or predefined roles
- An attacker (or misconfigured automation) uses
setIamPolicyto assign themselves or a compromised service account powerful roles likeroles/iam.admin,roles/owner, or a custom role withresourcemanager.projects.setIamPolicy/iam.serviceAccounts.actAsleading to persistent privilege escalation and control over identities and keys (GDPR Art. 32, HIPAA §164.308(a)(3)). - Mitigation: Monitor Cloud Audit Logs for policy changes, enable Cloud SCC/Chronicle rules to alert on risky bindings, and require approvals (change management) for role changes to high-privilege principals.
- An attacker (or misconfigured automation) uses
-
Cross-project / cross-tenant data access enabling unauthorized data flows
setIamPolicyis used to grant another project’s service account read access (e.g.,roles/storage.objectViewer,roles/bigquery.dataViewer) across environments (prod → test, or regulated → non‑regulated), breaking data-segregation controls and compliance boundaries (PCI DSS 3.4/7.1, FedRAMP AC-6).- Mitigation: Regular IAM reviews, policy analyzer (
gcloud iam policy-intelligenceor Policy Analyzer UI), labels/folders to segment regulated workloads, and guardrails via Org Policy plus CI/CD checks before applying IAM changes.
Remediation
Using Console
-
Revoke project‑wide admin from broad principals (e.g.,
allAuthenticatedUsers, entire domain)- Console: Go to IAM & Admin → IAM, use the Include Google-provided role grants filter, and look for principals like
allUsers,allAuthenticatedUsers, or broad groups/domains (e.g.,@example.com) withOwnerorEditor. - For each risky binding: click Edit principal (pencil icon) → remove
Owner/Editor(and any other unnecessary roles) → assign only the minimum required predefined role(s) or a tightly scoped custom role → Save. - Hardening: Under IAM & Admin → Organization policies, enforce controls such as “Domain restricted sharing” and “Restrict public IAM grants” to prevent future public/broad assignments and document this as a least‑privilege / segregation control for ISO 27001, SOC 2, and CIS checks.
- Console: Go to IAM & Admin → IAM, use the Include Google-provided role grants filter, and look for principals like
-
Stop privileged role escalation via custom/predefined roles
- Console: IAM & Admin → IAM, sort by Role and specifically review principals with
Owner,Editor,IAM Admin, Security Admin, and any Custom roles that containresourcemanager.projects.setIamPolicy,iam.serviceAccounts.actAs, oriam.roles.update. Remove or downgrade these roles from non‑break-glass users and generic service accounts; keep them only on tightly controlled admin identities. - Console: IAM & Admin → Roles → open each custom role → Permissions tab → search for high‑risk permissions (
setIamPolicy,roles.create/update,serviceAccounts.actAs, key management, org policy). Remove them where not strictly needed, or create separate “elevated admin” roles gated by strong approval and MFA. - Monitoring & approvals: In Security → Security Command Center (or Chronicle if available), enable and/or tune findings for risky IAM changes; in Logging → Logs Explorer, build saved queries for
SetIamPolicy/ IAM role changes and export to SIEM. Require change tickets and at least two‑person approval for assigning any role that can change IAM or act as service accounts (GDPR/HIPAA admin safeguards).
- Console: IAM & Admin → IAM, sort by Role and specifically review principals with
-
Control cross‑project / cross‑tenant data access (prevent unauthorized data flows)
- Discovery: Use IAM & Admin → IAM in each project and look for service accounts from other projects or external tenants (principal type = Service account, with different project ID) that have roles like
Storage Object Viewer,BigQuery Data Viewer, or custom read roles over sensitive projects (prod, regulated, PCI, PHI, etc.). Remove any access that is not explicitly approved per data‑segregation policy. - Guardrails: Use IAM & Admin → Policy Analyzer (Policy Intelligence) to simulate and review cross‑project access paths; for highly regulated workloads, group them under dedicated Folders and apply stricter Organization policies (e.g., restrict external service accounts, restrict cross‑project service account usage). Enforce environment‑specific labels (e.g.,
env=prod,data=regulated) and reference them in your internal standards. - Preventative controls: Integrate IAM changes into CI/CD (Terraform, Deployment Manager) with code review; add checks that block grants from regulated projects to non‑regulated ones or to foreign tenants. Periodically run IAM Recommender / Policy Intelligence to identify excess permissions and remediate to comply with PCI DSS and FedRAMP segregation requirements.
- Discovery: Use IAM & Admin → IAM in each project and look for service accounts from other projects or external tenants (principal type = Service account, with different project ID) that have roles like
Using CLI
-
Revoke project‑wide admin from broad principals (e.g.,
allAuthenticatedUsers, entire domain)- List current IAM policy and identify risky bindings:
gcloud projects get-iam-policy PROJECT_ID --format=json > iam.json- Review for bindings like
roles/owner,roles/editor, or other high‑privilege roles with members such asallAuthenticatedUsers,allUsers, or entire domains (domain:example.com).
- Remove/adjust risky bindings and re‑apply policy:
- Edit
iam.jsonto delete or narrow these bindings (e.g., per‑group or per‑service‑account, and preferably to least‑privilege roles). gcloud projects set-iam-policy PROJECT_ID iam.json
- Edit
- Enforce guardrails and conditions:
- Block future public grants:
gcloud org-policies set-policy org-policy.yamlwith constraints likeconstraints/iam.allowServiceAccountCredentialLifetimeExtension(as needed) and especiallyconstraints/iam.allowedPolicyMemberDomainsorconstraints/iam.disableServiceAccountKeyCreationas part of hardening, and useconstraints/iam.allowedPolicyMemberDomainsto restrict members to approved domains.
- Use conditional bindings to scope access, for example:
- Block future public grants:
- List current IAM policy and identify risky bindings:
-
Contain privileged role escalation via custom/predefined roles
- Identify and roll back risky high‑privilege grants:
gcloud projects get-iam-policy PROJECT_ID --format=json | jq '.bindings[] | select(.role | test("roles/owner|roles/editor|roles/iam.admin"))'- For each risky binding, remove it (or replace with least‑privilege roles) in
iam.jsonand re‑apply with:gcloud projects set-iam-policy PROJECT_ID iam.json
- Monitor and alert on IAM policy changes to privileged roles:
- Ensure Admin Activity logs for
setIamPolicyare enabled (they are by default) and routed:gcloud logging sinks create iam-changes-sink \ storage.googleapis.com/BUCKET_NAME \ --log-filter='protoPayload.methodName=("SetIamPolicy" OR "SetIamPolicy") AND resource.type="project"'
- Use Security Command Center / Chronicle to alert when
roles/owner,roles/iam.admin, custom roles containingresourcemanager.projects.setIamPolicyoriam.serviceAccounts.actAsare assigned.
- Ensure Admin Activity logs for
- Implement change control and constrained delegation:
- Restrict who can modify IAM:
- Require approvals via CI/CD: represent IAM as code (Terraform/YAML), and only allow
gcloud projects set-iam-policyvia pipelines with reviews, not from individual laptops.
- Restrict who can modify IAM:
- Identify and roll back risky high‑privilege grants:
-
Prevent unauthorized cross‑project / cross‑tenant data access
- Discover cross‑project grants:
gcloud projects get-iam-policy PROJECT_ID --format=json | jq '.bindings[] | select(.members[]? | contains("serviceAccount:"))'and note members from other projects/tenants.- For specific resources, e.g. GCS:
gcloud storage buckets get-iam-policy gs://BUCKET_NAME --format=json
- For BigQuery:
gcloud bq show --format=prettyjson PROJECT_ID:DATASET | jq '.access'
- Revoke or narrow cross‑environment access:
- Remove or restrict cross‑project
roles/storage.objectViewer,roles/bigquery.dataViewer, etc. by editing the respective IAM policies and re‑applying: - Where cross‑project access is required, use dedicated “broker” service accounts and least‑privilege roles limited to specific buckets/datasets, ideally with IAM Conditions (e.g., labels, resource names).
- Remove or restrict cross‑project
- Enforce segregation and pre‑deployment checks:
- Segment regulated workloads with folders/labels and tighter org policies (e.g., separate folders for PCI/HIPAA vs. non‑regulated, and enforce restrictive
constraints/iam.allowedPolicyMemberDomains/ resource‑location constraints). - Use Policy Analyzer / Policy Intelligence to continuously review effective access:
gcloud iam policy-intelligence analyze-iam-policy \ --full-resource-name="//cloudresourcemanager.googleapis.com/projects/PROJECT_NUMBER" \ --identity="serviceAccount:SA_NAME@OTHER_PROJECT.iam.gserviceaccount.com"
- Integrate IAM checks into CI/CD (e.g., policy linting) before running
gcloud ... set-iam-policyto prevent non‑compliant cross‑environment bindings.
- Segment regulated workloads with folders/labels and tighter org policies (e.g., separate folders for PCI/HIPAA vs. non‑regulated, and enforce restrictive
- Discover cross‑project grants:
Using Python
-
Revoke broad / public project-wide admin bindings (GCPIAM via Python)
- Follow-up: enforce org policies like
constraints/iam.allowedPolicyMemberDomains, forbidallUsers/allAuthenticatedUsersat project level, and use IAM Conditions to scope necessary public access only to specific resources.
- Follow-up: enforce org policies like
-
Detect and roll back privileged role escalation (owners / IAM admins / custom roles)
- Operationalize: back IaC (Terraform) as the source of truth, require change approvals for any
setIamPolicyaffecting HIGH_RISK_ROLES, and configure Cloud Logging + SCC / Chronicle rules to alert on these bindings.
- Operationalize: back IaC (Terraform) as the source of truth, require change approvals for any
-
Identify / prevent cross-project or cross-tenant data access violations
- Governance: use folders/labels to separate regulated vs non-regulated projects, enforce org policies (
constraints/iam.allowedPolicyMemberDomains,constraints/gcp.resourceLocations) and add CI/CD checks that block IAM changes creating cross-environment access to regulated projects.
- Governance: use folders/labels to separate regulated vs non-regulated projects, enforce org policies (

