Skip to content

fix: Require all requests to S3 Bucket to be SSL (PCI.S3.5) and enable encryption at rest (PCI.S3.4) #149

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

Merged
merged 6 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ jobs:
- name: Install pre-commit dependencies
run: |
pip install pre-commit
go install github.com/hashicorp/terraform-config-inspect@latest
make deps

- name: Execute generate-terraform-providers for organizational
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
deps:
go install github.com/terraform-docs/[email protected]
go install github.com/hashicorp/terraform-config-inspect@latest
curl -L "`curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip"`" -o tflint.zip && \
curl -L https://github.com/terraform-linters/tflint/releases/download/v0.43.0/tflint_linux_amd64.zip -o tflint.zip && \
unzip tflint.zip && \
rm tflint.zip && \
mv tflint "`go env GOPATH`/bin"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ A: For Organizational Setup for cloudbench (deployed through management account

### Q-RuntimeThreat Detection: Getting error 403 `"could not load rule set from Sysdig Secure: ruleprovider#newPartialRuleSet | error loading default-rules: error from Sysdig Secure API: 403`

A: The Sysdig User that deployed the components is a standard user within the Sysdig Platform. Only administrator users are given permissions to read falco rule sets. Once this permission is changed, you should no longer get this error and CSPM Cloud events should start populating.
A: The Sysdig User that deployed the components is a standard user within the Sysdig Platform. Only administrator users are given permissions to read falco rule sets. Once this permission is changed, you should no longer get this error and CSPM Cloud events should start populating.

<br/><br/>

Expand Down
1 change: 1 addition & 0 deletions modules/infrastructure/cloudtrail/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ No modules.
| [aws_s3_bucket_lifecycle_configuration.cloudtrail](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_lifecycle_configuration) | resource |
| [aws_s3_bucket_policy.cloudtrail_s3](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource |
| [aws_s3_bucket_public_access_block.cloudtrail](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
| [aws_s3_bucket_server_side_encryption_configuration.cloudtrail](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_server_side_encryption_configuration) | resource |
| [aws_sns_topic.cloudtrail](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic) | resource |
| [aws_sns_topic_policy.allow_cloudtrail_publish](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_policy) | resource |
| [aws_caller_identity.me](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
Expand Down
38 changes: 33 additions & 5 deletions modules/infrastructure/cloudtrail/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ resource "aws_s3_bucket" "cloudtrail" {
tags = var.tags
}

resource "aws_s3_bucket_server_side_encryption_configuration" "cloudtrail" {
bucket = aws_s3_bucket.cloudtrail.id
rule {

apply_server_side_encryption_by_default {
sse_algorithm = var.cloudtrail_kms_enable ? "aws:kms" : "AES256"
kms_master_key_id = var.cloudtrail_kms_enable ? aws_kms_key.cloudtrail_kms[0].id : null
}
}
}

resource "aws_s3_bucket_lifecycle_configuration" "cloudtrail" {
bucket = aws_s3_bucket.cloudtrail.id

Expand Down Expand Up @@ -39,18 +50,16 @@ resource "aws_s3_bucket_public_access_block" "cloudtrail" {
block_public_policy = true
ignore_public_acls = true
restrict_public_buckets = true
depends_on = [aws_s3_bucket_policy.cloudtrail_s3] # https://github.com/hashicorp/terraform-provider-aws/issues/7628
depends_on = [aws_s3_bucket_policy.cloudtrail_s3]
# https://github.com/hashicorp/terraform-provider-aws/issues/7628
}



resource "aws_s3_bucket_policy" "cloudtrail_s3" {
bucket = aws_s3_bucket.cloudtrail.id
policy = data.aws_iam_policy_document.cloudtrail_s3.json
}
data "aws_iam_policy_document" "cloudtrail_s3" {

# begin. required policies as requested in aws_cloudtrail resource documentation
statement {
sid = "AWSCloudTrailAclCheck"
effect = "Allow"
Expand All @@ -77,5 +86,24 @@ data "aws_iam_policy_document" "cloudtrail_s3" {
}
resources = ["${aws_s3_bucket.cloudtrail.arn}/AWSLogs/*"]
}
# end

# S3 buckets should require requests to use Secure Socket Layer
# [PCI.S3.5] This AWS control checks whether S3 buckets have policies that require requests to use Secure Socket Layer (SSL).
statement {
principals {
identifiers = ["*"]
type = "AWS"
}
actions = ["s3:*"]
resources = [
aws_s3_bucket.cloudtrail.arn,
"${aws_s3_bucket.cloudtrail.arn}/*"
]
effect = "Deny"
condition {
test = "Bool"
variable = "aws:SecureTransport"
values = ["false"]
}
}
}