SKY-D404 · Deployment and infrastructure
Terraform turns off S3 public access protections
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 towardmax_highandmax_security; the rule never reports CRITICAL. - Finding type
- review
- Catalog name
- Terraform AWS S3 public access protections disabled
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
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
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
- Runs with
--danger(or-a). Reads.tfand.tf.jsonfiles, skipping.terraform,.git,node_modules,vendor,build,distand virtual-environment folders, and parses them as HCL without running Terraform or contacting AWS. - Resolves only literal values and
localvalues 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. - Skips a resource with
count = 0or an emptyfor_each, and needs the official AWS provider (hashicorp/aws, which anaws_resource uses unless another provider is configured). - Checks
aws_s3_bucket_public_access_block. - Reports when any of
block_public_acls,ignore_public_acls,block_public_policyandrestrict_public_bucketsis the literalfalse. A value that is not a boolean makes the resource not judged. - Reports HIGH on the
resourceline, 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.
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_cidrsis not reported even when its default is0.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.