mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 14:55:00 +00:00
Merge branch 'master' into checks/find_security_groups_with_wide_open_non_RFC1918_IPv4
This commit is contained in:
@@ -25,11 +25,13 @@ extra742(){
|
|||||||
|
|
||||||
textInfo "Looking for secrets in CloudFormation output across all regions... "
|
textInfo "Looking for secrets in CloudFormation output across all regions... "
|
||||||
for regx in $REGIONS; do
|
for regx in $REGIONS; do
|
||||||
LIST_OF_CFN_STACKS=$($AWSCLI cloudformation describe-stacks $PROFILE_OPT --region $regx --query Stacks[*].[StackName] --output text)
|
CFN_STACKS=$($AWSCLI cloudformation describe-stacks $PROFILE_OPT --region $regx)
|
||||||
|
LIST_OF_CFN_STACKS=$(echo $CFN_STACKS | jq -r '.Stacks[].StackName')
|
||||||
if [[ $LIST_OF_CFN_STACKS ]];then
|
if [[ $LIST_OF_CFN_STACKS ]];then
|
||||||
for stack in $LIST_OF_CFN_STACKS; do
|
for stack in $LIST_OF_CFN_STACKS; do
|
||||||
CFN_OUTPUTS_FILE="$SECRETS_TEMP_FOLDER/extra742-$stack-$regx-outputs.txt"
|
CFN_OUTPUTS_FILE="$SECRETS_TEMP_FOLDER/extra742-$stack-$regx-outputs.txt"
|
||||||
CFN_OUTPUTS=$($AWSCLI $PROFILE_OPT --region $regx cloudformation describe-stacks --query "Stacks[?StackName==\`$stack\`].Outputs[*].[OutputKey,OutputValue]" --output text > $CFN_OUTPUTS_FILE)
|
echo $CFN_STACKS | jq --arg s "$stack" -r '.Stacks[] | select( .StackName == $s ) | .Outputs[]? | "\(.OutputKey) \(.OutputValue)"' > $CFN_OUTPUTS_FILE
|
||||||
|
|
||||||
if [ -s $CFN_OUTPUTS_FILE ];then
|
if [ -s $CFN_OUTPUTS_FILE ];then
|
||||||
# This finds ftp or http URLs with credentials and common keywords
|
# This finds ftp or http URLs with credentials and common keywords
|
||||||
# FINDINGS=$(egrep -i '[[:alpha:]]*://[[:alnum:]]*:[[:alnum:]]*@.*/|key|secret|token|pass' $CFN_OUTPUTS_FILE |wc -l|tr -d '\ ')
|
# FINDINGS=$(egrep -i '[[:alpha:]]*://[[:alnum:]]*:[[:alnum:]]*@.*/|key|secret|token|pass' $CFN_OUTPUTS_FILE |wc -l|tr -d '\ ')
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ extra765(){
|
|||||||
textFail "$region: ECR repository $repo has scan on push disabled!" "$region"
|
textFail "$region: ECR repository $repo has scan on push disabled!" "$region"
|
||||||
;;
|
;;
|
||||||
"None")
|
"None")
|
||||||
textInfo "$region: ECR repository $repo hs no scanOnPush status, newer awscli needed" "$region"
|
textInfo "$region: ECR repository $repo has no scanOnPush status, newer awscli needed" "$region"
|
||||||
;;
|
;;
|
||||||
"*")
|
"*")
|
||||||
textInfo "$region: ECR repository $repo has unknown scanOnPush status \"$SCAN_ENABLED\"" "$region"
|
textInfo "$region: ECR repository $repo has unknown scanOnPush status \"$SCAN_ENABLED\"" "$region"
|
||||||
|
|||||||
97
checks/check_extra776
Normal file
97
checks/check_extra776
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
#!/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.
|
||||||
|
|
||||||
|
# Remediation:
|
||||||
|
#
|
||||||
|
# https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-scanning.html
|
||||||
|
#
|
||||||
|
# aws ecr put-image-scanning-configuration \
|
||||||
|
# --region <value> \
|
||||||
|
# --repository-name <value> \
|
||||||
|
# --image-scanning-configuration scanOnPush=true
|
||||||
|
#
|
||||||
|
# aws ecr describe-image-scan-findings \
|
||||||
|
# --region <value> \
|
||||||
|
# --repository-name <value>
|
||||||
|
# --image-id imageTag=<value>
|
||||||
|
|
||||||
|
CHECK_ID_extra776="7.76"
|
||||||
|
CHECK_TITLE_extra776="[extra776] Check if ECR image scan found vulnerabilities in the newest image version (Not Scored) (Not part of CIS benchmark)"
|
||||||
|
CHECK_SCORED_extra776="NOT_SCORED"
|
||||||
|
CHECK_TYPE_extra776="EXTRA"
|
||||||
|
CHECK_ALTERNATE_check776="extra776"
|
||||||
|
|
||||||
|
extra776(){
|
||||||
|
for region in $REGIONS; do
|
||||||
|
LIST_ECR_REPOS=$($AWSCLI ecr describe-repositories $PROFILE_OPT --region $region --query "repositories[*].[repositoryName]" --output text 2>&1)
|
||||||
|
if [[ $(echo "$LIST_ECR_REPOS" | grep AccessDenied) ]]; then
|
||||||
|
textFail "Access Denied Trying to describe ECR repositories"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [[ ! -z "$LIST_ECR_REPOS" ]]; then
|
||||||
|
for repo in $LIST_ECR_REPOS; do
|
||||||
|
SCAN_ENABLED=$($AWSCLI ecr describe-repositories $PROFILE_OPT --region $region --query "repositories[?repositoryName==\`$repo\`].[imageScanningConfiguration.scanOnPush]" --output text 2>&1)
|
||||||
|
if [[ "$SCAN_ENABLED" == "True" ]]; then
|
||||||
|
IMAGE_DIGEST=$($AWSCLI ecr describe-images $PROFILE_OPT --region $region --repository-name "$repo" --query "sort_by(imageDetails,& imagePushedAt)[-1].imageDigest" --output text 2>&1)
|
||||||
|
IMAGE_TAG=$($AWSCLI ecr describe-images $PROFILE_OPT --region $region --repository-name "$repo" --query "sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]" --output text 2>&1)
|
||||||
|
if [[ ! -z "$LIST_ECR_REPOS" ]]; then
|
||||||
|
IMAGE_SCAN_STATUS=$($AWSCLI ecr describe-image-scan-findings $PROFILE_OPT --region $region --repository-name "$repo" --image-id imageDigest="$IMAGE_DIGEST" --query "imageScanStatus.status" 2>&1)
|
||||||
|
if [[ $IMAGE_SCAN_STATUS == *"ScanNotFoundException"* ]]; then
|
||||||
|
textFail "$region: ECR repository $repo has imageTag $IMAGE_TAG without a scan" "$region"
|
||||||
|
else
|
||||||
|
if [[ $IMAGE_SCAN_STATUS == *"FAILED"* ]]; then
|
||||||
|
textFail "$region: ECR repository $repo has imageTag $IMAGE_TAG with scan status $IMAGE_SCAN_STATUS" "$region"
|
||||||
|
else
|
||||||
|
FINDINGS_COUNT=$($AWSCLI ecr describe-image-scan-findings $PROFILE_OPT --region $region --repository-name "$repo" --image-id imageDigest="$IMAGE_DIGEST" --query "imageScanFindings.findingSeverityCounts" 2>&1)
|
||||||
|
if [[ ! -z "$FINDINGS_COUNT" ]]; then
|
||||||
|
SEVERITY_CRITICAL=$(echo "$FINDINGS_COUNT" | jq -r '.CRITICAL' )
|
||||||
|
if [[ "$SEVERITY_CRITICAL" != "null" ]]; then
|
||||||
|
textFail "$region: ECR repository $repo has imageTag $IMAGE_TAG with CRITICAL ($SEVERITY_CRITICAL) findings" "$region"
|
||||||
|
fi
|
||||||
|
SEVERITY_HIGH=$(echo "$FINDINGS_COUNT" | jq -r '.HIGH' )
|
||||||
|
if [[ "$SEVERITY_HIGH" != "null" ]]; then
|
||||||
|
textFail "$region: ECR repository $repo has imageTag $IMAGE_TAG with HIGH ($SEVERITY_HIGH) findings" "$region"
|
||||||
|
fi
|
||||||
|
SEVERITY_MEDIUM=$(echo "$FINDINGS_COUNT" | jq -r '.MEDIUM' )
|
||||||
|
if [[ "$SEVERITY_MEDIUM" != "null" ]]; then
|
||||||
|
textFail "$region: ECR repository $repo has imageTag $IMAGE_TAG with MEDIUM ($SEVERITY_MEDIUM) findings" "$region"
|
||||||
|
fi
|
||||||
|
SEVERITY_LOW=$(echo "$FINDINGS_COUNT" | jq -r '.LOW' )
|
||||||
|
if [[ "$SEVERITY_LOW" != "null" ]]; then
|
||||||
|
textInfo "$region: ECR repository $repo has imageTag $IMAGE_TAG with LOW ($SEVERITY_LOW) findings" "$region"
|
||||||
|
fi
|
||||||
|
SEVERITY_INFORMATIONAL=$(echo "$FINDINGS_COUNT" | jq -r '.INFORMATIONAL' )
|
||||||
|
if [[ "$SEVERITY_INFORMATIONAL" != "null" ]]; then
|
||||||
|
textInfo "$region: ECR repository $repo has imageTag $IMAGE_TAG with INFORMATIONAL ($SEVERITY_INFORMATIONAL) findings" "$region"
|
||||||
|
fi
|
||||||
|
SEVERITY_UNDEFINED=$(echo "$FINDINGS_COUNT" | jq -r '.UNDEFINED' )
|
||||||
|
if [[ "$SEVERITY_UNDEFINED" != "null" ]]; then
|
||||||
|
textInfo "$region: ECR repository $repo has imageTag $IMAGE_TAG with UNDEFINED ($SEVERITY_UNDEFINED) findings" "$region"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
textPass "$region: ECR repository $repo has imageTag $IMAGE_TAG without findings" "$region"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
textInfo "$region: ECR repository $repo has no images" "$region"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
textInfo "$region: ECR repository $repo has no scanOnPush not enabled" "$region"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
textInfo "$region: No ECR repositories found" "$region"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
58
checks/check_extra777
Executable file
58
checks/check_extra777
Executable file
@@ -0,0 +1,58 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Prowler - the handy cloud security tool (copyright 2020) 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.
|
||||||
|
|
||||||
|
# Current VPC Limit is 120 rules (60 inbound and 60 outbound)
|
||||||
|
# Reference: https://docs.aws.amazon.com/vpc/latest/userguide/amazon-vpc-limits.html
|
||||||
|
|
||||||
|
CHECK_ID_extra777="7.77"
|
||||||
|
CHECK_TITLE_extra777="[extra777] Find VPC security groups with many ingress or egress rules (Not Scored) (Not part of CIS benchmark)"
|
||||||
|
CHECK_SCORED_extra777="NOT_SCORED"
|
||||||
|
CHECK_TYPE_extra777="EXTRA"
|
||||||
|
CHECK_ALTERNATE_check777="extra777"
|
||||||
|
|
||||||
|
extra777(){
|
||||||
|
THRESHOLD=50
|
||||||
|
textInfo "Looking for VPC security groups with more than ${THRESHOLD} rules across all regions... "
|
||||||
|
|
||||||
|
for regx in ${REGIONS}; do
|
||||||
|
SECURITY_GROUP_IDS=$(${AWSCLI} ec2 describe-security-groups \
|
||||||
|
${PROFILE_OPT} \
|
||||||
|
--region ${regx} \
|
||||||
|
--query 'SecurityGroups[*].GroupId' \
|
||||||
|
--output text | xargs
|
||||||
|
)
|
||||||
|
|
||||||
|
for SECURITY_GROUP in ${SECURITY_GROUP_IDS}; do
|
||||||
|
|
||||||
|
INGRESS_TOTAL=$(${AWSCLI} ec2 describe-security-groups \
|
||||||
|
${PROFILE_OPT} \
|
||||||
|
--filter "Name=group-id,Values=${SECURITY_GROUP}" \
|
||||||
|
--query "SecurityGroups[*].IpPermissions[*].IpRanges" \
|
||||||
|
--region ${regx} \
|
||||||
|
--output text | wc -l | xargs
|
||||||
|
)
|
||||||
|
|
||||||
|
EGRESS_TOTAL=$(${AWSCLI} ec2 describe-security-groups \
|
||||||
|
${PROFILE_OPT} \
|
||||||
|
--filter "Name=group-id,Values=${SECURITY_GROUP}" \
|
||||||
|
--query "SecurityGroups[*].IpPermissionsEgress[*].IpRanges" \
|
||||||
|
--region ${regx} \
|
||||||
|
--output text | wc -l | xargs
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ (${INGRESS_TOTAL} -ge ${THRESHOLD}) || (${EGRESS_TOTAL} -ge ${THRESHOLD}) ]]; then
|
||||||
|
textFail "${regx}: ${SECURITY_GROUP} has ${INGRESS_TOTAL} inbound rules and ${EGRESS_TOTAL} outbound rules." "${regx}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ GROUP_ID[7]='extras'
|
|||||||
GROUP_NUMBER[7]='7.0'
|
GROUP_NUMBER[7]='7.0'
|
||||||
GROUP_TITLE[7]='Extras - [extras] **********************************************'
|
GROUP_TITLE[7]='Extras - [extras] **********************************************'
|
||||||
GROUP_RUN_BY_DEFAULT[7]='Y' # run it when execute_all is called
|
GROUP_RUN_BY_DEFAULT[7]='Y' # run it when execute_all is called
|
||||||
GROUP_CHECKS[7]='extra71,extra72,extra73,extra74,extra75,extra76,extra77,extra78,extra79,extra710,extra711,extra712,extra713,extra714,extra715,extra716,extra717,extra718,extra719,extra720,extra721,extra722,extra723,extra724,extra725,extra726,extra727,extra728,extra729,extra730,extra731,extra732,extra733,extra734,extra735,extra736,extra737,extra738,extra739,extra740,extra741,extra742,extra743,extra744,extra745,extra746,extra747,extra748,extra749,extra750,extra751,extra752,extra753,extra754,extra755,extra756,extra757,extra758,extra761,extra762,extra763,extra764,extra765,extra767,extra768,extra769,extra770,extra771,extra772,extra773,extra774,extra775,extra778'
|
GROUP_CHECKS[7]='extra71,extra72,extra73,extra74,extra75,extra76,extra77,extra78,extra79,extra710,extra711,extra712,extra713,extra714,extra715,extra716,extra717,extra718,extra719,extra720,extra721,extra722,extra723,extra724,extra725,extra726,extra727,extra728,extra729,extra730,extra731,extra732,extra733,extra734,extra735,extra736,extra737,extra738,extra739,extra740,extra741,extra742,extra743,extra744,extra745,extra746,extra747,extra748,extra749,extra750,extra751,extra752,extra753,extra754,extra755,extra756,extra757,extra758,extra761,extra762,extra763,extra764,extra765,extra767,extra768,extra769,extra770,extra771,extra772,extra773,extra774,extra775,extra776,extra777,extra778'
|
||||||
|
|
||||||
# Extras 759 and 760 (lambda variables and code secrets finder are not included)
|
# Extras 759 and 760 (lambda variables and code secrets finder are not included)
|
||||||
# to run detect-secrets use `./prowler -g secrets`
|
# to run detect-secrets use `./prowler -g secrets`
|
||||||
|
|||||||
Reference in New Issue
Block a user