Cybermatic.aiAll guides →

The Cybermatic Signal · Fix-it Guides · Cloud · Google Cloud

How to remove public access from a Google Cloud Storage bucket

← All guides · Time to fix: 5 minutes per bucket; 15 minutes once to apply the org-level · Google Cloud

A Google Cloud Storage bucket becomes publicly readable the moment allUsers or allAuthenticatedUsers appears in its IAM policy — anyone on the internet can list and download every object inside it. This affects any team that has ever clicked 'Make public' during testing or inherited a bucket from a previous admin. Locking it down takes about five minutes per bucket.

The fix, verified

Public Cloud Storage bucket

Severitycritical · Google Cloud
Where to clickGoogle Cloud console → Cloud Storage → Buckets → the bucket → Permissions → remove allUsers and allAuthenticatedUsers → Public access prevention: Enforced.
Or run
gcloud storage buckets update gs://BUCKET-NAME --public-access-prevention
Maps toCIS GCP 5.1SOC2 CC6.1

What this setting controls and what goes wrong when it is open

Every GCS bucket has an IAM policy that controls who can read, write, or list its contents. Two special principals — allUsers (literally everyone, including unauthenticated visitors) and allAuthenticatedUsers (anyone with any Google account) — bypass normal access controls entirely. When either principal holds the Storage Object Viewer or Storage Object Admin role, the bucket is effectively a public website whether you intended it or not.

Bucket names follow predictable patterns: company name, environment, year, region. Automated scanners probe these combinations continuously. A realistic scenario: a developer creates a staging bucket named acme-exports-2023, grants allUsers read access to share a file with a contractor, and forgets to revert it. Weeks later, that bucket contains a nightly export of customer records that anyone who guesses the name can download in full.

Check whether you are affected

The fastest way to audit all buckets in a project is with the gcloud CLI. Run the command below for each bucket you want to inspect, or pipe it through a script across all buckets in the project. In the console, a red 'Public' badge appears next to any bucket that has allUsers or allAuthenticatedUsers in its policy.

You can also open Cloud Storage → Buckets in the Google Cloud console. The 'Public access' column shows 'Public to internet', 'Subject to object ACLs', or 'Not public'. Any bucket showing 'Public to internet' needs immediate attention.

How to fix it

There are two steps: remove the offending principals from the bucket's IAM policy, then enforce public access prevention so the setting cannot be re-enabled accidentally.

Using the console: Google Cloud console → Cloud Storage → Buckets → select the bucket → Permissions tab → find any row showing allUsers or allAuthenticatedUsers → click the trash icon to remove it → then in the same Permissions tab locate Public access prevention and set it to Enforced.

Using the CLI, run the command below, replacing BUCKET-NAME with your actual bucket name:

gcloud storage buckets update gs://BUCKET-NAME --public-access-prevention

This single command sets public access prevention to enforced at the bucket level. It does not automatically remove existing allUsers bindings already in the policy, so if you have already added those principals, remove them through the console Permissions tab or with a separate gcloud projects remove-iam-policy-binding command before or after running this update.

What might break and how to handle it

If the bucket is intentionally serving public static assets — a website, downloadable software, public datasets — removing allUsers will take those assets offline for unauthenticated visitors. Before making the change, confirm with the bucket owner what the bucket is actually used for. If public hosting is genuinely required, the right path is to front the bucket with a Cloud CDN or Cloud Load Balancing endpoint that you control, rather than leaving the raw bucket open. For any bucket that should not be public, there is no legitimate reason to keep allUsers or allAuthenticatedUsers in the policy.

How to keep it fixed

Apply public access prevention at the organization or project level using an Organization Policy. The constraint is constraints/storage.publicAccessPrevention. Setting it to Enforced at the organization node means no bucket created anywhere in your Google Cloud organization can be made public, regardless of what an individual developer does in the console. This is the most reliable long-term control.

If you use infrastructure-as-code (Terraform, Deployment Manager), add public_access_prevention = 'enforced' to every google_storage_bucket resource block so the setting is version-controlled and applied consistently on every deployment. Schedule a quarterly review of the Public access column in the console, or set up a Security Command Center finding alert for the PUBLIC_BUCKET_ACL detector, which fires automatically when a bucket becomes public.

Questions people ask

Does setting public access prevention remove existing allUsers bindings automatically?

No. The public access prevention flag blocks future attempts to add public principals, but it does not strip bindings that are already in the policy. You need to remove allUsers and allAuthenticatedUsers from the Permissions tab separately, then enforce the prevention setting.

Will this break a static website hosted on Cloud Storage?

Yes, if the site relies on allUsers having Storage Object Viewer access. Unauthenticated visitors will get 403 errors. The standard fix is to serve the content through Cloud Load Balancing with a backend bucket, which keeps the bucket private while still allowing public HTTP access through the load balancer.

How do I check all buckets in a project at once instead of one at a time?

In the console, the Public access column on the Buckets list page shows the status of every bucket at a glance. From the CLI, you can run gcloud storage buckets list --format='value(name,iamConfiguration.publicAccessPrevention)' to get a quick report across all buckets in the active project.

Is this open in your environment?

Cybermatic checks for "Public Cloud Storage bucket" automatically — on every connected account, every day — and shows you the exact fix above next to each one it finds. The free scan takes about ten minutes and needs no credit card.

Run the free scan All guides →

Part of The Cybermatic Signal. Written by the Cybermatic editorial agent from the configuration check Cybermatic runs for this setting (ID gcp-public-gcs) and reviewed before publication. The click path, command and caution in the fix card are the vendor's documented procedure as of 2026-11-12. Found an error? Write to info@cybermatic.ai.

BriefingIssuesFlashGuidesInsurance checkDomain checkSubscribe

Cybermatic.ai by Ironhawk Group · 9330 Lyndon B Johnson Fwy, Suite 900 · Dallas, TX 75243 · Privacy · cybermatic.ai