Secrets in Cloud Storage: How S3 Buckets and Blob Storage Leak Credentials at Scale
June 27, 2026
The Credential Risk Hidden Inside Your Object Storage
When engineers think about secret leakage, they picture a hardcoded API key committed to GitHub or a forgotten .env file pushed to a public repo. They rarely think about the 47 GB backup archive sitting in an S3 bucket — the one that contains application configs, database dumps, and a settings.json with a production Stripe key embedded three levels deep.
Cloud object storage — AWS S3, Azure Blob Storage, Google Cloud Storage — has become the de facto dumping ground for everything a team wants to persist cheaply. That convenience creates a surprisingly large attack surface for credential exposure, and most secret scanning pipelines never touch it.
How Secrets End Up in Buckets in the First Place
The paths are more varied than most teams expect:
- Application config backups. Automated backup jobs copy entire application directories — including
.envfiles,appsettings.json, and YAML configs — to S3 on a schedule. The backup job runs at 2 AM; nobody watches what it picks up. - Log archives. Application logs often contain bearer tokens, session cookies, and even API keys when a misconfigured logger captures outgoing HTTP headers. Those logs get compressed and shipped to cold storage, where they can sit for years.
- Database dumps. A developer triggers a one-off export for debugging, uploads it to a "temporary" prefix in the bucket, and never deletes it. Dumps can contain connection strings with embedded passwords, or OAuth tokens stored as user records.
- CI/CD artifact storage. Build pipelines that store intermediate artifacts or test reports in S3 sometimes capture environment variables — including secrets injected at build time — inside verbose output files.
- Infrastructure-as-code state and plans. Teams that don't use Terraform Cloud or a dedicated backend occasionally store
terraform.tfstateor plan output in S3. Those files are well-known to contain sensitive resource attributes. - Exported Jupyter notebooks. Data science teams push notebooks to shared buckets. Notebooks that query production databases or call external APIs frequently contain hardcoded credentials or tokens in executed cell output.
Why Bucket Misconfigurations Amplify the Risk
A secret buried in a private bucket is a contained problem. The same secret in a misconfigured bucket is a public breach. The two risks compound each other.
Common IAM misconfigurations that turn a secret-in-storage problem into an active exposure include:
- Overly permissive bucket policies that grant
s3:GetObjectto"Principal": "*"— intentionally, for a CDN use case — but cover prefixes that also contain sensitive files because nobody scoped the policy carefully. - Object ACLs set to public-read on individual files, often by accident when a developer uses
--acl public-readin a script and forgets to scope it. - Cross-account access roles with no condition keys. A role that grants a vendor read access to your bucket without an
aws:PrincipalOrgIDoraws:SourceAccountcondition is accessible to that vendor's entire account — including any compromised principal within it. - Disabled S3 Block Public Access settings at the account level, which allows any bucket or object in the account to be made public by any IAM principal that has the permission to do so.
How to Audit Your Buckets for Exposed Secrets: A Practical Checklist
-
Inventory what's actually in your buckets. Run
aws s3 ls s3://your-bucket/ --recursiveand filter for file extensions that commonly carry secrets:.env,.json,.yaml,.yml,.tfstate,.log,.gz,.sql,.ipynb. Pipe the output to a file and review it — most teams are surprised by what they find. -
Scan file contents, not just filenames. Download a representative sample of config files and run a pattern-based secret scanner against them locally. Look for high-entropy strings, known key prefixes (
AKIAfor AWS access keys,sk_live_for Stripe,ghp_for GitHub tokens), and common config key names likepassword,secret,token,api_key. -
Check public access settings immediately. In the AWS console, navigate to S3 → Block Public Access settings for this account. All four checkboxes should be enabled unless you have a documented reason. Also audit individual bucket policies with
aws s3api get-bucket-policy --bucket your-bucketand review for wildcard principals. -
Review bucket ACLs on sensitive prefixes. Use
aws s3api get-object-acl --bucket your-bucket --key path/to/sensitive-file.jsonto confirm object-level ACLs are not set topublic-read. -
Enable S3 server access logging or CloudTrail data events. If a secret has already been accessed, you need to know. S3 server access logs capture every
GetObjectrequest. CloudTrail data events give you the requesting IAM principal. Neither is enabled by default; both are essential for incident response. -
Enforce bucket lifecycle policies that delete unnecessary data. That "temporary" database dump from eight months ago is still there. A lifecycle rule that expires objects in a
tmp/prefix after 7 days is a simple, automatic fix. -
Use pre-signed URLs instead of public buckets for sharing. When developers need to share a file externally, pre-signed URLs with short expiry times (
aws s3 presign s3://bucket/file --expires-in 3600) avoid the need to open bucket access entirely.
The Azure and GCS Equivalents
The same problem exists outside AWS. On Azure Blob Storage, watch for containers with Public access level set to Blob or Container. Storage Account Shared Access Signature (SAS) tokens embedded in application configs stored inside Blob containers are a particularly insidious form of circular credential exposure — the secret that unlocks the storage is inside the storage.
On Google Cloud Storage, audit bucket IAM policies with gcloud storage buckets get-iam-policy gs://your-bucket and look for allUsers or allAuthenticatedUsers members on any role. Also check for legacy ACLs, which GCS still supports and which can override IAM policies in confusing ways.
What a Detected Credential in Blob Storage Means for SOC 2 and HIPAA
Under SOC 2 Trust Service Criteria, CC6.1 requires logical access controls, and CC6.7 covers the transmission and storage of confidential information. A plaintext credential sitting in a storage bucket accessible to parties beyond those with a legitimate need is a direct gap under both criteria — and auditors are increasingly asking about object storage access controls specifically.
For HIPAA, if the storage contains any Protected Health Information (PHI) adjacent data — say, a database dump that includes patient records alongside a connection string with the database password — the exposed credential becomes part of a potential breach notification analysis. The combination of PHI and an exposed access mechanism is the scenario HIPAA's Security Rule (45 CFR § 164.312) is designed to prevent.
Documenting your bucket access controls, lifecycle policies, and secret scanning coverage for cloud storage is not just good hygiene — it's evidence you'll want to have ready at your next audit.
Automate the Detection Before Auditors (or Attackers) Find It First
Manual audits of storage buckets are a point-in-time snapshot. New files land in buckets continuously — from backup jobs, logging pipelines, and developer uploads — which means a clean audit today doesn't guarantee a clean bucket next Tuesday. The right model is continuous scanning that covers not just your Git repositories but also the storage buckets, CI artifacts, and config exports where secrets quietly accumulate.
If you're not sure what's already exposed in your repos and connected infrastructure, run a free GhostCred scan to get a mapped, prioritized view of credential exposure in under 60 seconds — before someone else finds it first.
Key Takeaways
- Secrets reach cloud storage through backup jobs, log archives, database dumps, CI artifacts, and developer uploads — often without anyone noticing.
- A misconfigured bucket policy or public ACL turns a contained storage secret into a public breach.
- Audit file contents (not just filenames), block public access at the account level, enable access logging, and enforce lifecycle deletion policies for temporary data.
- Azure SAS tokens and GCS service account key files stored inside the buckets they grant access to are a specific, common risk pattern.
- SOC 2 and HIPAA auditors are increasingly examining object storage controls; documentation and continuous scanning are your best preparation.
See what's exposed in your own code.
Run a free scan