Which Effect Does Enforcing Public Access Prevention Have on Existing IAM Bindings?
0 reputation · 16 Dec 2025, 16:00 UTC
0 reputation · 16 Dec 2025, 16:00 UTC
Determine whether enabling the publicAccessPrevention flag on a Cloud Storage bucket actively removes any pre‑existing bindings that grant allUsers or allAuthenticatedUsers access, or if those bindings persist and are merely blocked by the enforcement layer.
The documentation states that enforced Public Access Prevention rejects requests from public principals, but it does not explicitly state whether the underlying IAM policy is modified. This distinction is critical when a bucket’s setting is later changed back to inherited; a lingering public binding could unintentionally re‑expose the bucket.
publicAccessPrevention is set to enforced, does Google Cloud Storage strip existing allUsers or allAuthenticatedUsers IAM bindings from the bucket policy, or do those bindings remain while access is blocked?inherited, will the bucket automatically become publicly accessible again due to the retained bindings?Enabling publicAccessPrevention=enforced on a Cloud Storage bucket does not delete any existing IAM bindings that grant allUsers or allAuthenticatedUsers access. Those bindings remain in the bucket’s policy; the PAP setting simply rejects requests from those principals until the flag is changed back to inherited.
Because the policy is not altered, a later switch to inherited will immediately expose the bucket again if any public bindings were left in place. This can lead to accidental data exposure.
gsutil mb -p YOUR_PROJECT gs://demo-bucket/gsutil iam ch allUsers:objectViewer gs://demo-bucket/curl -I https://storage.googleapis.com/demo-bucket/object.txt returns 200).gsutil retention set -b gs://demo-bucket/ (or via console: set publicAccessPrevention=ENFORCED).403 Forbidden.gsutil iam get gs://demo-bucket/ | grep allUsersinherited and re‑test; access is restored.Do you have Uniform Bucket‑Level Access enabled on the bucket? The presence or absence of this setting can affect how public IAM bindings are evaluated.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.