For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/terraform-gcp-kms-crypto-key-publicly-accessible.md.
A documentation index is available at /llms.txt.
Google Cloud KMS CryptoKeys provide cryptographic functionality for encrypting and decrypting sensitive data in Google Cloud. When KMS CryptoKey IAM policies include allUsers or allAuthenticatedUsers, they become publicly accessible, creating a serious security vulnerability that could lead to unauthorized access to encryption capabilities, data breaches, or compromised encrypted information.
Insecure configuration example:
data "google_iam_policy" {
binding {
role = "roles/cloudkms.cryptoKeyEncrypter"
members = ["allUsers"]
}
}
Secure configuration with specific user access:
data "google_iam_policy" {
binding {
role = "roles/cloudkms.cryptoKeyEncrypter"
members = [
"user:jane@example.com",
]
}
}