diff --git a/checks/check_extra745 b/checks/check_extra745 index f6e6fe8bdf..5470391f6f 100644 --- a/checks/check_extra745 +++ b/checks/check_extra745 @@ -18,23 +18,29 @@ CHECK_SEVERITY_extra745="Medium" CHECK_ASFF_RESOURCE_TYPE_extra745="AwsApiGatewayRestApi" CHECK_ALTERNATE_check745="extra745" CHECK_SERVICENAME_extra745="apigateway" -CHECK_RISK_extra745='If accessible from internet without restrictions opens up attack / abuse surface for any malicious user.' -CHECK_REMEDIATION_extra745='Verify that any public Api Gateway is protected and audited. Detective controls for common risks should be implemented.' +CHECK_RISK_extra745='If accessible from internet opens up attack / abuse surface for any malicious user.' +CHECK_REMEDIATION_extra745='Make Api Gateway private if a public endpoint is not necessary. Detective controls for common risks should be implemented.' CHECK_DOC_extra745='https://d1.awsstatic.com/whitepapers/api-gateway-security.pdf?svrd_sip6' CHECK_CAF_EPIC_extra745='Infrastructure Security' extra745(){ for regx in $REGIONS; do - LIST_OF_REST_APIS=$($AWSCLI $PROFILE_OPT --region $regx apigateway get-rest-apis --query 'items[*].id' --output text 2>&1) - if [[ $(echo "$LIST_OF_REST_APIS" | grep -E 'AccessDenied|UnauthorizedOperation|AuthorizationError') ]]; then + LIST_OF_REST_APIS=$("$AWSCLI" $PROFILE_OPT --region "$regx" apigateway get-rest-apis --query 'items[*].id' --output text 2>&1) + if grep -q -E 'AccessDenied|UnauthorizedOperation|AuthorizationError' <<< "$LIST_OF_REST_APIS"; then textInfo "$regx: Access Denied trying to get rest APIs" "$regx" continue fi if [[ $LIST_OF_REST_APIS ]];then for api in $LIST_OF_REST_APIS; do - API_GW_NAME=$($AWSCLI apigateway get-rest-apis $PROFILE_OPT --region $regx --query "items[?id==\`$api\`].name" --output text) - ENDPOINT_CONFIG_TYPE=$($AWSCLI $PROFILE_OPT --region $regx apigateway get-rest-api --rest-api-id $api --query endpointConfiguration.types --output text) - if [[ $ENDPOINT_CONFIG_TYPE ]]; then + API_GW_NAME=$("$AWSCLI" apigateway get-rest-apis $PROFILE_OPT --region $regx --query "items[?id==\`$api\`].name" --output text) + ENDPOINT_CONFIG_TYPE=$("$AWSCLI" $PROFILE_OPT --region "$regx" apigateway get-rest-api --rest-api-id "$api" --query endpointConfiguration.types --output text) + if grep -q -E 'AccessDenied|UnauthorizedOperation|AuthorizationError' <<< "$API_GW_NAME"; then + textInfo "$regx: Access Denied trying to get rest APIs" "$regx" + continue + elif grep -q -E 'AccessDenied|UnauthorizedOperation|AuthorizationError' <<< "$ENDPOINT_CONFIG_TYPE"; then + textInfo "$regx: Access Denied trying to get rest APIs" "$regx" + continue + elif [[ $ENDPOINT_CONFIG_TYPE ]]; then case $ENDPOINT_CONFIG_TYPE in PRIVATE ) textPass "$regx: API Gateway $API_GW_NAME ID $api is set as $ENDPOINT_CONFIG_TYPE" "$regx" "$API_GW_NAME" diff --git a/iam/prowler-additions-policy.json b/iam/prowler-additions-policy.json index 1ed3c31f9e..2f66778fc6 100644 --- a/iam/prowler-additions-policy.json +++ b/iam/prowler-additions-policy.json @@ -23,6 +23,15 @@ "Resource": "*", "Effect": "Allow", "Sid": "AllowMoreReadForProwler" + }, + { + "Effect": "Allow", + "Action": [ + "apigateway:GET" + ], + "Resource": [ + "arn:aws:apigateway:*::/restapis/*" + ] } ] }