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

Code Review of a new Feature #590

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

mikeurbanski1
Copy link

No description provided.

Copy link

@bridgecrew bridgecrew bot left a comment

Choose a reason for hiding this comment

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

Bridgecrew has found infrastructure configuration errors in this PR ⬇️

@@ -23,6 +23,31 @@ resource "aws_s3_bucket" "data" {
}
}

resource "aws_s3_bucket" "data2" {
Copy link

@bridgecrew bridgecrew bot Nov 19, 2021

Choose a reason for hiding this comment

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

LOW   Ensure S3 Bucket has public access blocks
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_NETWORKING_52

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.

@@ -23,6 +23,31 @@ resource "aws_s3_bucket" "data" {
}
}

resource "aws_s3_bucket" "data2" {
Copy link

@bridgecrew bridgecrew bot Nov 19, 2021

Choose a reason for hiding this comment

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

LOW   Ensure S3 bucket has cross-region replication enabled
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_GENERAL_72

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.

versioning {
enabled = "${var.versioning_enabled}"
}
}
Copy link

@bridgecrew bridgecrew bot Nov 19, 2021

Choose a reason for hiding this comment

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

Suggested change
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
HIGH   Ensure data stored in the S3 bucket is securely encrypted at rest
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_S3_14

Description

SSE helps prevent unauthorized access to S3 buckets. Encrypting and decrypting data at the S3 bucket level is transparent to users when accessing data.

Benchmarks

  • PCI-DSS V3.2 3
  • NIST-800-53 AC-17, SC-2
  • PCI-DSS V3.2.1 3.4
  • FEDRAMP (MODERATE) SC-28
  • CIS AWS V1.3 2.1.1

🎉   Fixed by commit 0440345 - Bridgecrew bot fix for terraform/aws/s3.tf

@@ -23,6 +23,31 @@ resource "aws_s3_bucket" "data" {
}
}

resource "aws_s3_bucket" "data2" {
Copy link

@bridgecrew bridgecrew bot Nov 19, 2021

Choose a reason for hiding this comment

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

HIGH   PCI check tag exists
    Resource: aws_s3_bucket.data2 | ID: acme_aws_1629787200891

@@ -23,6 +23,31 @@ resource "aws_s3_bucket" "data" {
}
}

resource "aws_s3_bucket" "data2" {
Copy link

@bridgecrew bridgecrew bot Nov 19, 2021

Choose a reason for hiding this comment

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

MEDIUM   Visual Editor Policy Demo - S3 has a public-read ACL
    Resource: aws_s3_bucket.data2 | ID: acme_aws_1628101837348

@@ -23,6 +23,31 @@ resource "aws_s3_bucket" "data" {
}
}

resource "aws_s3_bucket" "data2" {
Copy link

@bridgecrew bridgecrew bot Nov 19, 2021

Choose a reason for hiding this comment

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

LOW   Ensure AWS access logging is enabled on S3 buckets
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_S3_13

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.

Copy link

@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 infrastructure configuration errors in this PR ⬇️

@@ -23,6 +23,31 @@ resource "aws_s3_bucket" "data" {
}
}

resource "aws_s3_bucket" "data2" {
Copy link

@prisma-cloud-devsecops prisma-cloud-devsecops bot Nov 19, 2021

Choose a reason for hiding this comment

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

LOW   AWS access logging not enabled on S3 buckets
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_S3_13

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

@@ -23,6 +23,31 @@ resource "aws_s3_bucket" "data" {
}
}

resource "aws_s3_bucket" "data2" {
Copy link

@prisma-cloud-devsecops prisma-cloud-devsecops bot Nov 19, 2021

Choose a reason for hiding this comment

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

LOW   S3 bucket cross-region replication disabled
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_GENERAL_72

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.

versioning {
enabled = "${var.versioning_enabled}"
}
}
Copy link

@prisma-cloud-devsecops prisma-cloud-devsecops bot Nov 19, 2021

Choose a reason for hiding this comment

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

Suggested change
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
HIGH   Data stored in the S3 bucket is not securely encrypted at rest
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_S3_14

Description

SSE helps prevent unauthorized access to S3 buckets. Encrypting and decrypting data at the S3 bucket level is transparent to users when accessing data.

Benchmarks

  • FEDRAMP (MODERATE) SC-28
  • CIS AWS V1.3 2.1.1
  • NIST-800-53 SC-2, AC-17
  • PCI-DSS V3.2 3
  • PCI-DSS V3.2.1 3.4

🎉   Fixed by commit 0440345 - Bridgecrew bot fix for terraform/aws/s3.tf

@@ -23,6 +23,31 @@ resource "aws_s3_bucket" "data" {
}
}

resource "aws_s3_bucket" "data2" {
Copy link

@prisma-cloud-devsecops prisma-cloud-devsecops bot Nov 19, 2021

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.data2 | ID: BC_AWS_NETWORKING_52

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.

versioning {
enabled = "${var.versioning_enabled}"
}
}
Copy link

@prisma-cloud-devsecops prisma-cloud-devsecops bot Nov 19, 2021

Choose a reason for hiding this comment

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

Suggested change
}
sse_algorithm = "aws:kms"
LOW   S3 buckets are not encrypted with KMS
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_GENERAL_56

Description

TBA

🎉   Fixed by commit de13086 - Bridgecrew bot fix for terraform/aws/s3.tf

# bucket does not have access logs
# bucket does not have versioning
bucket = "${local.resource_prefix.value}-data"
acl = "public-read"
Copy link

@prisma-cloud-devsecops prisma-cloud-devsecops bot Nov 19, 2021

Choose a reason for hiding this comment

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

Suggested change
acl = "public-read"
HIGH   Bucket ACL grants READ permission to everyone
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_S3_1

Description

Unprotected S3 buckets are one of the major causes of data theft and intrusions. An S3 bucket that allows **READ** access to everyone can provide attackers the ability to read object data within the bucket, which can lead to the exposure of sensitive data. The only S3 buckets that should be globally accessible for unauthenticated users or for **Any AWS Authenticate Users** are those used for hosting static websites. Bucket ACL helps manage access to S3 bucket data.

We recommend AWS S3 buckets are not publicly accessible for READ actions to protect S3 data from unauthorized users and exposing sensitive data to public access.

Benchmarks

  • NIST-800-53 AC-17

@@ -23,6 +23,31 @@ resource "aws_s3_bucket" "data" {
}
}

resource "aws_s3_bucket" "data2" {
Copy link

@bridgecrew bridgecrew bot Nov 19, 2021

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" "data2" {
HIGH   Ensure AWS S3 object versioning is enabled
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_S3_16

Description

S3 versioning is a managed data backup and recovery service provided by AWS. When enabled it allows users to retrieve and restore previous versions of their buckets.

S3 versioning can be used for data protection and retention scenarios such as recovering objects that have been accidentally/intentionally deleted or overwritten.

Benchmarks

  • PCI-DSS V3.2.1 10.5.3
  • FEDRAMP (MODERATE) CP-10, SI-12
Dependent Resources

Calculating...

🎉   Fixed by commit de13086 - Bridgecrew bot fix for terraform/aws/s3.tf

@mikeurbanski1 mikeurbanski1 changed the title Update s3.tf [AWS code review] Update s3.tf Nov 19, 2021
@@ -23,6 +23,31 @@ resource "aws_s3_bucket" "data" {
}
}

resource "aws_s3_bucket" "data2" {
Copy link

@prisma-cloud-devsecops prisma-cloud-devsecops bot Nov 19, 2021

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" "data2" {
HIGH   AWS S3 object versioning is disabled
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_S3_16
Error in referred variable: variable "versioning_enabled"

Description

S3 versioning is a managed data backup and recovery service provided by AWS. When enabled it allows users to retrieve and restore previous versions of their buckets.

S3 versioning can be used for data protection and retention scenarios such as recovering objects that have been accidentally/intentionally deleted or overwritten.

Benchmarks

  • FEDRAMP (MODERATE) SI-12, CP-10
  • PCI-DSS V3.2.1 10.5.3

🎉   Fixed by commit 9a7393b - Update s3.tf

Copy link

@bridgecrew bridgecrew 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 0440345 - Bridgecrew bot fix for terraform/aws/s3.tf - 2 errors were fixed.

Change details

Error ID Change Path Resource
BC_AWS_S3_16 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2
BC_AWS_S3_14 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2

Copy link

@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 0440345 - Bridgecrew bot fix for terraform/aws/s3.tf - 2 errors were fixed.

Change details

Error ID Change Path Resource
BC_AWS_S3_16 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2
BC_AWS_S3_14 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2

Copy link

@bridgecrew bridgecrew 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 de13086 - Bridgecrew bot fix for terraform/aws/s3.tf - 2 errors were fixed.

Change details

Error ID Change Path Resource
BC_AWS_GENERAL_56 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2
BC_AWS_S3_16 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2

Copy link

@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 de13086 - Bridgecrew bot fix for terraform/aws/s3.tf - 2 errors were fixed.

Change details

Error ID Change Path Resource
BC_AWS_S3_16 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2
BC_AWS_GENERAL_56 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2

Copy link

@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 9a7393b - Update s3.tf - 1 error was fixed.

Change details

Error ID Change Path Resource
BC_AWS_S3_16 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2

metahertz and others added 2 commits March 24, 2022 15:10
Co-authored-by: bridgecrew[bot] <60663194+bridgecrew[bot]@users.noreply.github.com>
Co-authored-by: bridgecrew[bot] <60663194+bridgecrew[bot]@users.noreply.github.com>
@@ -23,6 +23,38 @@ resource "aws_s3_bucket" "data" {
}
}


resource "aws_s3_bucket" "data2" {
Copy link

Choose a reason for hiding this comment

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

LOW   Ensure AWS access logging is enabled on S3 buckets
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_S3_13

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
Dependent Resources

Calculating...

🎉   Fixed by commit 8eef7fb - Update terraform/aws/s3.tf

@@ -23,6 +23,38 @@ resource "aws_s3_bucket" "data" {
}
}


resource "aws_s3_bucket" "data2" {
Copy link

Choose a reason for hiding this comment

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

LOW   Ensure S3 bucket has cross-region replication enabled
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_GENERAL_72

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.

Dependent Resources



Calculating...

🎉   Fixed by commit 8eef7fb - Update terraform/aws/s3.tf

@@ -23,6 +23,38 @@ resource "aws_s3_bucket" "data" {
}
}


resource "aws_s3_bucket" "data2" {
Copy link

Choose a reason for hiding this comment

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

MEDIUM   Visual Editor Policy Demo - S3 has a public-read ACL
    Resource: aws_s3_bucket.data2 | ID: acme_aws_1628101837348
Dependent Resources

Calculating...

🎉   Fixed by commit 8eef7fb - Update terraform/aws/s3.tf

@@ -23,6 +23,38 @@ resource "aws_s3_bucket" "data" {
}
}


resource "aws_s3_bucket" "data2" {
Copy link

Choose a reason for hiding this comment

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

HIGH   PCI check tag exists
    Resource: aws_s3_bucket.data2 | ID: acme_aws_1629787200891
Dependent Resources

Calculating...

🎉   Fixed by commit 8eef7fb - Update terraform/aws/s3.tf

}
versioning {
enabled = "${var.versioning_enabled}"
}
Copy link

Choose a reason for hiding this comment

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

Suggested change
}
HIGH   Ensure AWS S3 object versioning is enabled
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_S3_16

Description

S3 versioning is a managed data backup and recovery service provided by AWS. When enabled it allows users to retrieve and restore previous versions of their buckets.

S3 versioning can be used for data protection and retention scenarios such as recovering objects that have been accidentally/intentionally deleted or overwritten.

Benchmarks

  • PCI-DSS V3.2.1 10.5.3
  • FEDRAMP (MODERATE) CP-10, SI-12
Dependent Resources

Calculating...

🎉   Fixed by commit 8eef7fb - Update terraform/aws/s3.tf

# bucket does not have access logs
# bucket does not have versioning
bucket = "${local.resource_prefix.value}-data"
force_destroy = true
Copy link

Choose a reason for hiding this comment

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

Suggested change
force_destroy = true
CRITICAL   Ensure bucket ACL does not grant READ permission to everyone
    Resource: aws_s3_bucket.data2 | ID: BC_AWS_S3_1

Description

Unprotected S3 buckets are one of the major causes of data theft and intrusions. An S3 bucket that allows **READ** access to everyone can provide attackers the ability to read object data within the bucket, which can lead to the exposure of sensitive data. The only S3 buckets that should be globally accessible for unauthenticated users or for **Any AWS Authenticate Users** are those used for hosting static websites. Bucket ACL helps manage access to S3 bucket data.

We recommend AWS S3 buckets are not publicly accessible for READ actions to protect S3 data from unauthorized users and exposing sensitive data to public access.

Benchmarks

  • NIST-800-53 AC-17
Dependent Resources

Calculating...

🎉   Fixed by commit 8eef7fb - Update terraform/aws/s3.tf

Copy link

@bridgecrew bridgecrew 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 8eef7fb - Update terraform/aws/s3.tf - 6 errors were fixed.

Change details

Error ID Change Path Resource
acme_aws_1628101837348 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2
acme_aws_1629787200891 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2
BC_AWS_GENERAL_72 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2
BC_AWS_S3_1 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2
BC_AWS_S3_13 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2
BC_AWS_S3_16 Fixed /terraform/aws/s3.tf aws_s3_bucket.data2

@schosterbarak schosterbarak changed the title [AWS code review] Update s3.tf Code Review of a new Feature Jul 11, 2023
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