-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
183 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/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. | ||
|
||
CHECK_ID_extra789="7.89" | ||
CHECK_TITLE_extra789="[extra789] Find trust boundaries in VPC endpoint services connections" | ||
CHECK_SCORED_extra789="NOT_SCORED" | ||
CHECK_TYPE_extra789="EXTRA" | ||
CHECK_ALTERNATE_extra789="extra789" | ||
|
||
extra789(){ | ||
TRUSTED_ACCOUNT_IDS=$( echo "${ACCOUNT_NUM} ${GROUP_TRUSTBOUNDARIES_TRUSTED_ACCOUNT_IDS}" | xargs ) | ||
|
||
for regx in ${REGIONS}; do | ||
ENDPOINT_SERVICES_IDS=$(${AWSCLI} ec2 describe-vpc-endpoint-services \ | ||
${PROFILE_OPT} \ | ||
--query "ServiceDetails[?Owner=='${ACCOUNT_NUM}'].ServiceId" \ | ||
--region ${regx} \ | ||
--output text | xargs | ||
) | ||
|
||
for ENDPOINT_SERVICE_ID in ${ENDPOINT_SERVICES_IDS}; do | ||
|
||
ENDPOINT_CONNECTION_LIST=$(${AWSCLI} ec2 describe-vpc-endpoint-connections \ | ||
${PROFILE_OPT} \ | ||
--query "VpcEndpointConnections[?VpcEndpointState=='available'].VpcEndpointOwner" \ | ||
--region ${regx} \ | ||
--output text | xargs | ||
) | ||
|
||
for ENDPOINT_CONNECTION in ${ENDPOINT_CONNECTION_LIST}; do | ||
for ACCOUNT_ID in ${TRUSTED_ACCOUNT_IDS}; do | ||
if [[ "${ACCOUNT_ID}" == "${ENDPOINT_CONNECTION}" ]]; then | ||
textPass "${regx}: Found trusted account in VPC endpoint service connection ${ENDPOINT_CONNECTION}" "${regx}" | ||
# Algorithm: | ||
# Remove all trusted ACCOUNT_IDs from ENDPOINT_CONNECTION_LIST. | ||
# As a result, the ENDPOINT_CONNECTION_LIST finally contains only unknown/untrusted account ids. | ||
ENDPOINT_CONNECTION_LIST=("${ENDPOINT_CONNECTION_LIST[@]/$ENDPOINT_CONNECTION}") # remove hit from whitelist | ||
fi | ||
done | ||
done | ||
|
||
for UNTRUSTED_CONNECTION in ${ENDPOINT_CONNECTION_LIST}; do | ||
textFail "${regx}: Found untrusted account in VPC endpoint service connection ${UNTRUSTED_CONNECTION}" "${regx}" | ||
done | ||
done | ||
done | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/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. | ||
|
||
CHECK_ID_extra790="7.90" | ||
CHECK_TITLE_extra790="[extra790] Find trust boundaries in VPC endpoint services whitelisted principles" | ||
CHECK_SCORED_extra790="NOT_SCORED" | ||
CHECK_TYPE_extra790="EXTRA" | ||
CHECK_ALTERNATE_extra790="extra790" | ||
|
||
extra790(){ | ||
TRUSTED_ACCOUNT_IDS=$( echo "${ACCOUNT_NUM} ${GROUP_TRUSTBOUNDARIES_TRUSTED_ACCOUNT_IDS}" | xargs ) | ||
|
||
for regx in ${REGIONS}; do | ||
ENDPOINT_SERVICES_IDS=$(${AWSCLI} ec2 describe-vpc-endpoint-services \ | ||
${PROFILE_OPT} \ | ||
--query "ServiceDetails[?Owner=='${ACCOUNT_NUM}'].ServiceId" \ | ||
--region ${regx} \ | ||
--output text | xargs | ||
) | ||
|
||
for ENDPOINT_SERVICE_ID in ${ENDPOINT_SERVICES_IDS}; do | ||
ENDPOINT_PERMISSIONS_LIST=$(${AWSCLI} ec2 describe-vpc-endpoint-service-permissions \ | ||
${PROFILE_OPT} \ | ||
--service-id ${ENDPOINT_SERVICE_ID} \ | ||
--query "AllowedPrincipals[*].Principal" \ | ||
--region ${regx} \ | ||
--output text | xargs | ||
) | ||
|
||
for ENDPOINT_PERMISSION in ${ENDPOINT_PERMISSIONS_LIST}; do | ||
# Take only account id from ENDPOINT_PERMISSION: arn:aws:iam::965406151242:root | ||
ENDPOINT_PERMISSION_ACCOUNT_ID=$(echo ${ENDPOINT_PERMISSION} | cut -d':' -f5 | xargs) | ||
|
||
for ACCOUNT_ID in ${TRUSTED_ACCOUNT_IDS}; do | ||
if [[ "${ACCOUNT_ID}" == "${ENDPOINT_PERMISSION_ACCOUNT_ID}" ]]; then | ||
textPass "${regx}: Found trusted account in VPC endpoint service permission ${ENDPOINT_PERMISSION}" "${regx}" | ||
# Algorithm: | ||
# Remove all trusted ACCOUNT_IDs from ENDPOINT_PERMISSIONS_LIST. | ||
# As a result, the ENDPOINT_PERMISSIONS_LIST finally contains only unknown/untrusted account ids. | ||
ENDPOINT_PERMISSIONS_LIST=("${ENDPOINT_PERMISSIONS_LIST[@]/$ENDPOINT_PERMISSION}") | ||
fi | ||
done | ||
done | ||
|
||
for UNTRUSTED_PERMISSION in ${ENDPOINT_PERMISSIONS_LIST}; do | ||
textFail "${regx}: Found untrusted account in VPC endpoint service permission ${UNTRUSTED_PERMISSION}" "${regx}" | ||
done | ||
done | ||
done | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/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. | ||
|
||
GROUP_ID[16]='trustboundaries' | ||
GROUP_NUMBER[16]='16.0' | ||
GROUP_TITLE[16]='Find cross-account trust boundaries - [trustboundaries] ****************************' | ||
GROUP_RUN_BY_DEFAULT[16]='N' # run it when execute_all is called | ||
GROUP_CHECKS[16]='extra789,extra790' | ||
|
||
# Single account environment: No action required. The AWS account number will be automatically added by the checks. | ||
# Multi account environment: Any additional trusted account number should be added as a space separated list, e.g. | ||
# GROUP_TRUSTBOUNDARIES_TRUSTED_ACCOUNT_IDS="1234567890 0987654321 6789012345" | ||
GROUP_TRUSTBOUNDARIES_TRUSTED_ACCOUNT_IDS='' |