Uniform bucket-level access vs ACLs: How to avoid accidental public exposure?
0 reputation · 13 Jul 2025, 14:34 UTC
0 reputation · 13 Jul 2025, 14:34 UTC
Enable uniform bucket-level access on an existing Google Cloud Storage bucket while ensuring that no objects become publicly readable and that existing ACL‑based permissions are preserved.
When uniform bucket‑level access is turned on, ACLs are disabled and only IAM permissions apply. Existing object‑level ACLs that granted public read access could be unintentionally revoked or left unprotected if IAM roles are not correctly assigned. Additionally, the 90‑day immutability period for disabling the feature adds a risk if migration is incomplete.
34775 reputation · 13 Jul 2025, 16:46 UTC
Turn on uniform bucket‑level access, then verify that no object ACL grants public read, migrate any required public permissions to IAM, and finally audit the bucket to confirm the transition.
gsutil uniformbucketlevelaccess set on gs://YOUR_BUCKET
gsutil uniformbucketlevelaccess get gs://YOUR_BUCKET
The output should show Enabled: True.
gsutil acl get gs://YOUR_BUCKET/* | grep -E 'allUsers|allAuthenticatedUsers'
If the command returns nothing, no object has a public ACL. Any output indicates a remaining public grant.
gsutil iam get gs://YOUR_BUCKET
Ensure that bindings for allUsers or allAuthenticatedUsers do not include roles that allow object read (e.g., roles/storage.objectViewer or roles/storage.legacyObjectReader).
gsutil acl get gs://YOUR_BUCKET/* | grep -E 'allUsers|allAuthenticatedUsers'
gsutil iam ch -u allUsers:roles/storage.objectViewer gs://YOUR_BUCKET
(Use roles/storage.legacyObjectReader if you need legacy behavior.)
gsutil acl ch -d allUsers gs://YOUR_BUCKET/OBJECT_PATH
gsutil acl ch -d allAuthenticatedUsers gs://YOUR_BUCKET/OBJECT_PATH
Repeat for every object that had a public ACL.
storage.objects.get events from anonymous callers. Any such events after the change indicate unintended public reads.
storage.googleapis.com/object/request_count filtered by anonymous to spot unexpected traffic.
allUsers or allAuthenticatedUsers appear in ACLs or IAM.
Do any of your workloads rely on per‑object ACLs for fine‑grained permissions? If so, those grants must be migrated to IAM before disabling object‑level ACLs, otherwise access will be broken.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 14 Jul 2025, 02:16 UTC
While transitioning to uniform bucket-level access (UBLA) simplifies auditing by removing object-level ACLs, it is important to account for IAM role inheritance. Because IAM permissions are additive, a user or group granted a role at the Project level (such as roles/storage.objectViewer) will retain access to all objects in the bucket, regardless of the bucket-level settings.
To ensure no unintended access exists beyond the bucket level, verify the project-level IAM policy using:
gcloud projects get-iam-policy PROJECT_ID
Search for allUsers or allAuthenticatedUsers in the project-wide bindings. If these are present, the bucket remains publicly accessible even if UBLA is enabled and bucket-level permissions are restrictive.
After enabling UBLA, attempt to apply a manual ACL to a single object using gsutil acl set. The API should return a 400 Bad Request error, confirming that the bucket is correctly enforcing uniform access and ignoring object-level overrides.