Last active
September 8, 2017 19:05
-
-
Save angrychimp/0d9b7c279794cbc3b68f21bfd664c3e3 to your computer and use it in GitHub Desktop.
Scan S3 buckets for public-read permissions
This file contains hidden or 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
| #!/bin/bash | |
| # requires jq: https://stedolan.github.io/jq/ | |
| # requires aws-cli: http://docs.aws.amazon.com/cli/latest/userguide/installing.html | |
| for bucket in `aws s3 ls | awk '{print $NF}'`; do | |
| errors=$(expr $(aws s3api get-bucket-acl --bucket $bucket | | |
| jq '.Grants | .[] | if (.Permission == "READ" and (.Grantee.URI == "http://acs.amazonaws.com/groups/global/AuthenticatedUsers" or .Grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers")) then "ERROR" else null end' | | |
| grep ERROR | | |
| wc -l)) | |
| if [[ $errors > 0 ]]; then | |
| echo $bucket $errors | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment