AI QA Monkey
AI Security Intelligence
Fix Guide

Cloud Storage Exposure: Securing Public S3, Azure Blob & GCS Buckets

Public cloud storage is behind a remarkable share of the largest data leaks of the past decade — and almost none of them involved a broken system. The storage worked exactly as configured. Somebody simply configured it to be readable by everyone, usually while trying to make an image load.

What This Finding Means — and What It Doesn't

Our scanner reports cloud storage exposure when it finds references to AWS S3, Azure Blob Storage or Google Cloud Storage in your pages and scripts. It is worth being precise about what that is and is not:

  • What we detect: that your site references cloud storage, and where. This maps a part of your attack surface that is easy to lose track of.
  • What we do not do: attempt to enumerate or download your objects. Testing another party's bucket permissions without authorization is not something a scanner should do on your behalf.

So treat this finding as an inventory item that deserves a two-minute check, not a declaration that you are leaking. The check itself is the subject of this guide, and it is worth doing properly, because the difference between "a bucket serving our logo" and "a bucket serving our logo and eleven years of customer invoices" is invisible from the outside.

Nearly every major bucket leak follows the same shape: storage created for one harmless purpose, quietly reused for something sensitive, with the original permissions still attached.

Why Buckets Leak So Reliably

Understanding the failure pattern makes the fix obvious, and it is remarkably consistent:

  1. A file will not load, so permissions get widened. An image 403s during a deploy. Under time pressure, someone flips the bucket to public, the image appears, and the ticket closes. The setting is permanent; the urgency was not.
  2. The bucket gets reused. Six months later it is the obvious place for user uploads, generated PDFs, a database export, or a nightly backup. Nobody re-examines a permission decision made for a logo.
  3. Listing was never disabled. This is the multiplier. Without listing, an attacker must guess exact filenames. With it, they request an index and receive one.
  4. Discovery is automated. Bucket names appear in page source, in DNS, in certificate transparency logs and in public repositories. Continuous scanners harvest and test them at internet scale, which is why "nobody knows our bucket name" has never been a control.
The distinction that matters most

Public read on assets meant to be read is fine — that is what a CDN origin is. Public list turns your storage into a browsable directory of everything you have. Public write is worse still: anyone can replace your JavaScript with theirs, which converts a storage misconfiguration into a supply-chain compromise of every visitor. Check all three separately.

Step 1: Audit What You Actually Expose

Start from the outside, with no credentials — that is precisely the position an attacker occupies.

Find every bucket your site references:

# Pull storage hostnames out of your own pages
curl -s https://yourdomain.com | grep -Eo "[a-z0-9.-]+\.(s3[.-][a-z0-9-]*\.?amazonaws\.com|blob\.core\.windows\.net|storage\.googleapis\.com)" | sort -u

# Repeat for your main JS bundle — references are often only in code
curl -s https://yourdomain.com/assets/app.js | grep -Eo "https://[a-z0-9.-]+\.(s3[^\"']*|blob\.core\.windows\.net[^\"']*|storage\.googleapis\.com[^\"']*)" | sort -u

Then add the buckets your backend uses that never appear in the front end — backups, exports, log archives, data-warehouse staging. In our experience these are the ones holding the sensitive material, precisely because nobody thinks of them as web-facing.

Test anonymous access on each one — the two questions that matter:

# 1. Can an anonymous user LIST the contents?  (the dangerous one)
curl -s "https://BUCKET.s3.amazonaws.com/?list-type=2" | head -40
curl -s "https://ACCOUNT.blob.core.windows.net/CONTAINER?restype=container&comp=list" | head -40
curl -s "https://storage.googleapis.com/storage/v1/b/BUCKET/o" | head -40

# A listing of your keys = exposure. "AccessDenied" = correct.

# 2. Can an anonymous user READ a specific private object?
curl -sI "https://BUCKET.s3.amazonaws.com/path/to/private-file.pdf"
# HTTP/1.1 200 OK       -> public, verify that is intended
# HTTP/1.1 403 Forbidden -> correct for private content

And verify from the inside, which catches buckets your site never references:

# AWS — every bucket's public access block, in one pass
for b in $(aws s3api list-buckets --query "Buckets[].Name" --output text); do
  echo "== $b"
  aws s3api get-public-access-block --bucket "$b" \
    --query "PublicAccessBlockConfiguration" 2>/dev/null || echo "  NO PUBLIC ACCESS BLOCK SET"
done

# Google Cloud — buckets readable by anyone
gsutil iam get gs://BUCKET | grep -E "allUsers|allAuthenticatedUsers"

# Azure — containers set to public
az storage container list --account-name ACCOUNT --query "[].{name:name, access:properties.publicAccess}" -o table
allAuthenticatedUsers is not "our team"

On Google Cloud, allAuthenticatedUsers means anyone holding any Google account — not members of your organization. It is effectively public with an extra click. The same trap exists on AWS as the legacy Any Authenticated AWS User grant. Both should be treated as public exposure.

Step 2: Decide What Is Genuinely Public

Before changing permissions, sort your objects — because fixing this by making everything private will break your site, and a broken site is how security changes get reverted.

  • Genuinely public: site images, logos, fonts, public documentation, marketing downloads. Anyone may read these; nobody should list or write them.
  • Private, always: user uploads, invoices, generated reports, data exports, database backups, log archives, anything with personal data. These should never be reachable without an authorization check.
  • The mixed bucket: the real source of leaks — public assets and private files sharing one container. Split it. Two buckets with clear, opposite policies are dramatically safer than one with carefully crafted per-object permissions that nobody will maintain correctly for years.

Fixing AWS S3

Start at the account level. This is the single highest-value control: it prevents any individual bucket mistake from exposing data, including mistakes made years from now by someone who has never read your policy.

# Block public access across the ENTIRE account
aws s3control put-public-access-block \
  --account-id 123456789012 \
  --public-access-block-configuration \
    BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true

# Or per bucket
aws s3api put-public-access-block --bucket MY-BUCKET \
  --public-access-block-configuration \
    BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true

Then re-enable narrowly where public reading is genuinely required — read only, on a specific prefix, with no listing:

{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "PublicReadAssetsOnly",
    "Effect": "Allow",
    "Principal": "*",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::MY-BUCKET/public-assets/*"
  }]
}

Note what is absent: no s3:ListBucket, so the container cannot be enumerated; no s3:PutObject, so nobody can write; and the resource is scoped to one prefix rather than the whole bucket. Additionally, enable S3 Block Public ACLs and prefer bucket policies over per-object ACLs — object ACLs are the mechanism behind most accidental exposure, which is why AWS now disables them by default on new buckets.

Two settings worth enabling while you are here: default encryption (SSE-S3 or SSE-KMS) and server access logging to a separate bucket, so you have an audit trail if you ever need to answer "what was accessed, and when?".

Fixing Azure Blob Storage

# Disallow public access at the STORAGE ACCOUNT level (the strong control)
az storage account update --name ACCOUNT --resource-group RG \
  --allow-blob-public-access false

# Or set a single container to private
az storage container set-permission \
  --name CONTAINER --account-name ACCOUNT --public-access off

Azure's access levels are worth knowing precisely, because the middle option is frequently chosen by mistake:

  • Private — no anonymous access. The correct default.
  • Blob — anonymous read of individual blobs, but no container listing. This is the right choice when assets must be public.
  • Container — anonymous read and full listing. This is the setting behind most Azure exposure findings, and it is rarely what anyone intended.

For private delivery, use a Shared Access Signature (SAS) with a short expiry and read-only permission, or a stored access policy so a leaked SAS can be revoked centrally without rotating account keys.

Fixing Google Cloud Storage

# Remove anonymous access
gsutil iam ch -d allUsers gs://MY-BUCKET
gsutil iam ch -d allAuthenticatedUsers gs://MY-BUCKET

# Enforce uniform bucket-level access (disables per-object ACLs — strongly recommended)
gsutil uniformbucketlevelaccess set on gs://MY-BUCKET

# Grant public READ only where genuinely required
gsutil iam ch allUsers:objectViewer gs://MY-PUBLIC-ASSETS

Enable uniform bucket-level access wherever possible. Per-object ACLs create exactly the situation that causes leaks: a bucket that looks private in the console while individual objects inside it are world-readable. Uniform access removes that entire class of surprise. For organization-wide protection, apply the Domain Restricted Sharing org policy, which blocks allUsers grants outright.

Serving Private Files: Signed URLs

The correct pattern for anything user-specific: the bucket stays private, and your backend issues a short-lived link only after it has verified the requester is entitled to the file.

// Node.js — AWS SDK v3
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";

app.get("/invoice/:id", requireSession, async (req, res) => {
  const invoice = await db.invoices.find(req.params.id);
  if (invoice.userId !== req.session.userId) return res.sendStatus(403);   // authorize FIRST

  const url = await getSignedUrl(
    new S3Client({}),
    new GetObjectCommand({ Bucket: "private-docs", Key: invoice.key }),
    { expiresIn: 300 }        // 5 minutes is plenty for a download
  );
  res.redirect(url);
});
<?php
// PHP — AWS SDK
$cmd = $s3->getCommand('GetObject', ['Bucket' => 'private-docs', 'Key' => $key]);
$request = $s3->createPresignedRequest($cmd, '+5 minutes');
header('Location: ' . (string) $request->getUri());

Three rules that decide whether this pattern is actually secure:

  1. Authorize before you sign. A signed URL proves nothing about who asked for it. If your endpoint signs whatever key it is handed, you have built an open proxy to your private storage — a direct object reference vulnerability with extra steps.
  2. Keep expiry short. Minutes, not days. A signed URL is a bearer credential: anyone holding it has access, and long-lived ones end up in browser history, referrer headers, chat logs and support tickets.
  3. Never sign a user-supplied path. Derive the object key from your database using an identifier you control, never from a query parameter the client sends.

Serving Public Files: CDN in Front, Bucket Private

Even for genuinely public assets, exposing the bucket directly is the weaker design. The better pattern keeps the storage private and grants read access to one identity: your CDN.

  • AWS — CloudFront with Origin Access Control; the bucket policy permits only that distribution.
  • Azure — Azure CDN or Front Door with a private origin and managed identity.
  • Google Cloud — Cloud CDN with a backend bucket and signed URLs or IAM-scoped access.

The benefits compound: the bucket is never directly reachable regardless of any future permission mistake, you gain caching and lower egress costs, you can attach a WAF and rate limiting, and access logs run through one place. You also stop leaking your storage topology — bucket names, regions and account identifiers — in your page source.

If Data Was Already Exposed

Closing the bucket stops future access. It tells you nothing about the past, and the past is what determines your obligations.

  1. Determine the exposure window. When did the permission change, and when did you close it? CloudTrail, Azure Activity Log and GCP Audit Logs record the configuration change itself.
  2. Review access logs for anonymous reads. S3 server access logs or CloudTrail data events, Azure Storage Analytics, GCP data access logs. You are looking for requests without an authenticated principal, especially bulk or sequential key access.
  3. Inventory what was reachable. Not what the bucket holds today — what it held during the window. This is the question a regulator or customer will ask, and reconstructing it later is far harder than capturing it now.
  4. Rotate any credentials that were stored there. Config files, service-account JSON keys, database dumps containing connection strings. Treat everything in the exposed set as compromised — our credential rotation guide covers the mechanics per provider.
  5. Assess notification duties. If personal data was reachable, GDPR and comparable regimes impose tight notification deadlines that begin when you become aware, not when you finish investigating. Our incident response template and GDPR technical controls guide outline the process.
Prevent the recurrence, not just this instance

Turn the fix into a guardrail: enable account-level public access blocks, add an infrastructure-as-code policy check (tfsec, checkov, AWS Config rules, Azure Policy, GCP Org Policy) that fails a build attempting to create a public bucket, and schedule an external scan so a change made outside your pipeline is still caught from the outside.

See Which Cloud Storage Your Site Exposes

Free scan — maps the S3, Azure Blob and Google Cloud Storage references in your pages and scripts, alongside 100+ other checks, in about 60 seconds.

Scan Your Site Now

Frequently Asked Questions

Is a public bucket always a security problem?

No. Buckets serving site images, fonts or public downloads are meant to be readable. The problems are public write (anyone can replace your files), public list (anyone gets a complete index), and private data sitting in a bucket that was only ever meant for public assets. The question is not whether the bucket is public, but whether every object inside it is intended to be.

Why is bucket listing worse than a single public file?

A single public object is only exposed to someone who already knows its exact address. Listing removes that requirement: an anonymous visitor enumerates every key and downloads the interesting ones. Disable listing even on buckets whose contents are genuinely public.

What is a signed URL and when should I use one?

A temporary link your backend generates on demand, carrying a signature and an expiry. The bucket stays private; only an already-authorized user receives a working link, and only briefly. Use them for anything user-specific — invoices, uploads, exports, private media — with expiry in minutes.

Does an unguessable bucket name protect me?

No. Bucket names appear in page source, DNS, certificate transparency logs and public repositories, and scanners harvest them continuously. Obscurity delays discovery at best. Access controls determine safety.

We use a CDN — is the bucket still exposed?

Frequently, yes. Putting a CDN in front does not automatically close direct access to the origin, so the bucket URL often still works and bypasses your WAF, caching and logging entirely. Restrict the bucket so only the CDN identity can read it, then verify the direct URL returns 403.

Check Your Website Right Now

Run a free automated security scan — 100 checks in 60 seconds. No signup required.

Run Free Security Scan →