From 8a71f15f8628d9155cc84735f8139abe269c8c27 Mon Sep 17 00:00:00 2001 From: sanaayousaf Date: Fri, 25 Nov 2022 11:58:36 +0000 Subject: [PATCH 1/5] added policy to check domain encryption added or not for elasticsearch --- .../aws/elasticsearch/AVD-AWS-0199/docs.md | 13 ++++++++++ .../kubernetes/general/AVD-KSV-01010/docs.md | 2 +- .../kubernetes/general/AVD-KSV-0108/docs.md | 4 +-- .../kubernetes/general/AVD-KSV-0109/docs.md | 2 +- .../enable_domain_encryption.rego | 25 +++++++++++++++++++ .../enable_domain_encryption_test.rego | 11 ++++++++ 6 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 avd_docs/aws/elasticsearch/AVD-AWS-0199/docs.md create mode 100644 internal/rules/policies/cloud/policies/aws/elasticsearch/enable_domain_encryption.rego create mode 100644 internal/rules/policies/cloud/policies/aws/elasticsearch/enable_domain_encryption_test.rego diff --git a/avd_docs/aws/elasticsearch/AVD-AWS-0199/docs.md b/avd_docs/aws/elasticsearch/AVD-AWS-0199/docs.md new file mode 100644 index 000000000..bc2e8c2aa --- /dev/null +++ b/avd_docs/aws/elasticsearch/AVD-AWS-0199/docs.md @@ -0,0 +1,13 @@ + +Elasticsearch domain isn't encrypted at rest. + +### Impact + + + +{{ remediationActions }} + +### Links +- https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/encryption-at-rest.html + + 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-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/elasticsearch/enable_domain_encryption.rego b/internal/rules/policies/cloud/policies/aws/elasticsearch/enable_domain_encryption.rego new file mode 100644 index 000000000..6e9eb1b30 --- /dev/null +++ b/internal/rules/policies/cloud/policies/aws/elasticsearch/enable_domain_encryption.rego @@ -0,0 +1,25 @@ +# METADATA +# title: "Elasticsearch Domain Encryption" +# description: "Elasticsearch domain isn't encrypted at rest." +# scope: package +# schemas: +# - input: schema.input +# related_resources: +# - https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/encryption-at-rest.html +# custom: +# avd_id: AVD-AWS-0199 +# provider: aws +# service: elasticsearch +# severity: HIGH +# short_code: enable-domain-encryption +# recommended_action: "You should ensure your Elasticsearch data is encrypted at rest to help prevent sensitive information from being read by unauthorised users." +# input: +# selector: +# - type: cloud +package builtin.aws.elasticsearch.aws0199 + +deny[res] { + domain := input.aws.elasticsearch.domains[_] + not domain.atrestencryption.enabled.value + res := result.new("Domain does not have at-rest encryption enabled.", domain.atrestencryption.enabled) +} diff --git a/internal/rules/policies/cloud/policies/aws/elasticsearch/enable_domain_encryption_test.rego b/internal/rules/policies/cloud/policies/aws/elasticsearch/enable_domain_encryption_test.rego new file mode 100644 index 000000000..3b6d75b94 --- /dev/null +++ b/internal/rules/policies/cloud/policies/aws/elasticsearch/enable_domain_encryption_test.rego @@ -0,0 +1,11 @@ +package builtin.aws.elasticsearch.aws0199 + +test_detects_when_disabled { + r := deny with input as {"aws": {"elasticsearch": {"domains": [{"atrestencryption": {"enabled": {"value": false}}}]}}} + count(r) == 1 +} + +test_when_enabled { + r := deny with input as {"aws": {"elasticsearch": {"domains": [{"atrestencryption": {"enabled": {"value": true}}}]}}} + count(r) == 0 +} From 939d734696b937f892d1ace8b3a35bd1c6d0845b Mon Sep 17 00:00:00 2001 From: SanaYousaf <78966921+SanaaYousaf@users.noreply.github.com> Date: Fri, 25 Nov 2022 14:31:08 +0000 Subject: [PATCH 2/5] 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 4bf80dea9108cddc06f471d24407c01af8591cb4 Mon Sep 17 00:00:00 2001 From: SanaYousaf <78966921+SanaaYousaf@users.noreply.github.com> Date: Fri, 25 Nov 2022 14:31:41 +0000 Subject: [PATCH 3/5] 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 096178650e91b4ea9700f04ac9b85ba40591efe2 Mon Sep 17 00:00:00 2001 From: SanaYousaf <78966921+SanaaYousaf@users.noreply.github.com> Date: Fri, 25 Nov 2022 14:32:09 +0000 Subject: [PATCH 4/5] 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 559bcbcfed8faebb2ab85bb0209cca59a46d270f Mon Sep 17 00:00:00 2001 From: SanaYousaf <78966921+SanaaYousaf@users.noreply.github.com> Date: Fri, 25 Nov 2022 14:32:32 +0000 Subject: [PATCH 5/5] 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 }}