S3 bucket should not have writable permissions from anonymous users

Misconfigured S3 buckets can leak private information to the entire internet or allow unauthorized data tampering / deletion

Risk Level: Critical
Cloud Entity: Simple Storage Service (S3)
CloudGuard Rule ID: D9.AWS.IAM.32
Category: Storage

GSL LOGIC

S3Bucket should not have acl.grants contain [uri = 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers' and (premission = 'FULL_CONTROL' or premission = 'WRITE_ACP')]

REMEDIATION

From Portal:
The S3 Block Public Access feature provides settings for access points, buckets, and accounts to help manage public access to Amazon S3 resources. By default, new buckets, access points, and objects don't allow public access. However, users can modify bucket policies, access point policies, or object permissions to allow public access. To remediate an existing Bucket Policy to non-public access, follow these steps:

  1. Sign in to your S3 bucket console - https://s3.console.aws.amazon.com/
  2. Click on the bucket you want to remediate the bucket policy
  3. On the Bucket dashboard, click on Permissions tab
  4. In the Permissions tab, click on the Bucket Policy button
  5. Ensure that the Principal and Resource elements along with action(such as s3: ), in the policy do not have an (values that contain a wildcard). If the bucket policy contains access to all Resource elements and Principal elements, you can make these policies non-public by including any of the condition keys, such as ;
    aws:SourceArn
    aws:SourceVpc
    aws:SourceVpce
    aws:SourceOwner
    aws:SourceAccount
    s3:x-amz-server-side-encryption-aws-kms-key-id
    aws:userid, outside the pattern 'AROLEID:*'
    s3:DataAccessPointArn, using a fixed value.

From TF:

resource "aws_s3_bucket" "test" {
	bucket = "mybucket"
	grant {
		type        = "Group"
		+   permissions = [...] #  not "WRITE" or "FULL_CONTROL" or "WRITE_ACP"
		uri         = "http://acs.amazonaws.com/groups/global/AuthenticatedUsers"
	}
}

From Command Line:

  1. Get and put a bucket policy. The following example shows how to download an Amazon S3 bucket policy, make modifications to the file, and then use put-bucket-policy to apply the modified bucket policy. Run following command to download the bucket policy to a file.
aws s3api get-bucket-policy --bucket BUCKET_NAME --query Policy --output text > policy.json
  1. You can then modify the policy.json file as needed. Finally you can apply this modified policy back to the S3 bucket by running:
aws s3api put-bucket-policy --bucket BUCKET_NAME --policy POLICY.JSON

Note: Use action as s3:Put and Effect:Deny for user principals . Follow reference links for more details on json policy.

Referemces:

  1. https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-bucket-policy.html to create a new Bucket Policy.
  2. Similarly, make sure that the S3 bucket access control lists (ACLs) that provide read, write, or full-access to Everyone or Any authenticated AWS user does not exist. For more information, please refer - https://docs.aws.amazon.com/AmazonS3/latest/dev/S3_ACLs_UsingACLs.html
  3. https://docs.aws.amazon.com/AmazonS3/latest/dev/using-iam-policies.html
  4. https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-with-s3-actions.html
  5. https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-policy.html
  6. https://docs.aws.amazon.com/cli/latest/reference/s3api/get-bucket-policy.html

Simple Storage Service (S3)

Companies today need the ability to simply and securely collect, store, and analyze their data at a massive scale. Amazon S3 is object storage built to store and retrieve any amount of data from anywhere ��� web sites and mobile apps, corporate applications, and data from IoT sensors or devices. It is designed to deliver 99.999999999% durability, and stores data for millions of applications used by market leaders in every indu

Compliance Frameworks

  • AWS CCPA Framework
  • AWS CloudGuard Best Practices
  • AWS CloudGuard S3 Bucket Security
  • AWS CloudGuard SOC2 based on AICPA TSC 2017
  • AWS CloudGuard Well Architected Framework
  • AWS HIPAA
  • AWS HITRUST
  • AWS ISO 27001:2013
  • AWS ITSG-33
  • AWS LGPD regulation
  • AWS MAS TRM Framework
  • AWS MITRE ATT&CK Framework v10
  • AWS MITRE ATT&CK Framework v11
  • AWS NIST 800-171
  • AWS NIST 800-53 Rev 4
  • AWS NIST 800-53 Rev 5
  • AWS NIST CSF v1.1
  • AWS PCI-DSS 3.2
  • AWS Risk Management
  • AWS Security Risk Management