Currently, publicly accessible buckets become a big deal and root cause of many recent data leaks.
All of these events even drive Amazon AWS to proactively send out emails to the customers who has such s3 configurations. Let's become a bit more proactive as well and audit s3 buckets
First, let's take look why bucket might become publicly available:
- Configured for public access intentionally (S3 static web hosting or just public resource) or by mistake
- Configured for the access of the Authenticated Users (option, misinterpreted by many as users from your account, which is wrong, it's any AWS authenticated user from any account)
Auditing AWS account you have full access to is quite easy - just list the buckets and check theirs ACL, users and bucket policies via aws cli or web gui.
What about cases when you:
- have many accounts and buckets (will take forever to audit manually)
- do not have enough permissions in the target AWS account to check bucket access
- you do not have permissions at all in this account (pentester mode)
To address everything above I've created small tool to do all dirty job for you (updated to v2):
https://github.com/IhorKravchuk/it-security/tree/master/scripts.aws
$python aws_test_bucket.py --profile prod-read --bucket test.bcuket
-P AWS_PROFILE, --profile=AWS_PROFILE
Please specify AWS CLI profile
-B BUCKET, --bucket=BUCKET
Please provide bucket name
-F FILE, --file=FILE Optional: file with buckets list to check
Note: --profile=AWS_PROFILE - any your AWS access profile (from aws cli). This profile HAS to NOT have access to the audited bucket (we need this just to become Authenticated User from AWS point of view )
You can specify one bucket to check using --bucket option or file with list of buckets(one bucket name per line) using --file option
All of these events even drive Amazon AWS to proactively send out emails to the customers who has such s3 configurations. Let's become a bit more proactive as well and audit s3 buckets
First, let's take look why bucket might become publicly available:
- Configured for public access intentionally (S3 static web hosting or just public resource) or by mistake
- Configured for the access of the Authenticated Users (option, misinterpreted by many as users from your account, which is wrong, it's any AWS authenticated user from any account)
Auditing AWS account you have full access to is quite easy - just list the buckets and check theirs ACL, users and bucket policies via aws cli or web gui.
What about cases when you:
- have many accounts and buckets (will take forever to audit manually)
- do not have enough permissions in the target AWS account to check bucket access
- you do not have permissions at all in this account (pentester mode)
To address everything above I've created small tool to do all dirty job for you (updated to v2):
https://github.com/IhorKravchuk/it-security/tree/master/scripts.aws
$python aws_test_bucket.py --profile prod-read --bucket test.bcuket
-P AWS_PROFILE, --profile=AWS_PROFILE
Please specify AWS CLI profile
-B BUCKET, --bucket=BUCKET
Please provide bucket name
-F FILE, --file=FILE Optional: file with buckets list to check
Note: --profile=AWS_PROFILE - any your AWS access profile (from aws cli). This profile HAS to NOT have access to the audited bucket (we need this just to become Authenticated User from AWS point of view )
You can specify one bucket to check using --bucket option or file with list of buckets(one bucket name per line) using --file option
Based on the bucket access status tool will provide you following responses:
Bucket: test.bucktet - The specified bucket does not exist
Bucket: test.bucktet - Bucket exists, but Access Denied
Bucket: test.bucktet - Found index.html, most probably S3 static web hosting is enabled
Bucket: test.bucktet - Bucket exists, publicly available and no S3 static web hosting, most probably misconfigured!
Enjoy!
PS. More over, you can create list of the buckets(even using some DNS/name alterations and permutations) to test in the file and loop through it checking each.
Stay secure.
No comments:
Post a Comment