Skip to main content

SKY-D402 · Deployment and infrastructure

Terraform gives an S3 bucket a public ACL

High

An access control list (ACL) is an older way to grant access to an S3 bucket. SKY-D402 reports a Terraform bucket that asks for one of the canned ACLs that let anyone read or write it: public-read, public-read-write, or authenticated-read (any AWS account).

Languages
Terraform
Quality gate
counted toward the gate limits (full and diff scans). Reported under security (danger). It counts toward max_high and max_security; the rule never reports CRITICAL.
Finding type
review
Catalog name
Terraform AWS public S3 bucket ACL
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Everything in the bucket becomes downloadable by anyone who guesses its name, and with public-read-write anyone can also upload or overwrite files. Many data leaks were exactly this setting on a bucket meant for logs or backups.

What Skylos flags

main.tf · TerraformReported on line 5
resource "aws_s3_bucket" "exports" {  bucket = "shop-customer-exports"} resource "aws_s3_bucket_acl" "exports" {  bucket = aws_s3_bucket.exports.id  acl    = "public-read"}

What Skylos leaves alone

main.tf · Terraform
resource "aws_s3_bucket" "exports" {  bucket = "shop-customer-exports"} resource "aws_s3_bucket_acl" "exports" {  bucket = aws_s3_bucket.exports.id  acl    = "public-read"} resource "aws_s3_bucket_public_access_block" "exports" {  bucket                  = aws_s3_bucket.exports.id  block_public_acls       = true  ignore_public_acls      = true  block_public_policy     = true  restrict_public_buckets = true}

Why Skylos leaves it alone

The ACL still asks for public read, but the same bucket has a public access block with ignore_public_acls = true, so S3 ignores the public grant. Skylos sees the overlap and does not report it (the ACL line is still worth deleting).

How Skylos decides

  1. Runs with --danger (or -a). Reads .tf and .tf.json files, skipping .terraform, .git, node_modules, vendor, build, dist and virtual-environment folders, and parses them as HCL without running Terraform or contacting AWS.
  2. Resolves only literal values and local values of the same module. Input variables, data sources, attributes of other resources and module outputs stay unknown, and an unknown value never produces a finding.
  3. Skips a resource with count = 0 or an empty for_each, and needs the official AWS provider (hashicorp/aws, which an aws_ resource uses unless another provider is configured).
  4. Checks the acl of aws_s3_bucket (older provider versions) and aws_s3_bucket_acl.
  5. Reports public-read, public-read-write and authenticated-read. Known private ACLs such as private or bucket-owner-full-control pass; explicit grant lists and access_control_policy blocks are not judged.
  6. Does not report when an aws_s3_bucket_public_access_block for the same bucket, or an account-wide block in the same module, sets block_public_acls or ignore_public_acls to true.
  7. Reports HIGH on the resource line.

How to fix it

Remove the ACL (new buckets have ACLs disabled by default) and add a public access block. Share files with presigned URLs or through CloudFront instead.

main.tf · Terraform · the fix, against the flagged file
resource "aws_s3_bucket" "exports" {  bucket = "shop-customer-exports"} Removed: resource "aws_s3_bucket_acl" "exports" {Removed:   bucket = aws_s3_bucket.exports.idRemoved:   acl    = "public-read"Added: resource "aws_s3_bucket_public_access_block" "exports" {Added:   bucket                  = aws_s3_bucket.exports.idAdded:   block_public_acls       = trueAdded:   ignore_public_acls      = trueAdded:   block_public_policy     = trueAdded:   restrict_public_buckets = true}

When it can be wrong

  • Values that come from variables, modules or other resources are not checked, because Skylos does not run Terraform: cidr_blocks = var.admin_cidrs is not reported even when its default is 0.0.0.0/0.
  • It judges the declaration only. It does not know what is deployed, and other settings (account defaults, security groups, routing) can make the real exposure smaller or larger.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • Terraform rules read no inline marker: # skylos: ignore[SKY-D402] on the resource line does not hide the finding.

  • [tool.skylos] ignore = ["SKY-D402"] turns the rule off for the project.

  • A baseline (skylos baseline ., then --baseline) accepts the declarations that exist today and reports new ones.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.