Skip to main content

SKY-D404 · Deployment and infrastructure

Terraform turns off S3 public access protections

High

S3 Block Public Access is a set of four switches that stop public ACLs and public bucket policies from taking effect. SKY-D404 reports a Terraform aws_s3_bucket_public_access_block that explicitly sets one of them to false.

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 S3 public access protections disabled
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

The block is the safety net behind every other bucket setting. With it off, one public ACL or policy, added later by anyone, makes the bucket's data public.

What Skylos flags

main.tf · TerraformReported on line 5
resource "aws_s3_bucket" "media" {  bucket = "shop-media"} resource "aws_s3_bucket_public_access_block" "media" {  bucket                  = aws_s3_bucket.media.id  block_public_acls       = false  ignore_public_acls      = false  block_public_policy     = true  restrict_public_buckets = true}

What Skylos leaves alone

main.tf · Terraform
resource "aws_s3_bucket" "media" {  bucket = "shop-media"} resource "aws_s3_bucket_public_access_block" "media" {  bucket                  = aws_s3_bucket.media.id  block_public_acls       = true  ignore_public_acls      = true  block_public_policy     = true  restrict_public_buckets = true}

Why Skylos leaves it alone

The same resource with all four protections set to true.

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 aws_s3_bucket_public_access_block.
  5. Reports when any of block_public_acls, ignore_public_acls, block_public_policy and restrict_public_buckets is the literal false. A value that is not a boolean makes the resource not judged.
  6. Reports HIGH on the resource line, once per resource. Turning a protection off does not by itself make anything public; SKY-D402 and SKY-D403 report the grants.

How to fix it

Set all four protections to true. If the bucket must serve public files, keep it private and put CloudFront in front of it.

main.tf · Terraform · the fix, against the flagged file
resource "aws_s3_bucket" "media" {  bucket = "shop-media"} resource "aws_s3_bucket_public_access_block" "media" {  bucket                  = aws_s3_bucket.media.idRemoved:   block_public_acls       = falseRemoved:   ignore_public_acls      = falseAdded:   block_public_acls       = trueAdded:   ignore_public_acls      = true  block_public_policy     = true  restrict_public_buckets = true}

When it can be wrong

  • A protection that is left out is not reported, although the AWS provider then sets it to false. Write all four explicitly.
  • 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-D404] on the resource line does not hide the finding.

  • [tool.skylos] ignore = ["SKY-D404"] 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.