Tarek Cheikh
Founder & AWS Cloud Architect
Amazon S3 is the backbone of data storage in the cloud. Organizations store everything in S3: application assets, database backups, log files, analytics data, and increasingly sensitive information like customer records, financial documents, and healthcare data. This ubiquity makes S3 the single most targeted AWS service by attackers and the most common source of cloud data breaches.
The pattern is depressingly familiar. A company misconfigures a bucket policy, disables Block Public Access for a quick test and forgets to re-enable it, or grants overly broad access to a third-party integration. The result: terabytes of sensitive data exposed to the open internet. High-profile S3 breaches have impacted government agencies, Fortune 500 companies, and startups alike. The common thread is not sophisticated attacks but basic misconfigurations that could have been prevented with the right controls.
This guide walks through every layer of S3 security, from account-level settings to individual object controls, giving you a comprehensive defense against data leaks.
S3 Block Public Access is the most important single control in S3 security. It provides four independent settings that prevent public access regardless of individual bucket policies or ACLs.
Enable all four Block Public Access settings at the account level:
Enable these at the account level using the AWS CLI:
aws s3control put-public-access-block --account-id YOUR_ACCOUNT_ID --public-access-block-configuration '{"BlockPublicAcls":true,"IgnorePublicAcls":true,"BlockPublicPolicy":true,"RestrictPublicBuckets":true}'
Once enabled at the account level, no bucket in the account can be made public unless an administrator explicitly removes this protection. For the rare cases where a bucket must be public (such as a static website hosting bucket), use a separate AWS account dedicated to public-facing content, and apply Block Public Access to all other accounts.
If you use AWS Organizations, create a Service Control Policy (SCP) that prevents anyone from removing Block Public Access settings. This ensures that even account administrators cannot accidentally or intentionally expose buckets.
Bucket policies are JSON documents that define who can access a bucket and what operations they can perform. They provide fine-grained control that complements IAM policies.
aws:SourceVpc to limit access to a specific VPC, aws:SourceIp for IP-based restrictions, and aws:PrincipalOrgID to restrict access to your AWS Organization.aws:SecureTransport is false. This prevents data from being transmitted in plaintext.x-amz-server-side-encryption header or specifying the wrong encryption type.AWS now recommends disabling ACLs entirely on new buckets and migrating away from ACLs on existing buckets. When you create a bucket with the BucketOwnerEnforced object ownership setting, ACLs are disabled and the bucket owner automatically owns all objects. This eliminates an entire category of misconfiguration.
Audit your existing buckets and migrate to the BucketOwnerEnforced setting wherever possible. Use bucket policies for all access control.
Encryption at rest protects your data if the underlying storage media is compromised and satisfies compliance requirements across every major framework.
Use SSE-KMS with a customer-managed key for sensitive data. The CloudTrail integration provides a complete audit trail of every encryption and decryption operation, and key policies give you explicit control over who can access the data. Use the S3 Security Scanner tool to audit encryption configuration across all your buckets.
You cannot detect unauthorized access if you are not recording access in the first place. S3 provides multiple logging mechanisms, and you should enable all of them for sensitive buckets.
Object Lock and versioning protect against data deletion, whether accidental or malicious (such as ransomware).
By default, traffic from your VPC to S3 travels over the public internet (even though it stays within AWS's network). VPC endpoints provide a private connection from your VPC to S3 that never traverses the public internet.
Combine VPC endpoints with bucket policies that restrict access to traffic originating from specific VPCs or endpoints. Add a deny statement with the condition "StringNotEquals": {"aws:sourceVpce": "vpce-xxxxxxxxx"} to ensure the bucket is only accessible through your VPC endpoint. This effectively creates a private bucket that cannot be accessed from the internet even if other controls fail.
Amazon Macie is a data security service that uses machine learning and pattern matching to discover and protect sensitive data in S3.
Macie is particularly valuable for organizations subject to compliance requirements (HIPAA, GDPR, PCI DSS) that mandate data classification. It is also useful during cloud migrations, when data from on-premises systems is moved to S3 and may contain unexpectedly sensitive content.
Enable Macie on at least your most sensitive buckets. Use the findings to classify data, apply appropriate encryption and access controls, and build a data inventory for compliance reporting.
S3 security is a layered discipline. No single control is sufficient; defense in depth is required. Start with Block Public Access at the account level to prevent the most common misconfiguration. Layer on bucket policies with encryption and HTTPS requirements. Enable comprehensive logging so you can detect unauthorized access. Add Object Lock and versioning to protect against data loss. Use VPC endpoints to keep traffic private, and deploy Macie to discover sensitive data you may not know about.
The most secure S3 configuration is one that assumes mistakes will happen and builds guardrails to prevent those mistakes from becoming breaches. Account-level Block Public Access, SCPs preventing its removal, and bucket policies restricting access to specific VPCs create multiple independent layers that an attacker would need to bypass simultaneously.
If you are concerned about the security of your S3 environment, our AWS security consulting services include a comprehensive S3 security assessment. We audit every bucket in your account, identify misconfigurations, and implement the controls described in this guide. Protecting your data in S3 is one of the most impactful things you can do for your organization's security posture.
This article is just the start. Get the full picture with our free whitepaper - 8 chapters covering IAM, S3, VPC, monitoring, agentic AI security, compliance, and a prioritized action plan with 50+ CLI commands.
Stop sending your IAM policies, CloudTrail logs, and infrastructure code to third-party APIs. Run LLMs locally with Ollama on Apple Silicon — private, offline, fast. Complete setup guide with AWS security use cases.
We obtained the actual compromised litellm packages, set up a disposable EC2 instance with honeypot credentials and mitmproxy, and detonated the malware. Full evidence: fork bomb, credential theft in under 2 seconds, IMDS queries, AWS API calls, and C2 exfiltration.
A deep technical breakdown of how threat actor TeamPCP compromised Trivy, pivoted to LiteLLM, and turned a popular AI proxy into a credential-stealing weapon targeting AWS IMDS, Secrets Manager, and Kubernetes.