48 of 50 in All Controls
gcp

Enforce Foundational IAM Organization Policy Constraints

IDGCP-IAM-002
Severity
high
Automation
Auto
Category
iam
Enforcementmandatory
Complexity / Impact
low(low impact)
Risk Profile
high likelihood(low residual)
Cloud Scopegcp:organization
Environments
productionnon-production
Target Resources
OrganizationPolicyFolderPolicyIAMPolicyServiceAccount
Services
iamresourcemanagerorgpolicycompute
Tags
gcpiamorg-policyguardrailslanding-zonegovernance
Frameworks
CIS GCPNIST 800-53ISO 27001PCI DSSSOC 2
Governance
cloud-security-team (quarterly)
Created
2026-08-28
Last Updated
2026-08-28

Specification & Description

Apply foundational IAM Organization Policy constraints at the organization root to restrict identity domains, prevent automatic broad role grants on default service accounts, and block unmanaged public key uploads.

Technical Specifications

Google Cloud Organization Policies act as immutable guardrails that enforce security baselines across all projects and folders, superseding local project IAM permissions. This control establishes four core IAM constraints at the organization root:

  1. Domain Restricted Sharing (constraints/iam.allowedPolicyMemberDomains): Restricts IAM role bindings exclusively to your corporate Cloud Identity or Google Workspace customer ID (e.g., C01234567). This blocks accidental or intentional grants to personal @gmail.com accounts or external tenants.

  2. Disable Default Service Account Role Grants (constraints/iam.automaticIamGrantsForDefaultServiceAccounts): By default, activating APIs like Compute Engine or App Engine automatically creates default service accounts (e.g., [PROJECT_NUMBER]-compute@developer.gserviceaccount.com) and binds them to the primitive roles/editor role across the entire project. This policy disables that automatic privilege assignment.

  3. Disable Service Account Key Upload (constraints/iam.disableServiceAccountKeyUpload): Blocks users from uploading self-generated public keys to service accounts, preventing the creation of untracked external credentials.

  4. Service Account Key Expiry (constraints/iam.serviceAccountKeyExpiryHours): For approved legacy exceptions where keys are strictly unavoidable, this constraint enforces an absolute maximum lifespan (e.g., 2160h / 90 days) on user-managed keys.

Security Rationale

Default Google Cloud project configurations favor rapid onboarding over security isolation. Without Domain Restricted Sharing, a rogue or compromised project owner can bind sensitive storage buckets or compute instances to an external personal account without triggering organizational identity validation. Furthermore, the default Compute Engine service account with roles/editor creates an instant lateral movement path: any compromised VM can modify IAM policies, read cloud secrets, and destroy project assets. Enforcing these constraints at the organization root eliminates default privilege escalation vectors and guarantees that all projects conform to baseline identity governance from inception.

Business & Security Impact

Prevents unauthorized identity federation and eliminates default overprivileged compute credentials. Existing projects with third-party external contractors or legacy service accounts must be granted explicit exceptions at the folder or project level before enforcing constraints globally.

Policy Exceptions (1)

Projects hosting multi-tenant customer integrations or SaaS applications that require granting IAM bindings to external customer Google accounts can configure an explicit override exception on a dedicated subfolder, provided external identities are logged and reviewed quarterly.

Operational & Implementation Notes

Enforcing Domain Restricted Sharing does not retroactively remove existing external IAM bindings. Before applying the policy, run an Asset Inventory IAM query across all projects to identify and remediate any existing bindings granted to domains outside your Cloud Identity directory.

Compliance Framework Mappings (5)

Regulatory baselines and industry standards mapped to this control specification.

Beta
Framework / StandardMapped Requirements & ControlsControls
CIS Google Cloud Platform Foundation Benchmark v3.0CIS GCP
1.51.61.8
3
NIST 800-53 Rev 5NIST 800-53
AC-2AC-3IA-2
3
ISO 27001:2022ISO 27001
A.5.15A.8.2
2
PCI DSS v4.0PCI DSS
7.2.17.2.2
2
SOC 2SOC 2
CC6.1CC6.3
2

* Compliance framework mappings are provided for informational architectural reference. Always verify control alignment against your organization's formal audit requirements.

Automated Detection & Rule Logic

Detection Engine: gcp-api • Automated: Yes

Query the Organization Policy API at the organization root to verify that all four foundational constraints are active: constraints/iam.allowedPolicyMemberDomains, constraints/iam.automaticIamGrantsForDefaultServiceAccounts, constraints/iam.disableServiceAccountKeyUpload, and constraints/iam.serviceAccountKeyExpiryHours. Additionally, query Cloud Asset Inventory across the organization to discover any existing non-compliant external domain bindings or default service accounts holding roles/editor.

Audit All 4 IAM Organization Policiesbash
ORG_ID="YOUR_ORGANIZATION_ID"

echo "=== 1. Domain Restricted Sharing ==="
gcloud resource-manager org-policies describe \
  constraints/iam.allowedPolicyMemberDomains \
  --organization="${ORG_ID}" \
  --format="yaml(constraint,listPolicy)"

echo "=== 2. Disable Default SA Automatic Grants ==="
gcloud resource-manager org-policies describe \
  constraints/iam.automaticIamGrantsForDefaultServiceAccounts \
  --organization="${ORG_ID}" \
  --format="yaml(constraint,booleanPolicy)"

echo "=== 3. Disable Service Account Key Upload ==="
gcloud resource-manager org-policies describe \
  constraints/iam.disableServiceAccountKeyUpload \
  --organization="${ORG_ID}" \
  --format="yaml(constraint,booleanPolicy)"

echo "=== 4. Service Account Key Expiry Hours ==="
gcloud resource-manager org-policies describe \
  constraints/iam.serviceAccountKeyExpiryHours \
  --organization="${ORG_ID}" \
  --format="yaml(constraint,booleanPolicy)"
Cloud Asset Inventory - Audit Existing Violationsbash
ORG_ID="YOUR_ORGANIZATION_ID"

# Search for default compute service accounts with Editor role across all projects
echo "=== Default SAs with Editor Role ==="
gcloud asset search-all-iam-policies \
  --scope="organizations/${ORG_ID}" \
  --query="roles:roles/editor AND policy:compute@developer.gserviceaccount.com" \
  --format="table(resource,project,policy.bindings.role,policy.bindings.members)"

# Search for unauthorized external domains in IAM policies
echo "=== External Domain Members ==="
gcloud asset search-all-iam-policies \
  --scope="organizations/${ORG_ID}" \
  --query="policy:@gmail.com" \
  --format="table(resource,project,policy.bindings.role,policy.bindings.members)"

Preventative Enforcement Policies

Terraform - Foundational IAM Org Policieshcl
# 1. Enforce Domain Restricted Sharing
resource "google_organization_policy" "domain_restricted_sharing" {
  org_id     = var.organization_id
  constraint = "constraints/iam.allowedPolicyMemberDomains"

  list_policy {
    allow {
      values = [var.cloud_identity_customer_id] # e.g., "C01234567"
    }
  }
}

# 2. Disable Automatic Role Grants for Default Service Accounts
resource "google_organization_policy" "disable_default_sa_grants" {
  org_id     = var.organization_id
  constraint = "constraints/iam.automaticIamGrantsForDefaultServiceAccounts"

  boolean_policy {
    enforced = true
  }
}

# 3. Disable External Service Account Key Uploads
resource "google_organization_policy" "disable_sa_key_upload" {
  org_id     = var.organization_id
  constraint = "constraints/iam.disableServiceAccountKeyUpload"

  boolean_policy {
    enforced = true
  }
}

# 4. Enforce Service Account Key Expiry Cap (90 days maximum)
resource "google_org_policy_policy" "sa_key_expiry" {
  name   = "organizations/${var.organization_id}/policies/iam.serviceAccountKeyExpiryHours"
  parent = "organizations/${var.organization_id}"

  spec {
    rules {
      values {
        allowed_values = ["2160h"] # 90 days max
      }
    }
  }
}
gcloud CLI Enforcementbash
# Enable Domain Restricted Sharing for your Directory Customer ID
gcloud org-policies set-policy --organization=ORGANIZATION_ID policy.yaml

# Disable automatic Editor grants for default service accounts
gcloud resource-manager org-policies enable-enforce \
  --organization=ORGANIZATION_ID \
  iam.automaticIamGrantsForDefaultServiceAccounts

# Disable service account public key uploads
gcloud resource-manager org-policies enable-enforce \
  --organization=ORGANIZATION_ID \
  iam.disableServiceAccountKeyUpload

Remediation Guide & Automation

Retrieve your Cloud Identity Customer ID and enforce Domain Restricted Sharing, Automatic SA Grant Disabling, and Key Upload Disabling at the Google Cloud organization root via Terraform or gcloud.

Step-by-Step Instructions

  1. Retrieve your Cloud Identity Directory Customer ID from the Google Admin Console (Account > Account Settings) or via gcloud.
  2. Deploy the Domain Restricted Sharing policy at the organization root, allowing only your approved Customer ID(s).
  3. Enable constraints/iam.automaticIamGrantsForDefaultServiceAccounts at the organization root to stop broad Editor role assignment on default service accounts.
  4. Enable constraints/iam.disableServiceAccountKeyUpload to block external key imports.
  5. Set constraints/iam.serviceAccountKeyExpiryHours to 2160h (90 days) to prevent permanent key persistence.
  6. Audit existing projects to revoke roles/editor from legacy default compute service accounts and replace them with custom, workload-scoped service accounts.
Remediation Script: Apply Org Policy Constraintsbash
ORG_ID="YOUR_ORGANIZATION_ID"
CUSTOMER_ID="YOUR_CLOUD_IDENTITY_CUSTOMER_ID" # e.g. C01234567

# 1. Disable Default SA Automatic Grants
gcloud resource-manager org-policies enable-enforce \
  --organization="${ORG_ID}" \
  iam.automaticIamGrantsForDefaultServiceAccounts

# 2. Disable Service Account Key Uploads
gcloud resource-manager org-policies enable-enforce \
  --organization="${ORG_ID}" \
  iam.disableServiceAccountKeyUpload

# 3. Create Domain Restricted Sharing Spec
cat <<EOF > domain_policy.yaml
constraint: constraints/iam.allowedPolicyMemberDomains
listPolicy:
  allowedValues:
    - "${CUSTOMER_ID}"
EOF

gcloud resource-manager org-policies set-policy domain_policy.yaml --organization="${ORG_ID}"
rm domain_policy.yaml

Cross-Cloud Policy Equivalence

Equivalent controls across multi-cloud provider platforms.

We value your privacy

We use analytics cookies to understand how visitors interact with our site and to improve the user experience. You can choose to accept or decline these cookies.