Az - Dynamic Groups Privesc
Last updated
Last updated
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Dynamic groups are groups that has a set of rules configured and all the users or devices that match the rules are added to the group. Every time a user or device attribute is changed, dynamic rules are rechecked. And when a new rule is created all devices and users are checked.
Dynamic groups can have Azure RBAC roles assigned to them, but it's not possible to add AzureAD roles to dynamic groups.
This feature requires Azure AD premium P1 license.
Note that by default any user can invite guests in Azure AD, so, If a dynamic group rule gives permissions to users based on attributes that can be set in a new guest, it's possible to create a guest with this attributes and escalate privileges. It's also possible for a guest to manage his own profile and change these attributes.
Get groups that allow Dynamic membership: Get-AzureADMSGroup | ?{$_.GroupTypes -eq 'DynamicMembership'}
Rule example: (user.otherMails -any (_ -contains "tester")) -and (user.userType -eq "guest")
Rule description: Any Guest user with a secondary email with the string 'tester' will be added to the group
Go to Azure Active Directory -> Users and click on Want to switch back to the legacy users list experience? Click here to leave the preview
Click on New guest user
and invite an email
The user's profile will be added to the Azure AD as soon as the invite is sent. Open the user's profile and click on (manage) under Invitation accepted.
Change Resend invite?
to Yes and you will get an invitation URL:
Copy the URL and open it, login as the invited user and accept the invitation
Login in the cli as the user and set the secondary email
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)