From ee5ae4fc5e44f291d19010e67dd479c49702cb87 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Wed, 15 Sep 2021 20:38:24 +0000 Subject: [PATCH 1/4] Check if DynamoDB tables point-in-time recovery (PITR) is enabled. --- checks/check_extra7151 | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 checks/check_extra7151 diff --git a/checks/check_extra7151 b/checks/check_extra7151 new file mode 100644 index 00000000..433a07a2 --- /dev/null +++ b/checks/check_extra7151 @@ -0,0 +1,44 @@ +#!/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. + +CHECK_ID_extra7151="7.151" +CHECK_TITLE_extra7151="[extra7151] Check if DynamoDB tables point-in-time recovery (PITR) is enabled." +CHECK_SCORED_extra7151="NOT_SCORED" +CHECK_TYPE_extra7151="EXTRA" +CHECK_SEVERITY_extra7151="Medium" +CHECK_ASFF_RESOURCE_TYPE_extra7151="AwsDynamoDbTable" +CHECK_ALTERNATE_check7151="extra7151" +CHECK_SERVICENAME_extra7151="dynamodb" +CHECK_RISK_extra7151='If the DynamoDB Table does not have point-in-time recovery enabled, it is vulnerable to accidental write or delete operations.' +CHECK_REMEDIATION_extra7151='Enable point-in-time recovery; this is not enabled by default.' +CHECK_DOC_extra7151='https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/PointInTimeRecovery_Howitworks.html' +CHECK_CAF_EPIC_extra7151='Data Protection' + +extra7151(){ + # "Check if DynamoDB tables point-in-time recovery (PITR) is enabled" + for regx in $REGIONS; do + LIST_OF_DYNAMODB_TABLES=$($AWSCLI dynamodb list-tables $PROFILE_OPT --region $regx --query 'TableNames[*]' --output text|xargs -n1) + if [[ $LIST_OF_DYNAMODB_TABLES ]]; then + for dynamodb_table in $LIST_OF_DYNAMODB_TABLES; do + POINT_IN_TIME_RECOVERY_ENABLED=$($AWSCLI dynamodb describe-continuous-backups $PROFILE_OPT --region $regx --table-name $dynamodb_table | jq '.[].PointInTimeRecoveryDescription | select(.PointInTimeRecoveryStatus=="ENABLED")') + if [[ $POINT_IN_TIME_RECOVERY_ENABLED ]]; then + textPass "$regx: $dynamodb_table has point-in-time recovery enabled" "$regx" "$dynamodb_table" + else + textFail "$regx: $dynamodb_table does not have point-in-time recovery enabled." "$regx" "$dynamodb_table" + fi + done + else + textInfo "$regx: No DynamoDB tables found" "$regx" + fi + done +} From 9d76ba0c7bcea5f61e252fa6585391173fc0cbc2 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Thu, 16 Sep 2021 13:29:06 +0000 Subject: [PATCH 2/4] Removed xargs from line 30, not needed. Tested code against resources. --- checks/check_extra7151 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checks/check_extra7151 b/checks/check_extra7151 index 433a07a2..7e58ac96 100644 --- a/checks/check_extra7151 +++ b/checks/check_extra7151 @@ -27,12 +27,12 @@ CHECK_CAF_EPIC_extra7151='Data Protection' extra7151(){ # "Check if DynamoDB tables point-in-time recovery (PITR) is enabled" for regx in $REGIONS; do - LIST_OF_DYNAMODB_TABLES=$($AWSCLI dynamodb list-tables $PROFILE_OPT --region $regx --query 'TableNames[*]' --output text|xargs -n1) + LIST_OF_DYNAMODB_TABLES=$($AWSCLI dynamodb list-tables $PROFILE_OPT --region $regx --query 'TableNames[*]' --output text) if [[ $LIST_OF_DYNAMODB_TABLES ]]; then for dynamodb_table in $LIST_OF_DYNAMODB_TABLES; do POINT_IN_TIME_RECOVERY_ENABLED=$($AWSCLI dynamodb describe-continuous-backups $PROFILE_OPT --region $regx --table-name $dynamodb_table | jq '.[].PointInTimeRecoveryDescription | select(.PointInTimeRecoveryStatus=="ENABLED")') if [[ $POINT_IN_TIME_RECOVERY_ENABLED ]]; then - textPass "$regx: $dynamodb_table has point-in-time recovery enabled" "$regx" "$dynamodb_table" + textPass "$regx: $dynamodb_table has point-in-time recovery enabled." "$regx" "$dynamodb_table" else textFail "$regx: $dynamodb_table does not have point-in-time recovery enabled." "$regx" "$dynamodb_table" fi From cff8f4a8d22d1153efc98c6d3cf44a5e8f987be8 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Tue, 28 Sep 2021 18:54:33 +0000 Subject: [PATCH 3/4] variable ends with just the value of key 'PointInTimeRecoveryStatus' if it is ENABLED. --- checks/check_extra7151 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checks/check_extra7151 b/checks/check_extra7151 index 7e58ac96..0d04a75a 100644 --- a/checks/check_extra7151 +++ b/checks/check_extra7151 @@ -30,11 +30,11 @@ extra7151(){ LIST_OF_DYNAMODB_TABLES=$($AWSCLI dynamodb list-tables $PROFILE_OPT --region $regx --query 'TableNames[*]' --output text) if [[ $LIST_OF_DYNAMODB_TABLES ]]; then for dynamodb_table in $LIST_OF_DYNAMODB_TABLES; do - POINT_IN_TIME_RECOVERY_ENABLED=$($AWSCLI dynamodb describe-continuous-backups $PROFILE_OPT --region $regx --table-name $dynamodb_table | jq '.[].PointInTimeRecoveryDescription | select(.PointInTimeRecoveryStatus=="ENABLED")') + POINT_IN_TIME_RECOVERY_ENABLED=$($AWSCLI dynamodb describe-continuous-backups $PROFILE_OPT --region $regx --table-name $dynamodb_table | jq '.[].PointInTimeRecoveryDescription | select(.PointInTimeRecoveryStatus=="ENABLED") | .PointInTimeRecoveryStatus') if [[ $POINT_IN_TIME_RECOVERY_ENABLED ]]; then textPass "$regx: $dynamodb_table has point-in-time recovery enabled." "$regx" "$dynamodb_table" else - textFail "$regx: $dynamodb_table does not have point-in-time recovery enabled." "$regx" "$dynamodb_table" + textFail "$regx: $dynamodb_table does not have point-in-time recovery enabled." "$regx" "$dynamodb_table" fi done else From babbf065deafa8faa7f283b04591ca1f1bf25c97 Mon Sep 17 00:00:00 2001 From: EC2 Default User Date: Fri, 1 Oct 2021 15:21:02 +0000 Subject: [PATCH 4/4] Changed ',' with ';' in variables --- checks/check_extra7151 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks/check_extra7151 b/checks/check_extra7151 index 0d04a75a..d680b971 100644 --- a/checks/check_extra7151 +++ b/checks/check_extra7151 @@ -19,7 +19,7 @@ CHECK_SEVERITY_extra7151="Medium" CHECK_ASFF_RESOURCE_TYPE_extra7151="AwsDynamoDbTable" CHECK_ALTERNATE_check7151="extra7151" CHECK_SERVICENAME_extra7151="dynamodb" -CHECK_RISK_extra7151='If the DynamoDB Table does not have point-in-time recovery enabled, it is vulnerable to accidental write or delete operations.' +CHECK_RISK_extra7151='If the DynamoDB Table does not have point-in-time recovery enabled; it is vulnerable to accidental write or delete operations.' CHECK_REMEDIATION_extra7151='Enable point-in-time recovery; this is not enabled by default.' CHECK_DOC_extra7151='https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/PointInTimeRecovery_Howitworks.html' CHECK_CAF_EPIC_extra7151='Data Protection'