Description
It is recommended that IAM policy on Cloud Storage bucket does not allows 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 any sensitive data. Hence, 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 browser
by visiting https://console.cloud.google.com/storage/browser. - Click on each bucket name to go to its
Bucket details
page. - Click on the
Permissions
tab. - Ensure that
allUsers
andallAuthenticatedUsers
are not in theMembers
list.
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=<ProjectName>
-
Check the IAM Policy for each bucket
GET https://www.googleapis.com/storage/v1/b/<bucketName>/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 way than configuring Bucket ACL. On GCP console, "Edit Permissions" for bucket exposes IAM configurations only. Bucket ACLs are configured automatically as per need in order to implement/support User enforced Bucket IAM policy. In-case administrator changes bucket ACL using command-line(gsutils)/API bucket IAM also gets updated automatically.