对 S3 对象有效权限的白盒评估,用于识别可公开访问的对象。
可以识别可公开访问的对象,以及可通过 AuthenticatedUsers 访问的对象(通过使用辅助配置文件)。
许多现有工具可以检查存储桶的权限,但由于 IAM 资源策略与 ACL 组合的复杂性,特定对象的有效权限往往难以评估。
该工具运行速度快,因为它使用了 asyncio 和 aiobotocore。
该工具利用两个 命名配置文件:
WHITEBOX_PROFILE - 此配置文件应具有对 S3 服务的读取权限。它将用于列出存储桶和对象,之后工具将尝试通过 未认证 的请求访问这些对象。它不用于访问对象,仅用于列出它们。BLACKBOX_PROFILE - 除了未认证的请求外,该工具还会使用此配置文件来识别对 "已认证用户组"(AuthenticatedUsers)可访问的对象。此配置文件不应具有对 S3 存储桶/对象的访问权限,否则会产生误报。设置虚拟环境并安装依赖项:
$ virtualenv -p python3 venv
$ source venv/bin/activate
$ pip -r requirements.txt
选项:
$ python s3-objects-check.py -h
usage: s3-objects-check.py [-h] -p WHITEBOX_PROFILE -e BLACKBOX_PROFILE [-d]
Whitebox evaluation of effective S3 object permissions, to identify publicly
accessible files.
optional arguments:
-h, --help show this help message and exit
-p WHITEBOX_PROFILE, --profile WHITEBOX_PROFILE
The profile with access to the desired AWS account and
buckets
-e BLACKBOX_PROFILE, --profile-external BLACKBOX_PROFILE
An "external" profile to test for 'AuthenticatedUsers'
permissions. This principal should not have
permissions to read bucket objects.
-d, --debug Verbose output. Will also create a log file
运行工具:
$ python s3-objects-check.py -p whitebox-profile -e blackbox-profile
2020-11-24 11:19:56 host object-check[371] INFO Starting
2020-11-24 11:20:08 host object-check[371] WARNING Found https://<bucket>.s3.us-east-1.amazonaws.com/<object> allowing "AllUsers"
2020-11-24 11:20:09 host object-check[371] WARNING Found https://<bucket>.s3.eu-west-2.amazonaws.com/<object> allowing "AuthenticatedUsers"
2020-11-24 11:21:34 host object-check[371] INFO Done