Skip to content

Update s3.tf#11

Open
bmppa wants to merge 16 commits into
mainfrom
demo
Open

Update s3.tf#11
bmppa wants to merge 16 commits into
mainfrom
demo

Conversation

@bmppa
Copy link
Copy Markdown
Owner

@bmppa bmppa commented Jan 25, 2023

No description provided.

Copy link
Copy Markdown

@prisma-cloud-devsecops prisma-cloud-devsecops Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prisma Cloud has found errors in this PR ⬇️

Comment thread terraform/aws/s3.tf
git_repo = "iac-demo"
yor_trace = "8cebc6f3-14b0-4a60-bd65-7988a2c206f1"
}
}
Copy link
Copy Markdown

@prisma-cloud-devsecops prisma-cloud-devsecops Bot Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
acl = "private"
HIGH   AWS S3 bucket ACL grants READ permission to everyone
    Resource: aws_s3_bucket.data | Policy ID: 807152304871829504_AWS_1670654004846 | Checkov ID: CKV_AWS_20

Description

https://docs.bridgecrew.io/docs/s3_1-acl-read-permissions-everyone

Benchmarks

  • NIST-800-53 AC-17

🎉   Fixed by commit ac01ce3 - Prisma Cloud bot fix for terraform/aws/s3.tf

Comment thread terraform/aws/s3.tf
git_repo = "iac-demo"
yor_trace = "8cebc6f3-14b0-4a60-bd65-7988a2c206f1"
}
}
Copy link
Copy Markdown

@prisma-cloud-devsecops prisma-cloud-devsecops Bot Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM  AWS Access logging not enabled on S3 buckets
    Resource: aws_s3_bucket.data | Bridgecrew ID: BC_AWS_S3_13 | Checkov ID: CKV_AWS_18

How to Fix

resource "aws_s3_bucket" "bucket" {
  acl    = var.s3_bucket_acl
  bucket = var.s3_bucket_name
  policy = var.s3_bucket_policy

  force_destroy = var.s3_bucket_force_destroy
  versioning {
    enabled    = var.versioning
    mfa_delete = var.mfa_delete
  }

+  dynamic "logging" {
+    for_each = var.logging
+    content {
+      target_bucket = logging.value["target_bucket"]
+      target_prefix = "log/${var.s3_bucket_name}"
+    }
+  }
}

Description

Access logging provides detailed audit logging for all objects and folders in an S3 bucket.

Benchmarks

  • HIPAA 164.312(B) Audit controls
     🎉   Fixed by commit 6eff6f0 - Update s3.tf

Comment thread terraform/aws/s3.tf
git_repo = "iac-demo"
yor_trace = "8cebc6f3-14b0-4a60-bd65-7988a2c206f1"
}
}
Copy link
Copy Markdown

@prisma-cloud-devsecops prisma-cloud-devsecops Bot Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  Testing Bucket with encryption
    Resource: aws_s3_bucket.data | Bridgecrew ID: cb404a47-3b88-40eb-b6ad-94081e055e6a
     🎉   Fixed by commit 6eff6f0 - Update s3.tf

Comment thread terraform/aws/s3.tf
git_repo = "iac-demo"
yor_trace = "8cebc6f3-14b0-4a60-bd65-7988a2c206f1"
}
}
Copy link
Copy Markdown

@prisma-cloud-devsecops prisma-cloud-devsecops Bot Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  AWS S3 Object Versioning is disabled
    Resource: aws_s3_bucket.data | Bridgecrew ID: 807152304871829504_AWS_1658427621485 | Checkov ID: CKV_AWS_21

Description

https://docs.bridgecrew.io/docs/s3_16-enable-versioning
     🎉   Fixed by commit 6eff6f0 - Update s3.tf

Copy link
Copy Markdown

@prisma-cloud-devsecops prisma-cloud-devsecops Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️   Due to ac01ce3 - Prisma Cloud bot fix for terraform/aws/s3.tf - 1 error was fixed.

Change details

Error ID Change Path Resource
807152304871829504_AWS_1670654004846 Fixed /terraform/aws/s3.tf aws_s3_bucket.data

Comment thread terraform/aws/s3.tf
Privacy = "public"
Proj = "prisma-cloud-pov"
}
}
Copy link
Copy Markdown

@prisma-cloud-devsecops prisma-cloud-devsecops Bot Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}
resource "aws_s3_bucket_versioning" "public_bucket" {
bucket = aws_s3_bucket.public_bucket.id
versioning_configuration {
status = "Enabled"
}
}
resource "aws_s3_bucket" "destination" {
bucket = aws_s3_bucket.public_bucket.id
versioning_configuration {
status = "Enabled"
}
}
resource "aws_iam_role" "replication" {
name = "aws-iam-role"
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "s3.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
POLICY
}
resource "aws_s3_bucket_replication_configuration" "public_bucket" {
depends_on = [aws_s3_bucket_versioning.public_bucket]
role = aws_iam_role.public_bucket.arn
bucket = aws_s3_bucket.public_bucket.id
rule {
id = "foobar"
status = "Enabled"
destination {
bucket = aws_s3_bucket.destination.arn
storage_class = "STANDARD"
}
}
}
LOW  S3 bucket cross-region replication disabled
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: BC_AWS_GENERAL_72 | Checkov ID: CKV_AWS_144

How to Fix

resource "aws_s3_bucket" "test" {
  ...
+  replication_configuration {
+    role = aws_iam_role.replication.arn
+    rules {
+      id     = "foobar"
+      prefix = "foo"
+      status = "Enabled"
+
+      destination {
+        bucket        = aws_s3_bucket.destination.arn
+        storage_class = "STANDARD"
+      }
+    }
+  }
}

Description

Cross-region replication enables automatic, asynchronous copying of objects across S3 buckets. By default, replication supports copying new S3 objects after it is enabled. It is also possible to use replication to copy existing objects and clone them to a different bucket, but in order to do so, you must contact AWS Support.

Comment thread terraform/aws/s3.tf
Privacy = "public"
Proj = "prisma-cloud-pov"
}
}
Copy link
Copy Markdown

@prisma-cloud-devsecops prisma-cloud-devsecops Bot Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}
resource "aws_s3_bucket_server_side_encryption_configuration" "public_bucket" {
bucket = aws_s3_bucket.public_bucket.bucket
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "aws:kms"
}
}
}
LOW  S3 buckets are not encrypted with KMS
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: BC_AWS_GENERAL_56 | Checkov ID: CKV_AWS_145

How to Fix

resource "aws_s3_bucket" "bucket_name" {
  bucket = "bucket_good"
}

+ resource "aws_s3_bucket_server_side_encryption_configuration" "good_sse_1" {
+   bucket = aws_s3_bucket.bucket_name.bucket
+
+   rule {
+     apply_server_side_encryption_by_default {
+       kms_master_key_id = aws_kms_key.mykey.arn
+       sse_algorithm     = "aws:kms"
+     }
+   }
+ }

Description

Encrypting your data and resources with KMS helps protect your data from unauthorized access or tampering. By encrypting your data, you can ensure that only authorized users can access and decrypt the data, and that the data is protected while in storage or in transit. Such action can help protect against external threats such as hackers or malware, as well as internal threats such as accidental or unauthorized access.

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  AWS S3 Object Versioning is disabled
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1658427621485 | Checkov ID: CKV_AWS_21

Description

https://docs.bridgecrew.io/docs/s3_16-enable-versioning

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  everitt-build-1
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1678303513602

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW  S3 Bucket does not have public access blocks
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: BC_AWS_NETWORKING_52 | Checkov ID: CKV2_AWS_6

How to Fix

resource "aws_s3_bucket" "bucket_good_1" {
  bucket = "bucket_good"
}

resource "aws_s3_bucket_public_access_block" "access_good_1" {
  bucket = aws_s3_bucket.bucket_good_1.id

  block_public_acls   = true
  block_public_policy = true
}

Description

When you create an S3 bucket, it is good practice to set the additional resource **aws_s3_bucket_public_access_block** to ensure the bucket is never accidentally public.

We recommend you ensure S3 bucket has public access blocks. If the public access block is not attached it defaults to False.

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW  test_pccs_rule1-EVERITT
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1658067543241

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  Weib - Check for classified S3 bucket without server-side encryption enabled
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1659266345263

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  All S3 Buckets must have a tag with key Classification and have versioning enabled
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1643813941482

Description

Ensure that S3 bucket have a classification tag

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  Testing Bucket with encryption
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: cb404a47-3b88-40eb-b6ad-94081e055e6a

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM  Jety_Policy_S3 Tag
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1658067543253

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW  VSCode Check
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1651820063408

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  DM_TEST_tags
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1678109938201

Description

test

Comment thread terraform/aws/main.tf
}

# Create a random string
resource "random_string" "random" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  DM_TEST_tags
    Resource: random_string.random | Bridgecrew ID: 807152304871829504_AWS_1678109938201

Description

test

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW  SM test - build policy
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1656555386808

Description

Enable versioning

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW  test_pccs_rule1-EVERITT
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1658067543241

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW  SM test - build policy
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1656555386808

Description

Enable versioning

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  Testing Bucket with encryption
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: cb404a47-3b88-40eb-b6ad-94081e055e6a

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  DM_TEST_tags
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1678109938201

Description

test

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM  Jety_Policy_S3 Tag
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1658067543253

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW  VSCode Check
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1651820063408

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  Weib - Check for classified S3 bucket without server-side encryption enabled
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1659266345263

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  AWS S3 Object Versioning is disabled
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1658427621485 | Checkov ID: CKV_AWS_21

Description

https://docs.bridgecrew.io/docs/s3_16-enable-versioning

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  everitt-build-1
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1678303513602

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HIGH  All S3 Buckets must have a tag with key Classification and have versioning enabled
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: 807152304871829504_AWS_1643813941482

Description

Ensure that S3 bucket have a classification tag

Comment thread terraform/aws/s3.tf
acl = "public-read"
force_destroy = true
# Create a bucket where objects can be public
resource "aws_s3_bucket" "public_bucket" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW  S3 Bucket does not have public access blocks
    Resource: aws_s3_bucket.public_bucket | Bridgecrew ID: BC_AWS_NETWORKING_52 | Checkov ID: CKV2_AWS_6

How to Fix

resource "aws_s3_bucket" "bucket_good_1" {
  bucket = "bucket_good"
}

resource "aws_s3_bucket_public_access_block" "access_good_1" {
  bucket = aws_s3_bucket.bucket_good_1.id

  block_public_acls   = true
  block_public_policy = true
}

Description

When you create an S3 bucket, it is good practice to set the additional resource **aws_s3_bucket_public_access_block** to ensure the bucket is never accidentally public.

We recommend you ensure S3 bucket has public access blocks. If the public access block is not attached it defaults to False.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants