Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Valid Terraform configuration fails with s3EnforceUserAcl #659

Closed
msnook opened this issue Apr 13, 2021 · 1 comment · Fixed by #828
Closed

Valid Terraform configuration fails with s3EnforceUserAcl #659

msnook opened this issue Apr 13, 2021 · 1 comment · Fixed by #828
Assignees
Labels
policy Issue concerning policy maintainers.

Comments

@msnook
Copy link

msnook commented Apr 13, 2021

  • terrascan version: Latest Docker image

Description

Trying to verify S3 bucket configuration, but keep running into a failing test case (due to s3EnforceUserAcl).

What I Did

Code snippet:

resource "aws_s3_bucket" "frontend_lb_logs" {
  bucket = "frontend-access-logs"
  acl    = "private"

  versioning {
    enabled = true
  }

  logging {
    target_bucket = "log-bucket"
    target_prefix = "AWSLogs/frontend-lb-access-logs/"
  }
}

resource "aws_s3_bucket_policy" "frontend_lb_logs_policy" {
  bucket = aws_s3_bucket.frontend_lb_logs.id

  policy = /* valid policy truncated */
}

I truncated the policy above to simplify the troubleshooting. Note: when I add the policy directly to the aws_s3_bucket, the terrascan results work fine!

Here is the command I run:

terrascan scan -l error --iac-type terraform --iac-version v14 --use-colors f -o json -v -f "/temp/main.tf" -t

Here are the results I get if I use aws_s3_bucket_policy:

{
  "results": {
    "violations": [
      {
        "rule_name": "s3EnforceUserACL",
        "description": "S3 bucket Access is allowed to all AWS Account Users.",
        "rule_id": "AWS.S3Bucket.DS.High.1043",
        "severity": "HIGH",
        "category": "Identity and Access Management",
        "resource_name": "frontend_lb_logs",
        "resource_type": "aws_s3_bucket",
        "file": "main.tf",
        "line": 363
      }
    ],
    "skipped_violations": null,
    "scan_summary": {
      "file/folder": "/temp/main.tf",
      "iac_type": "terraform",
      "scanned_at": "2021-04-13 19:35:10.781287492 +0000 UTC",
      "policies_validated": 158,
      "violated_policies": 1,
      "low": 0,
      "medium": 0,
      "high": 1
    }
  }
}

Why is aws_s3_bucket_policy not recognized by the terrascan?

@amirbenv
Copy link
Contributor

Thanks for the report, will update soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
policy Issue concerning policy maintainers.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants