← Back to Playbooks
    SEV-2AWS

    S3 Access Denied / Bucket Policy Playbook

    Sudden 403 Forbidden errors from S3. Usually caused by bucket policy changes, IAM role modifications, SCPs, or S3 Block Public Access settings. This playbook covers rapid diagnosis across the multiple authorization layers that S3 evaluates on every request.

    Operator's Field Notes

    Jeremy Martinez · Incident Commander | Principal Site Reliability Engineer

    "S3 403s are one of the most frustrating incidents to debug because there are at least six different authorization layers that can say 'no': IAM policy, bucket policy, bucket ACL, object ACL, S3 Block Public Access, and SCPs. Any one of them denying access produces the same generic 'Access Denied' error."

    "The fastest path to diagnosis: use CloudTrail. Every S3 API call is logged, and the error response includes which policy denied access. Without CloudTrail, you're guessing across six permission boundaries."

    First 5 Minutes - Triage

    1. Identify the Scope

    # Is it all objects or specific prefixes?
    aws s3 ls s3://my-bucket/ --max-items 5
    aws s3 ls s3://my-bucket/some-prefix/ --max-items 5
    
    # Is it all principals or specific roles?
    # Test with your current credentials
    aws sts get-caller-identity
    aws s3api head-object --bucket my-bucket --key test-object
    
    # Is it read, write, or both?
    aws s3api get-object --bucket my-bucket --key test.txt /tmp/test.txt
    echo "test" | aws s3 cp - s3://my-bucket/write-test.txt

    2. Check CloudTrail for Denial Reason

    # Search CloudTrail for recent AccessDenied events
    aws cloudtrail lookup-events \
      --lookup-attributes AttributeKey=EventName,AttributeValue=GetObject \
      --start-time $(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S) \
      --max-results 10
    
    # The errorCode and errorMessage fields tell you WHY
    # Common: "Access Denied" with requestParameters showing the bucket/key

    3. Check Recent Changes

    # Check bucket policy
    aws s3api get-bucket-policy --bucket my-bucket
    
    # Check S3 Block Public Access (account level)
    aws s3control get-public-access-block --account-id 123456789012
    
    # Check S3 Block Public Access (bucket level)
    aws s3api get-public-access-block --bucket my-bucket
    
    # Check bucket ACL
    aws s3api get-bucket-acl --bucket my-bucket
    
    # Check the IAM role/user policy
    aws iam simulate-principal-policy \
      --policy-source-arn arn:aws:iam::123456789012:role/MyAppRole \
      --action-names s3:GetObject s3:PutObject \
      --resource-arns arn:aws:s3:::my-bucket/*

    Common Root Causes & Fixes

    Bucket Policy Deny Statement Added

    # Common: Someone added a deny-all or restrict-to-VPC-endpoint policy
    # Check for explicit Deny statements
    aws s3api get-bucket-policy --bucket my-bucket | jq '.Policy | fromjson | .Statement[] | select(.Effect == "Deny")'
    
    # Fix: Remove or correct the Deny statement
    aws s3api put-bucket-policy --bucket my-bucket --policy file://corrected-policy.json
    
    # If bucket policy is completely wrong, delete it:
    aws s3api delete-bucket-policy --bucket my-bucket

    S3 Block Public Access Enabled

    # If your app legitimately needs public access:
    aws s3api put-public-access-block --bucket my-bucket \
      --public-access-block-configuration \
      BlockPublicAcls=false,IgnorePublicAcls=false,\
      BlockPublicPolicy=false,RestrictPublicBuckets=false
    
    # WARNING: Only disable if bucket SHOULD be public
    # Better: Use CloudFront with OAI instead of public buckets

    IAM Role Permissions Changed

    # Check what policies are attached to the role
    aws iam list-attached-role-policies --role-name MyAppRole
    aws iam list-role-policies --role-name MyAppRole
    
    # Check if SCP is blocking
    # (requires Organizations access)
    aws organizations list-policies-for-target \
      --target-id ou-abcd-12345678 --filter SERVICE_CONTROL_POLICY
    
    # Quick fix: Attach the correct policy back
    aws iam attach-role-policy --role-name MyAppRole \
      --policy-arn arn:aws:iam::123456789012:policy/S3ReadWritePolicy

    VPC Endpoint Policy Restriction

    # S3 gateway endpoint may have restrictive policy
    aws ec2 describe-vpc-endpoints --filters "Name=service-name,Values=com.amazonaws.us-east-1.s3"
    
    # Check the endpoint policy
    # Common issue: Policy only allows specific buckets, new bucket not listed
    
    # Fix: Update endpoint policy to include the bucket
    aws ec2 modify-vpc-endpoint --vpc-endpoint-id vpce-0abc123 \
      --policy-document file://updated-endpoint-policy.json

    S3 Authorization Flow

    Every S3 request is evaluated against these layers in order. Any explicit Deny wins.

    1SCPs - Organization-level guardrails
    2IAM Policy - User/role permissions
    3S3 Block Public Access - Account + bucket level
    4Bucket Policy - Resource-based policy on the bucket
    5Bucket ACL / Object ACL - Legacy access control
    6VPC Endpoint Policy - If accessing via VPC endpoint

    Anti-Patterns

    ❌ Don't Do This

    • • Granting s3:* to fix access issues
    • • Disabling Block Public Access without understanding why
    • • Modifying bucket policy without backup
    • • Using ACLs (legacy, hard to audit)
    • • Not checking CloudTrail first

    ✅ Do This Instead

    • • Use IAM Policy Simulator to test
    • • CloudTrail for exact denial reason
    • • Backup policy before changes
    • • Use IAM policies + bucket policies (no ACLs)
    • • S3 Access Analyzer for continuous monitoring