mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 23:05:05 +00:00
48 lines
2.1 KiB
Bash
48 lines
2.1 KiB
Bash
#!/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_check11="1.1"
|
|
CHECK_TITLE_check11="[check11] Avoid the use of the root account"
|
|
CHECK_SCORED_check11="SCORED"
|
|
CHECK_CIS_LEVEL_check11="LEVEL1"
|
|
CHECK_SEVERITY_check11="High"
|
|
CHECK_ASFF_TYPE_check11="Software and Configuration Checks/Industry and Regulatory Standards/CIS AWS Foundations Benchmark"
|
|
CHECK_ALTERNATE_check101="check11"
|
|
CHECK_SERVICENAME_check11="iam"
|
|
CHECK_RISK_check11='The "root" account has unrestricted access to all resources in the AWS account. It is highly recommended that the use of this account be avoided.'
|
|
CHECK_REMEDIATION_check11='Follow the remediation instructions of the Ensure IAM policies are attached only to groups or roles recommendation.'
|
|
CHECK_DOC_check11='http://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html'
|
|
CHECK_CAF_EPIC_check11='IAM'
|
|
|
|
check11(){
|
|
# "Avoid the use of the root account (Scored)."
|
|
MAX_DAYS=-1
|
|
last_login_dates=$(cat $TEMP_REPORT_FILE | awk -F, '{ print $1,$5,$11,$16 }' | grep '<root_account>' | cut -d' ' -f2,3,4)
|
|
|
|
failures=0
|
|
for date in $last_login_dates; do
|
|
if [[ ${date%T*} =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]];then
|
|
days_not_in_use=$(how_many_days_from_today ${date%T*})
|
|
if [ "$days_not_in_use" -gt "$MAX_DAYS" ];then
|
|
failures=1
|
|
textFail "$REGION: Root user in the account was last accessed ${MAX_DAYS#-} day ago" "$REGION" "root"
|
|
break
|
|
fi
|
|
fi
|
|
done
|
|
|
|
if [[ $failures == 0 ]]; then
|
|
textPass "$REGION: Root user in the account wasn't accessed in the last ${MAX_DAYS#-} days" "$REGION" "root"
|
|
fi
|
|
}
|