Description
This entry lists a Cloud Storage bucket declared in Terraform. Cloud Storage encrypts stored objects by default.
Potential impact
If public access prevention is off, a bucket READER ACL for allUsers lets anyone list object names. Granting roles/storage.admin to allUsers also lets anyone change the bucket and its data.
Remediation
Record the owner, purpose and retention policy. Check ACLs and IAM, including inherited grants to allUsers or allAuthenticatedUsers. For a customer-managed key, match its location to the bucket and grant the Cloud Storage service agent access.
Examples
The first excerpt configures public grants on two buckets. The second defines a separate bucket with uniform bucket-level access and grants roles/storage.objectViewer to the operations group. Supply the referenced KMS keys.
Before
resource "google_storage_bucket_access_control" "public_rule" {
bucket = google_storage_bucket.bucket.name
role = "READER"
entity = "allUsers"
}
resource "google_storage_bucket" "bucket" {
name = "static-content-bucket"
location = "US"
}
resource "google_storage_bucket_iam_binding" "binding" {
bucket = google_storage_bucket.bucket2.name
role = "roles/storage.admin"
members = [
"allUsers",
]
}
resource "google_storage_bucket" "bucket2" {
name = "static-content-bucket-2"
location = "US"
encryption {
default_kms_key_name = var.bucket_kms_key
}
}
After
resource "google_storage_bucket" "logs_bucket" {
name = "team-app-logs-prod"
location = "US"
uniform_bucket_level_access = true
encryption {
default_kms_key_name = google_kms_crypto_key.bucket_key.id
}
labels = {
service = "app"
env = "prod"
}
}
resource "google_storage_bucket_iam_member" "ops_reader" {
bucket = google_storage_bucket.logs_bucket.name
role = "roles/storage.objectViewer"
member = "group:ops@example.com"
}