Description
In a Cloud Storage IAM binding, allUsers includes anonymous users and allAuthenticatedUsers includes authenticated accounts from outside the project. Each principal receives the role in that binding. An empty members list grants nothing through that binding.
Potential impact
Public read grants can expose objects such as backups or logs. A write or administrative role can also allow changes to objects or bucket settings.
Remediation
Remove unnecessary public principals and grant the minimum roles to the users, groups or service accounts that need them. Remove unused bindings. Preserve required members when editing a google_storage_bucket_iam_binding, which manages the member list for its role. Check inherited IAM, ACLs and public access prevention. Uniform bucket-level access disables ACLs but leaves public IAM grants in place. Test approved and denied access.
Examples
Define google_storage_bucket.default and replace jane@example.com with the intended account. The resource address changes between examples. For an existing binding, review the Terraform plan before applying.
Before
resource "google_storage_bucket_iam_binding" "public_binding" {
bucket = google_storage_bucket.default.name
role = "roles/storage.admin"
members = ["user:jane@example.com", "allUsers"]
}
roles/storage.admin grants bucket and object administration to allUsers unless public access prevention or other controls block it.
After
resource "google_storage_bucket_iam_binding" "restricted_binding" {
bucket = google_storage_bucket.default.name
role = "roles/storage.admin"
members = [
"user:jane@example.com",
]
}
Removing allUsers leaves just the named user on this binding. That user still receives roles/storage.admin. Check whether their duties require it.