FIELD NOTE ยท TA-95 REGISTER

Plugging the Leaky Bucket

Five ways attackers expose, encrypt, or quietly siphon S3 data, plus the AWS controls that prevent and detect each path.

In March 2025, researchers found 108 GB of nurses’ records in an exposed S3 bucket used by ESHYFT. WebWork Tracker exposed millions of workplace screenshots through another open bucket.

Both incidents involved unintended reads. A stolen role can do more. It can read private objects, overwrite versions, delete recovery copies, or change replication so future objects leave the account.

AWS has enabled Block Public Access and disabled ACLs by default for new buckets since April 2023. Exposure usually means somebody changed a policy, weakened a guardrail, imported an old configuration, or lost credentials. One green console setting doesn’t settle the audit.

I look for five paths.

Start with a read-only account audit

Run these commands from a role that can inspect S3 configuration. They don’t modify resources.

ACCOUNT_ID=$(aws sts get-caller-identity \
  --query Account \
  --output text)

aws s3control get-public-access-block \
  --account-id "$ACCOUNT_ID"

aws s3api list-buckets \
  --query 'Buckets[].Name' \
  --output text

for bucket in $(aws s3api list-buckets \
  --query 'Buckets[].Name' \
  --output text); do
  printf '\n### %s\n' "$bucket"

  aws s3api get-bucket-policy-status \
    --bucket "$bucket" 2>/dev/null || true

  aws s3api get-public-access-block \
    --bucket "$bucket" 2>/dev/null || true

  aws s3api get-bucket-ownership-controls \
    --bucket "$bucket" 2>/dev/null || true

  aws s3api get-bucket-versioning \
    --bucket "$bucket" 2>/dev/null || true

done

The output is a starting inventory. It doesn’t prove the account is safe. A non-public bucket can still trust the wrong account, role, VPC endpoint, access point, or service principal.

Attack 1: public and unintended cross-account access

A public bucket is the obvious failure. A bucket policy can also trust the wrong AWS account, an access point can grant broader permissions, or an old access control list (ACL) can retain access nobody remembers.

An attacker doesn’t always need s3:ListBucket. If object names are predictable or leaked elsewhere, s3:GetObject can be enough to retrieve data directly. Public write access is worse because it allows tampering, malware hosting, and surprise storage or transfer charges.

Prevent it

Enable all four Block Public Access settings at the account level:

aws s3control put-public-access-block \
  --account-id "$ACCOUNT_ID" \
  --public-access-block-configuration \
'BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true'

For most organizations, enforce the setting centrally with an AWS Organizations S3 policy. Put approved public workloads in an explicit exception account or organizational unit instead of weakening the baseline everywhere.

Disable ACLs on ordinary buckets:

aws s3api put-bucket-ownership-controls \
  --bucket example-bucket \
  --ownership-controls \
'Rules=[{ObjectOwnership=BucketOwnerEnforced}]'

Before making that change, check whether a legacy delivery service still depends on ACLs. CloudFront standard logging is one example that may require a separate log bucket with compatible ownership settings.

Detect it

Use IAM Access Analyzer for S3 to find public and cross-account access. Add the AWS Config managed rules s3-bucket-public-read-prohibited, s3-bucket-public-write-prohibited, and s3-account-level-public-access-blocks-periodic. Security Hub exposes corresponding S3 controls if you already use it.

Alert when someone changes:

  • a bucket policy;
  • Block Public Access;
  • an ACL;
  • an access point policy;
  • an organization-level S3 policy.

Attack 2: stolen credentials

Long-lived access keys turn one leaked secret into an open-ended incident. Bots inspect public repositories, package registries, logs, build artifacts, and paste sites for credentials. An attacker with a valid principal doesn’t need an S3 vulnerability. They use the permissions you already granted.

With a valid principal, an attacker can discover buckets, inspect their configuration, copy objects, and delete or overwrite data when the role permits it.

Prevent it

Don’t create long-lived keys when a short-lived identity will work.

  • EC2, Lambda, ECS, and EKS workloads should use IAM roles.
  • Human access should use IAM Identity Center or another federated identity path.
  • GitHub Actions should exchange an OIDC token for a scoped deployment role.
  • External workloads can use IAM Roles Anywhere or another federation mechanism.

Then reduce the damage a stolen session can cause. Separate read, write, replication, policy administration, and version deletion. A deployment role that uploads website files doesn’t need s3:PutBucketPolicy, s3:PutReplicationConfiguration, or s3:DeleteObjectVersion.

Secret scanning catches mistakes during the transition away from keys. It doesn’t replace short-lived identities and narrow permissions.

Detect it

CloudTrail event history records management events, but S3 object reads and writes are data events. CloudTrail doesn’t log those data events by default. Enable them for sensitive buckets or use advanced event selectors to control cost.

GuardDuty S3 Protection analyzes S3 data events for suspicious access, exfiltration, and destructive behavior. It helps when nobody can watch raw events continuously.

Attack 3: SSRF to instance credentials

The DOJ complaint in the 2019 Capital One case describes commands that passed through a misconfigured firewall, obtained credentials, listed S3 buckets, and extracted data. The attack path is commonly summarized as server-side request forgery (SSRF) against the EC2 Instance Metadata Service followed by use of an overprivileged IAM role.

IMDSv2 requires a token request with PUT and a later metadata request carrying that token. Many simple SSRF paths can’t perform that exchange. Some can. IMDSv2 reduces the credential-exposure path; it doesn’t fix SSRF or excessive IAM permissions.

Prevent it

Require IMDSv2 for new launches at the account level in every Region you use:

aws ec2 modify-instance-metadata-defaults \
  --region us-east-1 \
  --http-tokens required \
  --http-put-response-hop-limit 1

Update existing instances separately:

aws ec2 modify-instance-metadata-options \
  --instance-id i-1234567890abcdef0 \
  --http-tokens required \
  --http-put-response-hop-limit 1 \
  --http-endpoint enabled

Test applications and container networking before enforcing a hop limit of one. Some container arrangements require a different value.

A Service Control Policy (SCP) can deny ec2:RunInstances when ec2:MetadataHttpTokens isn’t required. Also deny unauthorized changes through ec2:ModifyInstanceMetadataOptions. That doesn’t replace fixing the application request path and reducing the instance role.

Attack 4: overwrite, delete, and SSE-C ransomware

Attackers with valid S3 write permissions have used CopyObject with server-side encryption and customer-provided keys (SSE-C) to overwrite objects with versions that only the attacker can decrypt. Others place delete markers or permanently delete versions.

Versioning helps only while recoverable versions still exist. A principal with s3:DeleteObjectVersion can remove them. Lifecycle rules can expire them. Until you’ve restored from them, you’re assuming they work.

Prevent it

Enable versioning where losing or overwriting data would hurt:

aws s3api put-bucket-versioning \
  --bucket example-bucket \
  --versioning-configuration Status=Enabled

For backups and audit records, use S3 Object Lock or AWS Backup Vault Lock with a retention period based on recovery requirements. Keep a second copy in a separate account when the primary account’s administrators shouldn’t be able to destroy both copies.

If no workload uses SSE-C, deny it in the bucket policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenySSECustomerKeys",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::example-bucket/*",
      "Condition": {
        "Null": {
          "s3:x-amz-server-side-encryption-customer-algorithm": "false"
        }
      }
    }
  ]
}

AWS Organizations resource control policies can apply the same denial across accounts. An explicit policy documents the rule and covers buckets where compatibility settings differ.

Grant these permissions only to the roles that need them:

  • s3:DeleteObjectVersion;
  • s3:PutLifecycleConfiguration;
  • s3:PutBucketVersioning;
  • s3:PutObjectRetention;
  • s3:BypassGovernanceRetention.

Detect it

Log S3 data events and alert on unusual volumes of CopyObject, DeleteObject, and DeleteObjectVersion. For SSE-C, inspect CloudTrail request parameters for x-amz-server-side-encryption-customer-algorithm. GuardDuty S3 Protection includes detections for suspicious destructive and encryption activity.

Attack 5: quiet exfiltration through configuration

A direct download is noisy. An attacker with control-plane permissions may instead change the bucket so future data leaves automatically.

Watch two configurations:

  • replication rules that copy objects to another bucket;
  • event notifications that send object events to Lambda, SQS, or SNS destinations.

Replication requires a role that S3 can assume and, for cross-account destinations, cooperation from the destination policy. That makes the attack harder, but not impossible when the compromised principal can pass roles and change both sides.

Prevent and detect it

Application roles rarely need these actions:

  • s3:PutReplicationConfiguration;
  • iam:PassRole for replication roles;
  • s3:PutBucketNotification;
  • s3:PutBucketPolicy;
  • s3:PutEncryptionConfiguration.

Keep those permissions in a narrow infrastructure role. Record the management events in CloudTrail and alert whenever production bucket replication, notifications, policy, or encryption configuration changes outside an approved deployment.

A practical AWS baseline

For a normal private workload, I want to see:

  • organization or account-level Block Public Access;
  • BucketOwnerEnforced unless a documented integration requires ACLs;
  • IAM Access Analyzer findings reviewed;
  • short-lived identities and least-privilege roles;
  • HTTPS enforced in the bucket policy;
  • versioning for recoverable data;
  • Object Lock or a locked backup for irreplaceable data;
  • SSE-C denied when unused;
  • CloudTrail data events on sensitive buckets;
  • GuardDuty S3 Protection or equivalent detection;
  • alerts on policy, replication, notification, lifecycle, and public-access changes;
  • a restore test that proves the backup works.

A public-access check can find an open bucket. It won’t find a stolen administrator role, a destructive encryption request, or a new replication path.

Check who can read the data, who can destroy every recoverable version, which configuration changes generate alerts, and whether a restore has ever worked.


Sources and related reading: