#!/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 Advanced" CHECK_SCORED_extra7168="NOT_SCORED" CHECK_CIS_LEVEL_extra7168="EXTRA" CHECK_SEVERITY_extra7168="Medium" CHECK_ASFF_RESOURCE_TYPE_extra7168="AwsRoute53Domain" CHECK_ALTERNATE_check7168="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 $PROFILE_OPT 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 $AWSCLI $PROFILE_OPT 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 textInfo "$REGION: no Route53 hosted zones found" "$REGION" fi else textInfo "No AWS Shield Advanced subscription found. Skipping check." fi }