Overview
It is recommended that the IAM policy on Cloud KMS cryptokeys should restrict anonymous and/or public access.
Rationale
Granting permissions to allUsers or allAuthenticatedUsers allows anyone to access the dataset. Such access might not be desirable if sensitive data is stored at the location. In this case, ensure that anonymous and/or public access to a Cloud KMS cryptokey is not allowed.
Impact
Removing the binding for allUsers and allAuthenticatedUsers members denies accessing cryptokeys to anonymous or public users.
Remediation guidance
From Google Cloud CLI
- List all Cloud KMS Cryptokeys.
gcloud kms keys list --keyring=<keyRingName> --location=global --format=json | jq '.[].name'
- Remove IAM policy binding for a KMS key to remove access to
allUsersandallAuthenticatedUsersusing the below command.
gcloud kms keys remove-iam-policy-binding <keyName> --keyring=<keyRingName> --location=global --member='allAuthenticatedUsers' --role='<role>'
gcloud kms keys remove-iam-policy-binding <keyName> --keyring=<keyRingName> --location=global --member='allUsers' --role='<role>'
Default Value
By default Cloud KMS does not allow access to allUsers or allAuthenticatedUsers.
References
- https://cloud.google.com/sdk/gcloud/reference/kms/keys/remove-iam-policy-binding
- https://cloud.google.com/sdk/gcloud/reference/kms/keys/set-iam-policy
- https://cloud.google.com/sdk/gcloud/reference/kms/keys/get-iam-policy
- https://cloud.google.com/kms/docs/object-hierarchy#key_resource_id
Google Cloud Console (Asset-Level)
- Open the affected project/resource from the finding details in Google Cloud Console.
- Navigate to the resource security/configuration settings.
- Apply the control-specific secure configuration.
- Save and re-run the check.
Service-wide remediation
Recommended when many resources are affected: fix the platform baseline first so new resources inherit the secure setting, then remediate the existing flagged resources in batches.
Google Cloud
Use organization or folder policies where available, shared project templates, logs and alerting baselines, and IaC modules so new resources inherit the secure setting.
Operational rollout
- Fix the baseline first at the account, subscription, project, cluster, or tenant scope that owns this control.
- Remediate the currently affected resources in batches, starting with internet-exposed and production assets.
- Re-scan and track approved exceptions with an owner and expiry date.
Query logic
These are the stored checks tied to this control.
Cloud KMS cryptokeys are not anonymously or publicly accessible
Connectors
Covered asset types
Expected check: eq []
kmsKeys(where:{OR:[{policyDocument_CONTAINS:"allUsers"},{policyDocument_CONTAINS:"allAuthenticatedUsers"}]}){...AssetFragment}
Google Cloud