From ae274b2fc9f731afc9a36dd25d85044cf92e96f4 Mon Sep 17 00:00:00 2001 From: Toni de la Fuente Date: Tue, 18 Jul 2017 11:45:52 -0400 Subject: [PATCH 1/2] Added check73 S3 buckets open to the AllUsers --- prowler | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/prowler b/prowler index 1487a82e..a6accfed 100755 --- a/prowler +++ b/prowler @@ -1417,20 +1417,28 @@ extra72(){ } extra73(){ -# # set -x - ID73="7.3" - TITLE73="Ensure there are no S3 buckets open to the AllUsers (Not Scored) (Not part of CIS benchmark)" - textTitle "$ID73" "$TITLE73" "0" -# -# for regx in $REGIONS; do -# -# done -# # set +x + #set -x + ID73="7.3" + TITLE73="Ensure there are no S3 buckets open to the AllUsers (Not Scored) (Not part of CIS benchmark)" + textTitle "$ID73" "$TITLE73" "0" + textNotice "Looking for S3 Buckets in all regions... " + ALL_BUCKETS_LIST=$($AWSCLI s3api list-buckets --query 'Buckets[*].{Name:Name}' --profile $PROFILE --region $REGION --output text) + for bucket in $ALL_BUCKETS_LIST; do + BUCKET_LOCATION=$($AWSCLI s3api get-bucket-location --bucket $bucket --profile $PROFILE --region $REGION --output text) + if [[ "None" == $BUCKET_LOCATION ]]; then + BUCKET_LOCATION="us-east-1" + fi + CHECK_BUCKET_PERMISSIONS=$($AWSCLI s3api get-bucket-acl --profile $PROFILE --region $BUCKET_LOCATION --bucket $bucket --query "Grants[?Grantee.URI == 'http://acs.amazonaws.com/groups/global/AllUsers']" --output text |grep -v GRANTEE) + CHECK_BUCKET_PERMISSIONS_SINGLE_LINE=$(echo -ne $CHECK_BUCKET_PERMISSIONS) + if [[ $CHECK_BUCKET_PERMISSIONS ]];then + textWarn "$BUCKET_LOCATION: $bucket bucket is open to the Internet with permissions: $CHECK_BUCKET_PERMISSIONS_SINGLE_LINE" "$regx" + else + textOK "$BUCKET_LOCATION: $bucket bucket is not open" "$regx" + fi + done } - - callCheck(){ if [[ $CHECKNUMBER ]];then case "$CHECKNUMBER" in @@ -1526,7 +1534,7 @@ callCheck(){ extra71;extra72;extra73 ;; * ) - textWarn "ERROR! Use a valid check name (i.e. check41)\n"; + textWarn "ERROR! Use a valid check name (i.e. check41 or extra71)\n"; esac cleanTemp exit @@ -1616,6 +1624,12 @@ check43 check44 check45 +TITLE7="Extras ************************************************************" +textTitle "7" "$TITLE7" +extra71 +extra72 +extra73 + if [[ $MODE != "csv" ]]; then infoReferenceLong fi From 2faa50c4dec633ea637fc0273dcd2ca427a3d8f4 Mon Sep 17 00:00:00 2001 From: Toni de la Fuente Date: Tue, 18 Jul 2017 11:47:56 -0400 Subject: [PATCH 2/2] fixed typo in TITTLE73 --- prowler | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prowler b/prowler index a6accfed..4a89cd3a 100755 --- a/prowler +++ b/prowler @@ -1419,7 +1419,7 @@ extra72(){ extra73(){ #set -x ID73="7.3" - TITLE73="Ensure there are no S3 buckets open to the AllUsers (Not Scored) (Not part of CIS benchmark)" + TITLE73="Ensure there are no S3 buckets open to AllUsers (Not Scored) (Not part of CIS benchmark)" textTitle "$ID73" "$TITLE73" "0" textNotice "Looking for S3 Buckets in all regions... " ALL_BUCKETS_LIST=$($AWSCLI s3api list-buckets --query 'Buckets[*].{Name:Name}' --profile $PROFILE --region $REGION --output text)