SKY-D402 · Deployment and infrastructure
Terraform gives an S3 bucket a public ACL
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 towardmax_highandmax_security; the rule never reports CRITICAL. - Finding type
- review
- Catalog name
- Terraform AWS public S3 bucket ACL
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
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
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
- 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 the
aclofaws_s3_bucket(older provider versions) andaws_s3_bucket_acl. - Reports
public-read,public-read-writeandauthenticated-read. Known private ACLs such asprivateorbucket-owner-full-controlpass; explicitgrantlists andaccess_control_policyblocks are not judged. - Does not report when an
aws_s3_bucket_public_access_blockfor the same bucket, or an account-wide block in the same module, setsblock_public_aclsorignore_public_aclstotrue. - Reports HIGH on the
resourceline.
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.
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_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-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.