
AWS IAMポリシーステートメントのパーサーおよびクエリツールです。
IAMActionHunter は IAM ポリシーステートメントのパーサー兼クエリツールで、AWS Identity and Access Management (IAM) におけるユーザーとロールの許可ポリシーステートメントを収集・理解するプロセスを簡素化することを目的としています。機能は単純ですが、日常の AWS ペネトレーションテストにおいて効率的なソリューションの必要性に応えて開発されました。
https://rhinosecuritylabs.com/aws/iamactionhunter-aws-iam-permissions/
このツールは、悪用される可能性のあるさまざまな AWS IAM アクションをクエリすることで、AWS アカウントにおける潜在的な権限昇格の機会を検索するために使用できます。他のツールが権限昇格のリスクを特定するスキャンを実行するのに対し、このツールはより手動のアプローチを可能にし、ユーザーが権限を調査し、適用対象となるロール、ユーザー、リソースを迅速に確認してターゲット分析を行うことができます。
このツールは、クエリ結果を CSV 形式で出力・保存する機能も提供します。これは、AWS アカウント内のプリンシパル権限やリソースの概要を把握したいセキュリティチームにとって有益です。例えば、アカウント内で iam:put* 権限を持つユーザーとロールを特定したい場合、クエリを実行して CSV を生成することで、これらの権限を持つすべてのユーザーとロール、およびそれらがアクセスできるリソースを簡単に確認できます。
推奨:
pip3 install iamactionhunter
この機能の多くは https://github.com/RhinoSecurityLabs/pacu にモジュール iam__enum_action_query としても実装されており、そちらを好む場合は使用できます。
クローンして Poetry を使用する:
git clone https://github.com/RhinoSecurityLabs/IAMActionHunter.git
cd IAMActionHunter
# (必要に応じて: poetry env use python3.9)
poetry install
iamactionhunter --help
iamactionhunter --collect --profile <some-aws-profile>
クローンして Pip を使用する:
git clone https://github.com/RhinoSecurityLabs/IAMActionHunter.git
cd IAMActionHunter
pip install .
iamactionhunter --help
iamactionhunter --collect --profile <some-aws-profile>
ヘルプ:
usage: iamactionhunter [-h] [--profile PROFILE] [--account ACCOUNT] [--query QUERY] [--role ROLE] [--user USER]
[--all-or-none] [--collect] [--list] [--csv CSV] [--config CONFIG]
Collect all policies for all users/roles in an AWS account and then query the policies for permissions.
optional arguments:
-h, --help show this help message and exit
--profile PROFILE The name of the AWS profile to use for authentication for user/role collection.
--account ACCOUNT Account number to query.
--query QUERY Permissions to query. A string like: s3:GetObject or s3:* or s3:GetObject,s3:PutObject
--role ROLE Filter role to query.
--user USER Filter user to query.
--all-or-none Check if all queried actions are allowed, not just some.
--collect Collect user and role policies for the account.
--list List accounts available to query.
--csv CSV File name for CSV report output.
--config CONFIG JSON config file for preset queries.
まず、ユーザーとロールのすべての IAM 情報をダウンロードします:
iamactionhunter --collect --profile my-aws-profile
アカウントデータが収集されているかを一覧表示:
iamactionhunter --list
次に、何かをクエリ:
iamactionhunter --account <account_number_of_profile_above> --query iam:create*
さらにクエリ:
iamactionhunter --account <account_number_of_profile_above> --query iam:create*,iam:put*
特定のロールをクエリ:
iamactionhunter --account <account_number_of_profile_above> --role some_role --query iam:*
特定のユーザーをクエリ:
iamactionhunter --account <account_number_of_profile_above> --user some_user --query iam:*
CSV に出力:
iamactionhunter --account <account_number_of_profile_above> --query iam:* --csv report.csv
プリセット設定を実行:
iamactionhunter --account <account_number_of_profile_above> --config dangerous_iam
ユーザーまたはロールがクエリしたすべての権限を持っている場合のみ結果を表示するクエリを実行:
iamactionhunter --account <account_number_of_profile_above> --query s3:getobject,s3:listbucket --all-or-none
組み込み設定オプション:
dangerous_iam
write_actions
privescs
iamactionhunter --account <account_number_of_profile> --config dangerous_iam
設定ファイルは、検索したい特定の権限を指定する JSON ファイルです。以下は、CodeBuild における書き込みアクションを検索するサンプルファイルです。
[
{
"Description": "These are all actions which may allow some kind of write privilege in CodeBuild.",
"Name": "CodeBuildWriteActions",
"ActionsNeeded": [
"codebuild:Put*",
"codebuild:Create*",
"codebuild:Delete*",
"codebuild:Modify*",
"codebuild:Update*",
"codebuild:Attach*",
"codebuild:Detach*",
"codebuild:Associate*",
"codebuild:Disassociate*",
"codebuild:Add*",
"codebuild:Remove*",
"codebuild:Set*",
"codebuild:Enable*",
"codebuild:Disable*",
"codebuild:Reset*",
"codebuild:Stop*",
"codebuild:Terminate*",
"codebuild:Reboot*",
"codebuild:Start*"
],
"AllOrNone": false
}
]
その後、--config 引数でファイル名を指定して設定を実行できます。
iamactionhunter --account <account_number_of_profile> --config write_code_build.json