From f4990b498e69237d7aff99ddbcdcbcfe5470be86 Mon Sep 17 00:00:00 2001 From: sanaayousaf Date: Mon, 21 Nov 2022 07:27:15 +0000 Subject: [PATCH 1/7] added policy to check cloudwatch_integration for cloudtrail --- avd_docs/aws/cloudtrail/AVD-AWS-0182/docs.md | 13 ++++++++++ .../kubernetes/general/AVD-KSV-01010/docs.md | 2 +- .../kubernetes/general/AVD-KSV-0107/docs.md | 5 +++- .../kubernetes/general/AVD-KSV-0108/docs.md | 4 +-- .../kubernetes/general/AVD-KSV-0109/docs.md | 2 +- .../ensure_cloudwatch_integration.rego | 25 +++++++++++++++++++ .../ensure_cloudwatch_integration_test.rego | 11 ++++++++ 7 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 avd_docs/aws/cloudtrail/AVD-AWS-0182/docs.md create mode 100644 internal/rules/policies/cloud/policies/aws/cloudtrail/ensure_cloudwatch_integration.rego create mode 100644 internal/rules/policies/cloud/policies/aws/cloudtrail/ensure_cloudwatch_integration_test.rego diff --git a/avd_docs/aws/cloudtrail/AVD-AWS-0182/docs.md b/avd_docs/aws/cloudtrail/AVD-AWS-0182/docs.md new file mode 100644 index 000000000..c364854c3 --- /dev/null +++ b/avd_docs/aws/cloudtrail/AVD-AWS-0182/docs.md @@ -0,0 +1,13 @@ + +Ensures CloudTrail logs are being properly delivered to CloudWatch + +### Impact + + + +{{ remediationActions }} + +### Links +- https://docs.aws.amazon.com/awscloudtrail/latest/userguide/send-cloudtrail-events-to-cloudwatch-logs.html#send-cloudtrail-events-to-cloudwatch-logs-console + + diff --git a/avd_docs/kubernetes/general/AVD-KSV-01010/docs.md b/avd_docs/kubernetes/general/AVD-KSV-01010/docs.md index 1cee68f20..f69f12cad 100644 --- a/avd_docs/kubernetes/general/AVD-KSV-01010/docs.md +++ b/avd_docs/kubernetes/general/AVD-KSV-01010/docs.md @@ -2,7 +2,7 @@ Storing sensitive content such as usernames and email addresses in configMaps is unsafe ### Impact -Unsafe storage of sensitive content in configMaps could lead to the information being compromised. + {{ remediationActions }} diff --git a/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md b/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md index e8258523c..6af76b2a2 100644 --- a/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md +++ b/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md @@ -1,5 +1,5 @@ -apiVersion and kind has been deprecated +apiVersion '' and kind '' has been deprecated on: '' and planned for removal on:'' ### Impact @@ -7,4 +7,7 @@ apiVersion and kind has been deprecated {{ remediationActions }} +### Links +- + diff --git a/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md b/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md index 8d55a3498..9c1e77234 100644 --- a/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md +++ b/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md @@ -2,8 +2,8 @@ Services with external IP addresses allows direct access from the internet and might expose risk for CVE-2020-8554 ### Impact -Kubernetes API server in all versions allow an attacker who is able to create a ClusterIP service and set the spec.externalIPs field, to intercept traffic to that IP address. Additionally, an attacker who is able to patch the status (which is considered a privileged operation and should not typically be granted to users) of a LoadBalancer service can set the status.loadBalancer.ingress.ip to similar effect. -https://www.cvedetails.com/cve/CVE-2020-8554/ + + {{ remediationActions }} diff --git a/avd_docs/kubernetes/general/AVD-KSV-0109/docs.md b/avd_docs/kubernetes/general/AVD-KSV-0109/docs.md index d215353f0..70bba0fb1 100644 --- a/avd_docs/kubernetes/general/AVD-KSV-0109/docs.md +++ b/avd_docs/kubernetes/general/AVD-KSV-0109/docs.md @@ -2,7 +2,7 @@ Storing secrets in configMaps is unsafe ### Impact -Unsafe storage of secret content in configMaps could lead to the information being compromised. + {{ remediationActions }} diff --git a/internal/rules/policies/cloud/policies/aws/cloudtrail/ensure_cloudwatch_integration.rego b/internal/rules/policies/cloud/policies/aws/cloudtrail/ensure_cloudwatch_integration.rego new file mode 100644 index 000000000..f4d63ae2e --- /dev/null +++ b/internal/rules/policies/cloud/policies/aws/cloudtrail/ensure_cloudwatch_integration.rego @@ -0,0 +1,25 @@ +# METADATA +# title: "CloudTrail To CloudWatch" +# description: "Ensures CloudTrail logs are being properly delivered to CloudWatch" +# scope: package +# schemas: +# - input: schema.input +# related_resources: +# - https://docs.aws.amazon.com/awscloudtrail/latest/userguide/send-cloudtrail-events-to-cloudwatch-logs.html#send-cloudtrail-events-to-cloudwatch-logs-console +# custom: +# avd_id: AVD-AWS-0182 +# provider: aws +# service: cloudtrail +# severity: LOW +# short_code: ensure-cloudwatch-integration +# recommended_action: "Enable CloudTrail CloudWatch integration for all regions" +# input: +# selector: +# - type: cloud +package builtin.aws.cloudtrail.aws0182 + +deny[res] { + trail := input.aws.cloudtrail.trails[_] + trail.cloudwatchlogsloggrouparn.value == "" + res := result.new("Trail does not have CloudWatch logging configured", trail.cloudwatchlogsloggrouparn) +} diff --git a/internal/rules/policies/cloud/policies/aws/cloudtrail/ensure_cloudwatch_integration_test.rego b/internal/rules/policies/cloud/policies/aws/cloudtrail/ensure_cloudwatch_integration_test.rego new file mode 100644 index 000000000..50a191496 --- /dev/null +++ b/internal/rules/policies/cloud/policies/aws/cloudtrail/ensure_cloudwatch_integration_test.rego @@ -0,0 +1,11 @@ +package builtin.aws.cloudtrail.aws0182 + +test_detects_when_not_configured { + r := deny with input as {"aws": {"cloudtrail": {"trails": [{"cloudwatchlogsloggrouparn": {"value": ""}}]}}} + count(r) == 1 +} + +test_when_configured { + r := deny with input as {"aws": {"cloudtrail": {"trails": [{"cloudwatchlogsloggrouparn": {"value": "arn:aws:logs:us-east-1:123456789012:log-group:my-log-group"}}]}}} + count(r) == 0 +} From d4962fa59dae88326467eb41c0efc64006c7b264 Mon Sep 17 00:00:00 2001 From: SanaYousaf <78966921+SanaaYousaf@users.noreply.github.com> Date: Fri, 25 Nov 2022 13:41:04 +0000 Subject: [PATCH 2/7] Update avd_docs/kubernetes/general/AVD-KSV-01010/docs.md --- avd_docs/kubernetes/general/AVD-KSV-01010/docs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avd_docs/kubernetes/general/AVD-KSV-01010/docs.md b/avd_docs/kubernetes/general/AVD-KSV-01010/docs.md index f69f12cad..1cee68f20 100644 --- a/avd_docs/kubernetes/general/AVD-KSV-01010/docs.md +++ b/avd_docs/kubernetes/general/AVD-KSV-01010/docs.md @@ -2,7 +2,7 @@ Storing sensitive content such as usernames and email addresses in configMaps is unsafe ### Impact - +Unsafe storage of sensitive content in configMaps could lead to the information being compromised. {{ remediationActions }} From 71b606102cbddfed6a4c3c3c1df52a2ff3dd6fdf Mon Sep 17 00:00:00 2001 From: SanaYousaf <78966921+SanaaYousaf@users.noreply.github.com> Date: Fri, 25 Nov 2022 13:41:46 +0000 Subject: [PATCH 3/7] Update avd_docs/kubernetes/general/AVD-KSV-0107/docs.md --- avd_docs/kubernetes/general/AVD-KSV-0107/docs.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md b/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md index 6af76b2a2..ff069441c 100644 --- a/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md +++ b/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md @@ -7,7 +7,4 @@ apiVersion '' and kind '' has been deprecated on: '' and planned for removal on: {{ remediationActions }} -### Links -- - From 1fe216ed303b18c65f590c67cfccd8c4906fcb3c Mon Sep 17 00:00:00 2001 From: SanaYousaf <78966921+SanaaYousaf@users.noreply.github.com> Date: Fri, 25 Nov 2022 13:42:23 +0000 Subject: [PATCH 4/7] Update avd_docs/kubernetes/general/AVD-KSV-0107/docs.md --- avd_docs/kubernetes/general/AVD-KSV-0107/docs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md b/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md index ff069441c..e8258523c 100644 --- a/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md +++ b/avd_docs/kubernetes/general/AVD-KSV-0107/docs.md @@ -1,5 +1,5 @@ -apiVersion '' and kind '' has been deprecated on: '' and planned for removal on:'' +apiVersion and kind has been deprecated ### Impact From 58b6ee64e113565759807d6731ed0007ac43d723 Mon Sep 17 00:00:00 2001 From: SanaYousaf <78966921+SanaaYousaf@users.noreply.github.com> Date: Fri, 25 Nov 2022 13:43:05 +0000 Subject: [PATCH 5/7] Update avd_docs/kubernetes/general/AVD-KSV-0109/docs.md --- avd_docs/kubernetes/general/AVD-KSV-0109/docs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avd_docs/kubernetes/general/AVD-KSV-0109/docs.md b/avd_docs/kubernetes/general/AVD-KSV-0109/docs.md index 70bba0fb1..d215353f0 100644 --- a/avd_docs/kubernetes/general/AVD-KSV-0109/docs.md +++ b/avd_docs/kubernetes/general/AVD-KSV-0109/docs.md @@ -2,7 +2,7 @@ Storing secrets in configMaps is unsafe ### Impact - +Unsafe storage of secret content in configMaps could lead to the information being compromised. {{ remediationActions }} From 2144e0ed69ef03545fa2c21c55dd64bece29b7cc Mon Sep 17 00:00:00 2001 From: SanaYousaf <78966921+SanaaYousaf@users.noreply.github.com> Date: Fri, 25 Nov 2022 13:43:52 +0000 Subject: [PATCH 6/7] Update avd_docs/kubernetes/general/AVD-KSV-0108/docs.md --- avd_docs/kubernetes/general/AVD-KSV-0108/docs.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md b/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md index 9c1e77234..58feb86a3 100644 --- a/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md +++ b/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md @@ -2,7 +2,8 @@ Services with external IP addresses allows direct access from the internet and might expose risk for CVE-2020-8554 ### Impact - +Kubernetes API server in all versions allow an attacker who is able to create a ClusterIP service and set the spec.externalIPs field, to intercept traffic to that IP address. Additionally, an attacker who is able to patch the status (which is considered a privileged operation and should not typically be granted to users) of a LoadBalancer service can set the status.loadBalancer.ingress.ip to similar effect. +https://www.cvedetails.com/cve/CVE-2020-8554/ {{ remediationActions }} From a436816f3465ba55845d115fdec0579750cb244e Mon Sep 17 00:00:00 2001 From: SanaYousaf <78966921+SanaaYousaf@users.noreply.github.com> Date: Fri, 25 Nov 2022 13:44:12 +0000 Subject: [PATCH 7/7] Update avd_docs/kubernetes/general/AVD-KSV-0108/docs.md --- avd_docs/kubernetes/general/AVD-KSV-0108/docs.md | 1 - 1 file changed, 1 deletion(-) diff --git a/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md b/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md index 58feb86a3..8d55a3498 100644 --- a/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md +++ b/avd_docs/kubernetes/general/AVD-KSV-0108/docs.md @@ -4,7 +4,6 @@ Services with external IP addresses allows direct access from the internet and m ### Impact Kubernetes API server in all versions allow an attacker who is able to create a ClusterIP service and set the spec.externalIPs field, to intercept traffic to that IP address. Additionally, an attacker who is able to patch the status (which is considered a privileged operation and should not typically be granted to users) of a LoadBalancer service can set the status.loadBalancer.ingress.ip to similar effect. https://www.cvedetails.com/cve/CVE-2020-8554/ - {{ remediationActions }}