S3 Wildcard Principal Without Conditions: The Leak
Overview
Deleting a Condition block to silence an AccessDenied error leaves Principal * unconstrained, so s3:GetObject or s3:PutObject becomes callable by anyone. S3 accepts such a policy only when BlockPublicPolicy is off at both account and bucket level.
At a glance
- Symptom
- Engineer strips Condition block to clear AccessDenied during testing, leaving wildcard principal unscoped
- Likely cause
- Bucket policy Principal "*" with no Condition, and BlockPublicPolicy overridden to false
- Impact
- Any unauthenticated internet caller gains read or write access to bucket objects, enabling exfiltration or ransomware-style overwrite
- Verification signal
- Re-run the detection test and a controlled negative-path test.
- Safe correction
- Restore scoped Condition using aws:SourceArn or aws:PrincipalOrgID; enforce account-wide Block Public Access; validate policies with Access Analyzer
- Rollback or recovery
- Restore the exported configuration if the new control blocks required production traffic, then narrow the policy before redeployment.
The Trap
Wildcard Principal (“Principal”: “*”) left in an S3 bucket policy with no accompanying Condition block. This is distinct from a plain public bucket toggle; the policy looks scoped because it references a specific service, action, or resource, but nothing actually constrains who that wildcard resolves to.
The Default State
AWS’s own documentation examples for CloudFront origin access control and SES inbound receipt rules use a service principal paired with a Condition using aws:SourceArn or aws:SourceAccount. Engineers copy the Action blocks into Terraform’s aws_s3_bucket_policy resource or a CloudFormation template, then hit an AccessDenied error during testing. The fastest fix under deadline pressure is widening the principal to “*” and deleting the Condition block rather than diagnosing why the principal, ARN or account ID doesn’t match — the policy applies cleanly once the constraint is gone, and the ticket closes as resolved.
The Blast Radius
S3 Block Public Access normally intercepts PutBucketPolicy calls that grant public access via Principal “*” unless the statement includes a recognised narrowing condition key — aws:SourceArn, aws:SourceIp, aws:SourceVpce, aws:PrincipalOrgID, or similar. But it only applies where enabled at bucket or account level: buckets created before April 2023, when AWS began enabling it on new buckets by default, or via IaC modules that explicitly set BlockPublicPolicy=false, accept the policy without complaint unless the account-level setting blocks it. Once attached, s3:GetObject or s3:PutObject becomes callable by any unauthenticated request. Bucket names are often guessable or visible in DNS and certificate records, and scanners routinely probe for open buckets; exposed write access invites ransomware-style overwrite of objects, exposed read access invites bulk exfiltration via aws s3 sync run anonymously with –no-sign-request.
The Lead Mechanic Fix
Restore the service principal and a Condition scoped to the actual caller, for example “Principal”: {“Service”: “cloudfront.amazonaws.com”} with “Condition”: {“StringEquals”: {“AWS:SourceArn”: “arn:aws:cloudfront::123456789012:distribution/EDFDVBD6EXAMPLE”}}, or “aws:PrincipalOrgID” for access from your own organisation. Enforce the guardrail on the bucket with aws s3api put-public-access-block --bucket BUCKET --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true, and account-wide with aws s3control put-public-access-block --account-id ACCOUNT_ID and the same configuration once you have confirmed no bucket legitimately needs public access. Before deployment, validate every candidate policy with aws accessanalyzer check-no-public-access --policy-document file://policy.json --resource-type AWS::S3::Bucket, which returns FAIL if the policy can grant public access. Run an IAM Access Analyzer external-access scan continuously against the account, and treat any finding with an empty condition set as a Sev-1, not a backlog item.
Related reading
Apply the safer control
Before you change production
Confirm the affected scope, export the current configuration, and test the replacement control in a non-production environment first.
Fix commands and configuration
aws s3api put-public-access-block --bucket BUCKET --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=trueaws s3control put-public-access-block --account-id ACCOUNT_IDaws accessanalyzer check-no-public-access --policy-document file://policy.json --resource-type AWS::S3::BucketVerify, roll back or escalate
Verify
Re-run the detection test and a controlled negative-path test. Confirm the unsafe behaviour is blocked while approved traffic still succeeds.
Rollback
Restore the exported configuration if the new control blocks required production traffic, then narrow the policy before redeployment.
Escalate
Escalate when the blast radius is uncertain, the control cannot be tested safely, or remediation requires an outage or security exception.
Fixed? Get the next one before it hits you: The KBY Brief
Practical fixes for the systems you run, by email about twice a week. Unsubscribe at any time.
About this page
Credited to
Dates
Published
Last updated
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
