mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 06:45:08 +00:00
44 lines
2.2 KiB
Bash
44 lines
2.2 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_extra76="7.6"
|
|
CHECK_TITLE_extra76="[extra76] Ensure there are no EC2 AMIs set as Public"
|
|
CHECK_SCORED_extra76="NOT_SCORED"
|
|
CHECK_CIS_LEVEL_extra76="EXTRA"
|
|
CHECK_SEVERITY_extra76="Critical"
|
|
CHECK_ALTERNATE_extra706="extra76"
|
|
CHECK_ALTERNATE_check76="extra76"
|
|
CHECK_ALTERNATE_check706="extra76"
|
|
CHECK_SERVICENAME_extra76="ec2"
|
|
CHECK_RISK_extra76='A shared AMI is an AMI that a developer created and made available for other developers to use. If AMIs have embebed information about the environment could pose a security risk. You use a shared AMI at your own risk. Amazon can not vouch for the integrity or security of AMIs shared by Amazon EC2 users. '
|
|
CHECK_REMEDIATION_extra76='List all shared AMIs and make sure there is a business reason for them.'
|
|
CHECK_DOC_extra76='https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/usingsharedamis-finding.html'
|
|
CHECK_CAF_EPIC_extra76='Infrastructure Security'
|
|
|
|
extra76(){
|
|
# "Ensure there are no EC2 AMIs set as Public "
|
|
for regx in $REGIONS; do
|
|
LIST_OF_PUBLIC_AMIS=$($AWSCLI ec2 describe-images --owners self $PROFILE_OPT --region $regx --filters "Name=is-public,Values=true" --query 'Images[*].{ID:ImageId}' --output text 2>&1)
|
|
if [[ $(echo "$LIST_OF_PUBLIC_AMIS" | grep -E 'AccessDenied|UnauthorizedOperation') ]]; then
|
|
textInfo "$regx: Access Denied trying to describe images" "$regx"
|
|
continue
|
|
fi
|
|
if [[ $LIST_OF_PUBLIC_AMIS ]];then
|
|
for ami in $LIST_OF_PUBLIC_AMIS; do
|
|
textFail "$regx: $ami is currently Public!" "$regx" "$ami"
|
|
done
|
|
else
|
|
textPass "$regx: No Public AMIs found" "$regx" "$ami"
|
|
fi
|
|
done
|
|
}
|