Description
It is recommended that the IAM policy on a Cloud Storage bucket does not allow anonymous or public access.
Rationaleβ
Allowing anonymous or public access grants permissions to anyone to access bucket content. Such access might not be desired if you are storing sensitive data. Ensure that anonymous or public access to a bucket is not allowed.
Impactβ
No storage buckets would be publicly accessible. You would have to explicitly administer bucket access.
Auditβ
From Google Cloud Consoleβ
- Go to
Storage browserby visiting https://console.cloud.google.com/storage/browser. - Click on each bucket name to go to its
Bucket detailspage. - Click on the
Permissionstab. - Ensure that
allUsersandallAuthenticatedUsersare not in theMemberslist.
From Google Cloud CLIβ
-
List all buckets in a project:
gsutil ls -
Check the IAM policy for each bucket:
gsutil iam get gs://{{bucket-name}}
No role should contain allUsers and/or allAuthenticatedUsers as a member.
Using Rest APIβ
-
List all buckets in a project:
Get https://www.googleapis.com/storage/v1/b?project={{project-name}}
-
Check the IAM policy for each bucket:
GET https://www.googleapis.com/storage/v1/b/{{bucket-name}}/iam
No role should contain allUsers and/or allAuthenticatedUsers as a member.
Preventionβ
You can prevent Storage buckets from becoming publicly accessible by setting up the Domain restricted sharing organization policy at: https://console.cloud.google.com/iam-admin/orgpolicies/iam-allowedPolicyMemberDomains.
Default Valueβ
By default, Storage buckets are not publicly shared.
Referencesβ
- https://cloud.google.com/storage/docs/access-control/iam-reference
- https://cloud.google.com/storage/docs/access-control/making-data-public
- https://cloud.google.com/storage/docs/gsutil/commands/iam
Additional Informationβ
To implement access restrictions on buckets, configuring bucket IAM is preferred over configuring bucket ACLs. In the GCP console, Edit Permissions for a bucket exposes IAM configurations only. Bucket ACLs are configured automatically as needed to implement or support user-enforced bucket IAM policy. If an administrator changes a bucket ACL using the command line (gsutil) or API, bucket IAM also gets updated automatically.