S3 bucket has `block_public_acls` disabled Affecting S3 service in AWS


Severity

0.0
medium
0
10
Severity Framework
Snyk CCSS
Rule category
Data/ Access Control

Is your environment affected by this misconfiguration?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
Frameworks
AWS-Well-ArchitectedCIS-AWSCIS-ControlsCSA-CCMGDPRHIPAAISO-27001NIST-800-53SOC-2
  • Snyk IDSNYK-CC-00191
  • creditSnyk Research Team

Description

Anyone who can manage the bucket's ACLs will be able to grant public access to the bucket.

How to fix?

Set the aws_s3_bucket_public_access_block or aws_s3_account_public_access_block block_public_acls field to true or use the default settings.

To enable block public access settings explicitly at the bucket level:

To enable block public access settings explicitly at the account level:

Example Configuration

# Enable for a single bucket
resource "aws_s3_bucket" "private" {
  acl           = "private"
  # other required fields here
}

resource "aws_s3_bucket_public_access_block" "private" {
  bucket                = "${aws_s3_bucket.private.id}"
  block_public_acls     = true
}

resource "aws_s3_bucket_ownership_controls" "private" {
  bucket = "${aws_s3_bucket.private.id}"
  rule {
    object_ownership = "BucketOwnerPreferred"
  }
}

resource "aws_s3_bucket_acl" "private" {
  depends_on = [aws_s3_bucket_ownership_controls.private]

  bucket = "${aws_s3_bucket.private.id}"
  acl    = "private"
}
# Enable for an entire AWS account
resource "aws_s3_account_public_access_block" "main" {
  block_public_acls     = true
}