SKY-D403 · Deployment and infrastructure
Terraform S3 bucket policy grants access to everyone
A bucket policy is a JSON document that says who may do what with an S3 bucket. SKY-D403 reports a Terraform bucket policy with an Allow statement for the principal * (anyone, signed in or not) and no conditions.
- 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 policy
Why it matters
Every object the statement covers can be read, or with write actions overwritten or deleted, by anyone on the internet. A policy copied from a static-website tutorial is a common way private files end up public.
What Skylos flags
resource "aws_s3_bucket_policy" "downloads" { bucket = "shop-downloads" policy = jsonencode({ Version = "2012-10-17" Statement = [{ Effect = "Allow" Principal = "*" Action = "s3:GetObject" Resource = "arn:aws:s3:::shop-downloads/*" }] })}What Skylos leaves alone
resource "aws_s3_bucket_policy" "downloads" { bucket = "shop-downloads" policy = jsonencode({ Version = "2012-10-17" Statement = [{ Effect = "Allow" Principal = { AWS = "arn:aws:iam::123456789012:role/reporting" } Action = "s3:GetObject" Resource = "arn:aws:s3:::shop-downloads/*" }] })}Why Skylos leaves it alone
The same read grant goes to one IAM role in your own account, not to everyone. Account IDs, role and user ARNs, and AWS service principals are not public.
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_policy. The policy must be a literal: a JSON string or ajsonencode({...})of literal values. A policy built from a data source or a variable is not judged. - Reports an
Allowstatement whose principal is*or{ AWS = "*" }, whose actions are S3 actions such ass3:GetObject,s3:PutObject,s3:*or*, and whose resources are*or this bucket. - A statement with a
Condition, aDeny, aNotPrincipalor another unsupported key makes the whole policy not judged. - Does not report when a public access block for the same bucket sets
block_public_policyorrestrict_public_buckets. - Reports HIGH on the
resourceline.
How to fix it
Grant access to the roles or services that need it. For public downloads, serve the bucket through CloudFront with origin access control and keep the bucket itself private.
resource "aws_s3_bucket_policy" "downloads" { bucket = "shop-downloads" policy = jsonencode({ Version = "2012-10-17" Statement = [{ Effect = "Allow"Removed: Principal = "*"Added: Principal = { AWS = "arn:aws:iam::123456789012:role/reporting" } Action = "s3:GetObject" Resource = "arn:aws:s3:::shop-downloads/*" }] })}When it can be wrong
- A public statement with any
Condition, even a weak one, is not reported, because Skylos does not evaluate conditions. - 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-D403]on the resource line does not hide the finding.[tool.skylos] ignore = ["SKY-D403"]turns the rule off for the project.A baseline (
skylos baseline ., then--baseline) accepts the declarations that exist today and reports new ones.