Enforce Foundational IAM Organization Policy Constraints
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:
-
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.comaccounts or external tenants. -
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 primitiveroles/editorrole across the entire project. This policy disables that automatic privilege assignment. -
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.
-
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.
| Framework / Standard | Mapped Requirements & Controls | Controls |
|---|---|---|
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.
Preventative Enforcement Policies
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
- Retrieve your Cloud Identity Directory Customer ID from the Google Admin Console (Account > Account Settings) or via gcloud.
- Deploy the Domain Restricted Sharing policy at the organization root, allowing only your approved Customer ID(s).
- Enable constraints/iam.automaticIamGrantsForDefaultServiceAccounts at the organization root to stop broad Editor role assignment on default service accounts.
- Enable constraints/iam.disableServiceAccountKeyUpload to block external key imports.
- Set constraints/iam.serviceAccountKeyExpiryHours to 2160h (90 days) to prevent permanent key persistence.
- Audit existing projects to revoke roles/editor from legacy default compute service accounts and replace them with custom, workload-scoped service accounts.
Cross-Cloud Policy Equivalence
Equivalent controls across multi-cloud provider platforms.