Applications and Service Principals
An Application Administrator, or a compromised on-premise sync account, could add credentials to default Microsoft service principals that already hold powerful directory roles, then log in as those applications. This let them read and modify directory settings, group memberships, user accounts, SharePoint sites and OneDrive files, with audit logs naming the Microsoft application rather than the admin.
dirkjanm.io
Published on dirkjanm.io
During both my DEF CON and Troopers talks I mentioned a vulnerability that existed in Azure AD where an Application Admin or a compromised On-Premise Sync Account could escalate privileges by assigning credentials to applications. When revisiting this topic I found out the vulnerability was actually not fixed by…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the directory API allowed credentials to be added to first-party service principals that already held high-privilege roles, while the portal hid this option and the audit log attributed actions to the application.
Impact
An attacker with these admin rights could read and modify directory settings, groups, users, SharePoint sites and OneDrive files while the audit log blamed a Microsoft application; Microsoft treated it as by design, though it later blocked it for almost all first-party service principals.
What the attacker needed
Application Admin or sync account access; PowerShell or API access to the directory
The fix
Microsoft later blocked credential assignment on almost all first-party service principals, and admins should monitor for credentials added to default service principals and review who controls high-privilege apps.
How it was found
- Enumerate the default service principals in the tenant and add a password or certificate credential to a chosen one.
- Request an OAuth2 token with the client credential grant using that credential.
- Decode the token to see which roles the application holds.
- Use the token to act as the application, for example to add a user to a group.
- Check the audit log, which shows the Microsoft application as the actor.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
In a cloud directory, some built-in Microsoft apps are pre-granted broad powers so they can do their jobs. An administrator who manages apps could quietly add a password to one of those apps and then sign in as it, borrowing its powers. The activity looked like the app acting, not the admin, so it was hard to spot.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.