Service Principal Abuse
This persistence method consists in backdooring Azure applications leveraging the permissions of a SP account to gain SSO access to the environment with the permissions of that applications without the need for credentials.
The main benefits of attacking SP accounts is that these accounts can't have MFA enforced on login and they are created by default along with any application, the only downside is the possible presence of a Conditional Access Policy that enforces other conditions on the login process but it still isn't enough to set MFA on a Service Principal account.
Once we created an application (or we took control of an existing one) we want to add a Client Secret with a pretty generous expiration period; this secret is the password we'll be able to use to log into the application. As we already did in Abusing Cloud Administrator Role we can now log into the application as a Service Principal
Another method we can use to log into the SP account is using Graph API
Since the SP account has the same permissions as its application we need to pick an application with "interesting" permissions over the tenant; ideally we'd want to create a new user account as a persistence mechanism, to do so we need the new-MgUser
permissions so can use the following commands to list all the permissions required to perform that action.
If the application already has these permissions or we can delegate them to the app itself we are able to create a new user account.
The final step is to log in as this user and change their password.
Last updated