From af38286a155cf3337b22212aa2e82ebe8eea4b73 Mon Sep 17 00:00:00 2001 From: Shubham Shah <82979155+ShubhamShah11@users.noreply.github.com> Date: Mon, 20 Sep 2021 17:06:33 -0400 Subject: [PATCH 1/4] Create check_extra7154 --- checks/check_extra7154 | 1 + 1 file changed, 1 insertion(+) create mode 100644 checks/check_extra7154 diff --git a/checks/check_extra7154 b/checks/check_extra7154 new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/checks/check_extra7154 @@ -0,0 +1 @@ + From 7d79532c1ff2d0a91a817c4fdaad14c7df3baa95 Mon Sep 17 00:00:00 2001 From: Shubham Shah <82979155+ShubhamShah11@users.noreply.github.com> Date: Mon, 20 Sep 2021 17:20:13 -0400 Subject: [PATCH 2/4] Adding check_extra7154 --- checks/check_extra7154 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/checks/check_extra7154 b/checks/check_extra7154 index 8b137891..76e5f508 100644 --- a/checks/check_extra7154 +++ b/checks/check_extra7154 @@ -1 +1,35 @@ +#!/usr/bin/env bash + +# Prowler - the handy cloud security tool (copyright 2019) by Toni de la Fuente +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy +# of the License at http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +# CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# +# Remediation: +# +# https://docs.aws.amazon.com/cli/latest/reference/cloudformation/update-termination-protection.html +# +# aws cloudformation update-termination-protection \ +# --stack-name my-stack \ +# --enable-termination-protection + +CHECK_ID_extra7154="7.154" +CHECK_TITLE_extra7154="[extra7154] Enable termination protection for Cloudformation Stacks" +CHECK_SCORED_extra7154="NOT_SCORED" +CHECK_TYPE_extra7154="EXTRA" +CHECK_SEVERITY_extra7154="LOW" +CHECK_ASFF_RESOURCE_TYPE_extra7154="AwsCloudFormationStack" +CHECK_ALTERNATE_check7154="extra7154" +CHECK_SERVICENAME_extra7154="cloudformation" +CHECK_RISK_extra7154='Without termination protection enabled, a critical cloudformation stack can be accidently deleted.' +CHECK_REMEDIATION_extra7154='Ensure termination protection is enabled for the cloudformation stacks' +CHECK_DOC_extra7154='https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-protect-stacks.html' +CHECK_CAF_EPIC_extra7154='Infrastructure Protection' + From c6c730a81e80e9e3789e674b48a82d6e1a3b27b0 Mon Sep 17 00:00:00 2001 From: Shubham Shah <82979155+ShubhamShah11@users.noreply.github.com> Date: Mon, 20 Sep 2021 17:21:19 -0400 Subject: [PATCH 3/4] Update check_extra7154 --- checks/check_extra7154 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks/check_extra7154 b/checks/check_extra7154 index 76e5f508..47206432 100644 --- a/checks/check_extra7154 +++ b/checks/check_extra7154 @@ -23,7 +23,7 @@ CHECK_ID_extra7154="7.154" CHECK_TITLE_extra7154="[extra7154] Enable termination protection for Cloudformation Stacks" CHECK_SCORED_extra7154="NOT_SCORED" CHECK_TYPE_extra7154="EXTRA" -CHECK_SEVERITY_extra7154="LOW" +CHECK_SEVERITY_extra7154="MEDIUM" CHECK_ASFF_RESOURCE_TYPE_extra7154="AwsCloudFormationStack" CHECK_ALTERNATE_check7154="extra7154" CHECK_SERVICENAME_extra7154="cloudformation" From 6201a2a3fbe345535ce12c689c7730635a69aa18 Mon Sep 17 00:00:00 2001 From: Shubham Shah <82979155+ShubhamShah11@users.noreply.github.com> Date: Mon, 20 Sep 2021 19:02:28 -0400 Subject: [PATCH 4/4] Update check_extra7154 --- checks/check_extra7154 | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/checks/check_extra7154 b/checks/check_extra7154 index 47206432..eb571303 100644 --- a/checks/check_extra7154 +++ b/checks/check_extra7154 @@ -32,4 +32,22 @@ CHECK_REMEDIATION_extra7154='Ensure termination protection is enabled for the cl CHECK_DOC_extra7154='https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-protect-stacks.html' CHECK_CAF_EPIC_extra7154='Infrastructure Protection' - +extra7154() { + for regx in $REGIONS; do + CFN_STACKS=$($AWSCLI cloudformation describe-stacks $PROFILE_OPT --region $regx --output json) + LIST_OF_CFN_STACKS=$(echo $CFN_STACKS | jq -r '.Stacks[].StackName') + if [[ $LIST_OF_CFN_STACKS ]];then + for stack in $LIST_OF_CFN_STACKS; do + CFN_STACK_DETAILS=$($AWSCLI cloudformation describe-stacks $PROFILE_OPT --region $regx --stack-name $stack --output json) + TERMINATION_ENABLED=echo $CFN_STACK_DETAILS | jq -r '.Stacks[] | select( .EnableTerminationProtection == true )' + if [[ $TERMINATION_ENABLED ]]; then + textPass "$regx: Cloudformation stack $stack has termination protection enabled" "$regx" "$stack" + else + textFail "$regx: Cloudformation stack $stack has termination protection disabled" "$regx" "$stack" + fi + done + else + textInfo "$regx: No Cloudformation stacks found" "$regx" + fi + done +}