DataService 07 of 139 controls
Amazon S3 security hardening
Harden Amazon S3: organization-wide Block Public Access, ACLs disabled, TLS-only bucket policies, SSE-KMS with bucket keys, versioning and Object Lock.
On this page
Amazon S3 stores most of the data in a typical AWS estate, which is why it shows up in so many breach reports. The classic pattern is a bucket readable by anyone, found by someone scanning for exactly that. The more recent patterns use stolen credentials instead: in the 2019 Capital One breach, an SSRF flaw yielded role credentials that were used to list and copy S3 buckets; in 2024, Unit 42 described an extortion campaign that harvested access keys from exposed .env files, exfiltrated S3 data and deleted it; and in early 2025 the "Codefinger" campaign used compromised keys to re-encrypt objects with SSE-C so only the attacker held the key. AWS has closed many doors by default since 2023, but defaults only apply to new resources, old buckets keep their old settings, and one PutBucketPolicy with "Principal": "*" can still undo everything if nothing stops it. This page builds the baseline in layers: public access blocked for the whole organization, ACLs gone, bucket policies that enforce TLS and a data perimeter, encryption with keys you control, and versioning plus Object Lock so a compromised credential cannot destroy your data.
Baseline controls
- 0101Block Public Access on for the organization
Stops a single bucket policy or ACL from exposing data to the internet.
How to check:aws s3control get-public-access-block --account-id 111122223333Mapping: S3.1, S3.8, CIS 3.1.4 - 0202ACLs disabled (bucket owner enforced)
Removes a legacy, hard-to-audit access path that can grant any AWS account access.
How to check:aws s3api get-bucket-ownership-controls --bucket app-data-prodMapping: S3.12 - 0303Bucket policies deny requests without TLS
Prevents credentials and data from crossing the network in clear text.
How to check:aws s3api get-bucket-policy --bucket app-data-prodMapping: S3.5, CIS 3.1.1 - 0404Access restricted to your organization
A mistaken cross-account grant cannot reach the data when a perimeter deny wins.
How to check:aws s3api get-bucket-policy-status --bucket app-data-prod - 0505SSE-KMS with a customer managed key on sensitive buckets
Adds a second authorization layer (kms:Decrypt) and a CloudTrail record for reads.
How to check:aws s3api get-bucket-encryption --bucket app-data-prodMapping: S3.17, CIS 3.1.5 - 0606SSE-C blocked
Stops stolen credentials from re-encrypting objects with a key only the attacker holds.
How to check:aws s3api get-bucket-encryption --bucket app-data-prod - 0707Versioning enabled on every data bucket
Overwrites and deletes keep the previous version, so a bad write is recoverable.
How to check:aws s3api get-bucket-versioning --bucket app-data-prodMapping: S3.14, S3.20, CIS 3.1.2 - 0808Object Lock on backup and log buckets
Makes recovery data immutable, even for the root user, in compliance mode.
How to check:aws s3api get-object-lock-configuration --bucket log-archive-111122223333Mapping: S3.15 - 0909Object-level data events logged in CloudTrail
Without data events you cannot tell which objects an attacker read or deleted.
How to check:aws cloudtrail get-event-selectors --trail-name org-trailMapping: S3.22, S3.23, CIS 4.8, CIS 4.9
What AWS already does by default
Know the current defaults so you spend effort on the gaps:
- Encryption at rest: since January 2023, every new object is encrypted with SSE-S3 at no cost, even if you configure nothing.
- Block Public Access and ACLs: since April 2023, new buckets have all four Block Public Access settings on and Object Ownership set to bucket owner enforced (ACLs disabled).
- SSE-C: since April 2026, new general purpose buckets reject uploads that use server-side encryption with customer-provided keys. AWS also disabled it on existing buckets in accounts that had no SSE-C objects.
Buckets created before these dates may not have these settings. The rest of this page assumes you need to fix an estate with history.
Block Public Access at every level
Block Public Access (BPA) has four settings:
BlockPublicAcls: reject new public ACLs.IgnorePublicAcls: ignore existing public ACLs.BlockPublicPolicy: reject bucket and access point policies that grant public access.RestrictPublicBuckets: limit access to buckets with public policies to AWS service principals and the bucket owner's account.
S3 evaluates organization, account and bucket settings and applies the most restrictive combination.
Organization level
Since November 2025, AWS Organizations has an S3 policy type that enforces BPA across accounts. Member accounts cannot loosen it, which previously required an SCP denying s3:PutAccountPublicAccessBlock. From the management account:
aws organizations enable-policy-type \
--root-id r-examplerootid111 \
--policy-type S3_POLICY
aws organizations create-policy \
--name s3-block-public-access \
--type S3_POLICY \
--description "Block all S3 public access" \
--content '{
"s3_attributes": {
"public_access_block_configuration": { "@@assign": "all" }
}
}'
aws organizations attach-policy \
--policy-id p-examplepolicyid \
--target-id r-examplerootid111
Before you attach it at the root, find the accounts that legitimately serve public content from S3 (static websites, public datasets). Prefer serving those through CloudFront with origin access control, which keeps the bucket private. If an exception is unavoidable, attach the policy to OUs instead of the root and keep the exception account in its own OU. The Organizations page covers OU design and policy inheritance.
Account level
If you cannot use the organization policy yet, set BPA on every account (S3.1):
aws s3control put-public-access-block \
--account-id 111122223333 \
--public-access-block-configuration \
BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
Then protect it with an SCP that denies s3:PutAccountPublicAccessBlock to everyone except your platform role.
Bucket level
Keep bucket-level BPA on as well (S3.8). It costs nothing and protects the bucket if it is ever moved under a looser account configuration. Access points have their own BPA settings (S3.19); leave them on unless the access point exists to serve public content.
Verify
aws s3control get-public-access-block --account-id 111122223333
aws s3api get-public-access-block --bucket app-data-prod
aws s3api get-bucket-policy-status --bucket app-data-prod
get-bucket-policy-status returns IsPublic: true when S3 considers the bucket policy public. AWS Config rules s3-account-level-public-access-blocks-periodic and s3-bucket-level-public-access-prohibited give you the same answer continuously.
Disable ACLs
ACLs are a legacy access mechanism that predates IAM. They are hard to audit and easy to get wrong, notably the AuthenticatedUsers group, which means any AWS account, not just yours. Set Object Ownership to bucket owner enforced on every bucket (S3.12):
aws s3api put-bucket-ownership-controls \
--bucket app-data-prod \
--ownership-controls 'Rules=[{ObjectOwnership=BucketOwnerEnforced}]'
With ACLs disabled, the bucket owner owns every object and access is controlled only by policies. Before switching, check that no application still writes with ACL headers other than bucket-owner-full-control; S3 server access logs or CloudTrail data events will show them. Console: S3 > bucket > Permissions > Object Ownership.
Bucket policies that enforce your rules
A good bucket policy does three things: it requires TLS, it restricts access to your organization, and it enforces your encryption choice. The full example:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyInsecureTransport",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::app-data-prod",
"arn:aws:s3:::app-data-prod/*"
],
"Condition": { "Bool": { "aws:SecureTransport": "false" } }
},
{
"Sid": "DenyOldTLS",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::app-data-prod",
"arn:aws:s3:::app-data-prod/*"
],
"Condition": { "NumericLessThan": { "s3:TlsVersion": "1.2" } }
},
{
"Sid": "DenyOutsideOrganization",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::app-data-prod",
"arn:aws:s3:::app-data-prod/*"
],
"Condition": {
"StringNotEqualsIfExists": { "aws:PrincipalOrgID": "o-exampleorgid" },
"BoolIfExists": { "aws:PrincipalIsAWSService": "false" }
}
},
{
"Sid": "DenyWrongKey",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::app-data-prod/*",
"Condition": {
"StringNotEqualsIfExists": {
"s3:x-amz-server-side-encryption-aws-kms-key-id": "arn:aws:kms:eu-west-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
}
}
}
]
}
Apply it with aws s3api put-bucket-policy --bucket app-data-prod --policy file://policy.json.
Require TLS
DenyInsecureTransport is exactly what control S3.5 (CIS 3.1.1) looks for. DenyOldTLS goes further and rejects TLS 1.0 and 1.1 clients. Test both with old SDKs or appliances first; a legacy backup agent is the usual casualty. AWS Config rule s3-bucket-ssl-requests-only checks the first statement on every bucket.
Restrict access to your organization
DenyOutsideOrganization is a data perimeter statement: even if someone grants a cross-account principal access by mistake, or an attacker adds their own account to a bucket policy as a backdoor, the deny wins. The aws:PrincipalIsAWSService clause keeps service principals such as CloudTrail or S3 replication working. Writing this statement on every bucket does not scale, which is what resource control policies (RCPs) solve: one RCP at the root applies the same deny to every bucket in every member account. The RCP version lives on the Organizations page.
DenyWrongKey works together with default encryption: requests that omit encryption headers get the bucket default, requests that ask for a different key are denied. This matters because an attacker with write access can otherwise encrypt new objects with a KMS key in their own account.
Access points for shared buckets
When many applications share a large bucket, the bucket policy turns into a long list of exceptions. S3 access points give each consumer its own endpoint with its own policy, and you can restrict an access point to a VPC so it is unreachable from the internet. Delegate access control to access points owned by your account from the bucket policy:
{
"Effect": "Allow",
"Principal": { "AWS": "*" },
"Action": "*",
"Resource": [
"arn:aws:s3:::shared-datalake",
"arn:aws:s3:::shared-datalake/*"
],
"Condition": {
"StringEquals": { "s3:DataAccessPointAccount": "111122223333" }
}
}
Combine this with a VPC endpoint policy (see the VPC page) so data can only flow through paths you designed.
Encryption with keys you control
SSE-S3 protects against someone walking off with a disk. It does not add an authorization layer: anyone with s3:GetObject can read the object. SSE-KMS does, because reading also requires kms:Decrypt on the key, and every decrypt is logged in CloudTrail.
Encrypt with SSE-KMS and bucket keys
Use SSE-KMS with a customer managed key for buckets that hold sensitive data (S3.17):
aws s3api put-bucket-encryption \
--bucket app-data-prod \
--server-side-encryption-configuration '{
"Rules": [{
"ApplyServerSideEncryptionByDefault": {
"SSEAlgorithm": "aws:kms",
"KMSMasterKeyID": "arn:aws:kms:eu-west-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
},
"BucketKeyEnabled": true,
"BlockedEncryptionTypes": { "EncryptionType": ["SSE-C"] }
}]
}'
BucketKeyEnabled makes S3 use a bucket-level data key derived from your KMS key, which sharply reduces the number of KMS requests and their cost. The trade-off is that CloudTrail shows KMS events at the bucket level rather than per object, and the encryption context becomes the bucket ARN. Use a customer managed key, not the AWS managed aws/s3 key, so you control the key policy and can share or revoke access. Key policy design is on the KMS page.
Changing default encryption does not re-encrypt existing objects. Use S3 Batch Operations with a copy job to re-encrypt in place if you need to.
Block SSE-C
Attackers with stolen credentials have abused SSE-C to rewrite objects encrypted with a key that only they hold, then demanded a ransom for it. The BlockedEncryptionTypes element in the command above rejects SSE-C uploads on the bucket. Keep it blocked unless you have a real, documented need, and treat any PutObject with SSE-C headers on a bucket that never used them as an incident.
Protect data from destruction
Exposure is one risk; destruction is the other. A ransomware actor with write access can overwrite or delete every object, or set a lifecycle rule that expires everything overnight.
Versioning and MFA delete
Turn on versioning so overwrites and deletes keep the previous version (S3.14):
aws s3api put-bucket-versioning \
--bucket app-data-prod \
--versioning-configuration Status=Enabled
Add lifecycle rules to expire noncurrent versions after a period that fits your recovery objectives (S3.10), or storage costs will grow.
MFA delete (S3.20, CIS 3.1.2) requires an MFA code to permanently delete a version or change versioning state. Only the root user can enable it, through the CLI or API with the root MFA device, which makes it awkward at scale. Many teams satisfy the intent with Object Lock and SCPs that deny s3:PutBucketVersioning and s3:PutLifecycleConfiguration outside a platform role, and document the exception.
Object Lock for backups and logs
Object Lock makes object versions immutable for a retention period (S3.15). In compliance mode, nobody can delete a locked version or shorten its retention, including the root user. In governance mode, principals with s3:BypassGovernanceRetention can. Use compliance mode for backups, audit logs and anything you would need after a compromise:
aws s3api put-object-lock-configuration \
--bucket log-archive-111122223333 \
--object-lock-configuration '{
"ObjectLockEnabled": "Enabled",
"Rule": { "DefaultRetention": { "Mode": "COMPLIANCE", "Days": 365 } }
}'
Test retention on a small bucket first: compliance mode cannot be undone, and objects stay billable until retention expires. The CloudTrail page applies Object Lock to the log archive bucket.
Replicate critical buckets to another account with S3 Replication. A separate account with its own credentials is the strongest protection against an attacker who owns the source account.
Continuous review with IAM Access Analyzer
Settings drift. IAM Access Analyzer reports buckets shared outside your zone of trust (your organization or account), including access granted through bucket policies, ACLs and access points. Create an organization analyzer in the security account and review its S3 findings:
aws accessanalyzer list-findings-v2 \
--analyzer-arn arn:aws:access-analyzer:eu-west-1:111122223333:analyzer/org-analyzer \
--filter '{"resourceType": {"eq": ["AWS::S3::Bucket"]}, "status": {"eq": ["ACTIVE"]}}'
Archive findings only for documented, intentional sharing. Setting up the analyzer is covered on the IAM page, and Security Hub CSPM evaluates S3.1, S3.5, S3.8 and the rest of the S3 controls continuously, see the Security Hub page.
Logging and detection
CloudTrail data events for S3
Management events record bucket configuration changes, but not who read or deleted which object. Object-level reads and writes are data events (S3.22 for writes, S3.23 for reads, CIS 4.8 and 4.9). Logging every object in every bucket is expensive, so scope it with advanced event selectors to buckets that hold sensitive data:
aws cloudtrail put-event-selectors \
--trail-name org-trail \
--advanced-event-selectors '[{
"Name": "S3 data events, sensitive buckets",
"FieldSelectors": [
{ "Field": "eventCategory", "Equals": ["Data"] },
{ "Field": "resources.type", "Equals": ["AWS::S3::Object"] },
{ "Field": "resources.ARN", "StartsWith": ["arn:aws:s3:::app-data-prod/"] }
]
}]'
S3 server access logs are a cheaper complement (S3.9) and capture some requests CloudTrail does not, such as anonymous requests that fail authentication. Send them to a dedicated logging bucket, never to the bucket being logged.
What to alert on
Route these management events to your alerting with an EventBridge rule:
{
"source": ["aws.s3"],
"detail-type": ["AWS API Call via CloudTrail"],
"detail": {
"eventName": [
"PutBucketPolicy",
"DeleteBucketPolicy",
"PutBucketAcl",
"PutBucketPublicAccessBlock",
"DeleteBucketPublicAccessBlock",
"PutBucketEncryption",
"PutBucketLifecycle",
"PutBucketVersioning"
]
}
}
PutBucketLifecycle is the CloudTrail event name behind lifecycle configuration changes; a sudden expiration rule on a production bucket is a known destruction technique. In the data events, watch for bursts of DeleteObject or DeleteObjects, and PutObject requests carrying SSE-C headers.
GuardDuty S3 Protection analyzes S3 data events without you paying for a CloudTrail trail of them. Finding types to route with high priority include Exfiltration:S3/AnomalousBehavior, Impact:S3/AnomalousBehavior.Delete, Policy:S3/BucketBlockPublicAccessDisabled, Policy:S3/BucketAnonymousAccessGranted and Stealth:S3/ServerAccessLoggingDisabled. Enable it organization-wide as described on the GuardDuty page.
Common mistakes
- Trusting the 2023 defaults for old buckets. The default BPA and ACL settings apply only to buckets created after April 2023. Audit the whole inventory, not just what your pipelines create today.
- Allowing the public website exception at the root. One account that serves a static site should not keep BPA off for the organization. Use CloudFront with origin access control, or isolate that account in its own OU.
- Using
aws/s3for sensitive data. The AWS managed key cannot be restricted or shared on your terms. Anyone with S3 read access in the account can decrypt, so the second authorization layer you expected does not exist. - Versioning without lifecycle rules. Noncurrent versions accumulate silently, and teams then turn versioning off to save money. Expire noncurrent versions on a schedule instead.
- Object Lock in governance mode for ransomware protection. Governance mode can be bypassed by anyone with
s3:BypassGovernanceRetention, which a compromised admin role usually has. Use compliance mode for backups that must survive an account takeover. - Forgetting the perimeter on service-to-service paths. A
DenyOutsideOrganizationstatement without theaws:PrincipalIsAWSServiceexception breaks CloudTrail delivery, replication and logging, and teams then remove the statement entirely. - No data events anywhere. Without object-level logs, the incident response question "what did they take?" has no answer. Log at least the buckets that hold regulated or customer data.
References
- Blocking public access to your Amazon S3 storage
- Amazon S3 policies in AWS Organizations
- Controlling ownership of objects and disabling ACLs
- Blocking or unblocking SSE-C for a general purpose bucket
- Reducing the cost of SSE-KMS with Amazon S3 Bucket Keys
- Security Hub CSPM controls for Amazon S3
- AWS Security Blog: How to use bucket policies and apply defense-in-depth to help secure your Amazon S3 data
- Data perimeters on AWS
- Halcyon: Abusing AWS native services, ransomware encrypting S3 buckets with SSE-C
- Unit 42: Large-scale cloud extortion operation
- US Department of Justice: Capital One intrusion conviction
- Stratus Red Team: Backdoor an S3 bucket via its bucket policy
- Prowler: open-source AWS security assessment
- CIS Amazon Web Services Benchmarks
Written by
Florian AmetteSecurity engineer writing practical, benchmark-aligned hardening baselines for AWS services, from the organization and identities to data, networks and workloads.