From 122e1c0cf8b36a43d93e79ff2ceaf85336e534ff Mon Sep 17 00:00:00 2001 From: Michael Dickinson <45626543+michael-dickinson-sainsburys@users.noreply.github.com> Date: Thu, 23 Dec 2021 13:08:12 +0000 Subject: [PATCH] New check 7168 Route53 hosted zones are protected by AWS Shield Advanced --- checks/check_extra7168 | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 checks/check_extra7168 diff --git a/checks/check_extra7168 b/checks/check_extra7168 new file mode 100644 index 0000000000..67f9901235 --- /dev/null +++ b/checks/check_extra7168 @@ -0,0 +1,49 @@ +#!/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_extra7168="7.168" +CHECK_TITLE_extra7168="[extra7168] Check if Route53 hosted zones are protected by AWS Shield" +CHECK_SCORED_extra7168="NOT_SCORED" +CHECK_CIS_LEVEL_extra7168="EXTRA" +CHECK_SEVERITY_check="Medium" +CHECK_ASFF_RESOURCE_TYPE_extra7168="AwsRoute53Domain" +CHECK_ALTERNATE_extra7168="extra7168" +CHECK_SERVICENAME_extra7168="shield" +CHECK_RISK_extra7168='AWS Shield Advanced provides expanded DDoS attack protection for your resources' +CHECK_REMEDIATION_extra7168='Add as a protected resource in AWS Shield Advanced.' +CHECK_DOC_extra7168='https://docs.aws.amazon.com/waf/latest/developerguide/configure-new-protection.html' +CHECK_CAF_EPIC_extra7168='Infrastructure security' + +extra7168() { + if [[ "$($AWSCLI shield get-subscription-state --output text)" == "ACTIVE" ]]; then + CALLER_IDENTITY=$($AWSCLI sts get-caller-identity $PROFILE_OPT --query Arn) + PARTITION=$(echo $CALLER_IDENTITY | cut -d: -f2) + LIST_OF_ROUTE53_HOSTED_ZONES=$($AWSCLI route53 list-hosted-zones $PROFILE_OPT --query 'HostedZones[*].[Id,Name]' --output text) + if [[ $LIST_OF_ROUTE53_HOSTED_ZONES ]]; then + while read -r hosted_zone; do + HOSTED_ZONE_ID=$(echo $hosted_zone | awk '{ print $1; }') + HOSTED_ZONE_NAME=$(echo $hosted_zone | awk '{ print $2; }') + HOSTED_ZONE_ARN="arn:${PARTITION}:route53:::${HOSTED_ZONE_ID:1}" + if aws shield describe-protection --resource-arn $HOSTED_ZONE_ARN >/dev/null 2>&1; then + textPass "$REGION: Route53 Hosted Zone $HOSTED_ZONE_NAME is protected by AWS Shield Advanced" "$REGION" "$HOSTED_ZONE_NAME" + else + textFail "$REGION: Route53 Hosted Zone $HOSTED_ZONE_NAME is not protected by AWS Shield Advanced" "$REGION" "$HOSTED_ZONE_NAME" + fi + done <<<"$LIST_OF_ROUTE53_HOSTED_ZONES" + else + textPass "$REGION: no Route53 hosted zones found" "$REGION" + fi + else + textInfo "No AWS Shield Advanced subscription found. Skipping check." + fi +}