Files
prowler/checks/check_extra7142

50 lines
2.7 KiB
Bash

#!/usr/bin/env bash
# Prowler - the handy cloud security tool (copyright 2018) 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_extra7142="7.142"
CHECK_TITLE_extra7142="[extra7142] Check if S3 glacier vaults have policies which allow access to everyone (Not Scored) (Not part of CIS benchmark)"
CHECK_SCORED_extra7142="NOT_SCORED"
CHECK_TYPE_extra7142="EXTRA"
CHECK_SEVERITY_extra7142="Critical"
CHECK_ASFF_RESOURCE_TYPE_extra7142="AwsS3Glacier"
CHECK_ALTERNATE_check7142="extra7142"
CHECK_SERVICENAME_extra7142="s3glacier"
CHECK_RISK_extra7142='Vaults accessible to everyone could expose sensible data to bad actors'
CHECK_REMEDIATION_extra7142='Ensure vault policy does not have principle as *'
CHECK_DOC_extra7142='https://docs.aws.amazon.com/amazonglacier/latest/dev/access-control-overview.html'
CHECK_CAF_EPIC_extra7142='Data Protection'
extra7142(){
# "Check if S3 glacier vaults have policies which allow access to everyone (Not Scored) (Not part of CIS benchmark)"
for region in $REGIONS; do
LIST_OF_VAULTS=$($AWSCLI glacier list-vaults $PROFILE_OPT --region $region --account-id $ACCOUNT_NUM --query VaultList[*].VaultName --output text|xargs -n1)
if [[ $LIST_OF_VAULTS ]]; then
for vault in $LIST_OF_VAULTS;do
VAULT_POLICY_STATEMENTS=$($AWSCLI glacier $PROFILE_OPT get-vault-access-policy --region $region --account-id $ACCOUNT_NUM --vault-name $vault --output json --query policy.Policy 2>&1)
if [[ $VAULT_POLICY_STATEMENTS == *GetVaultAccessPolicy* ]]; then
textInfo "$region: Vault: $vault doesn't have any policy" "$region" "$vault"
else
VAULT_POLICY_BAD_STATEMENTS=$(echo $VAULT_POLICY_STATEMENTS | jq '. | fromjson' | jq '.Statement[] | select(.Effect=="Allow") | select(.Principal=="*" or .Principal.AWS=="*" or .Principal.CanonicalUser=="*")')
if [[ $VAULT_POLICY_BAD_STATEMENTS != "" ]]; then
textFail "$region : Vault: $vault has policy which allows access to everyone" "$region" "$vault"
else
textPass "$region: Vault: $vault has policy which does not allow access to everyone" "$region" "$vault"
fi
fi
done
else
textInfo "$region: No glacier vaults found" "$region"
fi
done
}