AZ_MG_DIRECTORY_READWRITE_ALL

Summary

FSProtect ACL Alias

AZ_MG_DIRECTORY_READWRITE_ALL

Entra ID (Azure AD) Alias

Directory.ReadWrite.All

Affected Object Types

Service Principals, Applications

Exploitation Certainty

Certain

Graph Permission / Role

Application Permission: Directory.ReadWrite.All

Description

AZ_MG_DIRECTORY_READWRITE_ALL represents a Microsoft Graph application permission that grants read and write access to all directory data in Microsoft Entra ID (Azure AD). This is one of the most dangerous permissions that can be assigned to an application or service principal because it allows:

  • Create, read, update, and delete users (except passwords for admin users)

  • Create, read, update, and delete groups including security groups and Microsoft 365 groups

  • Manage group memberships adding/removing members from any group

  • Read and modify applications and service principals

  • Read and modify directory roles and role assignments (with some restrictions)

  • Manage devices and device configurations

  • Read and modify organizational settings

  • Manage domains and directory extensions

This permission is often abused for:

  • Privilege escalation: Adding controlled accounts to privileged groups (e.g., Global Administrators role-assignable groups)

  • Persistence: Creating backdoor accounts or service principals

  • Lateral movement: Modifying existing accounts or groups to gain access to additional resources

  • Data exfiltration: Enumerating all directory objects and their properties

circle-exclamation

Identification

PowerShell

Find Service Principals with Directory.ReadWrite.All

1

Get all service principals with app role assignments

2

Filter for Directory.ReadWrite.All and export results

Exploitation

An attacker with access to a service principal that has Directory.ReadWrite.All can perform numerous privilege escalation attacks.

Add User to a Privileged Group

Create a Backdoor User Account

Mitigation

  • Audit all service principals with Directory.ReadWrite.All and remove unnecessary grants.

    • Go to Microsoft Entra ID -> App registrations -> select the application -> API permissions.

    • Remove the Directory.ReadWrite.All permission if not required.

  • Apply least privilege: Replace with more specific permissions where possible:

    • Use User.ReadWrite.All instead if only user management is needed.

    • Use Group.ReadWrite.All instead if only group management is needed.

    • Use Application.Read.All if only read access is required.

  • Implement Access Reviews for applications with high-privilege permissions:

    • Go to Identity Governance -> Access Reviews -> New access review.

    • Review applications with sensitive Graph permissions regularly.

  • Use Privileged Identity Management (PIM) for just-in-time access where applicable.

  • Monitor permission grants and alert on new Directory.ReadWrite.All assignments.

Detection

Detect permission grants and suspicious activity in Audit logs.

  • Go to Microsoft Entra ID -> Audit logs.

  • Filter by activities:

    • Add app role assignment to service principal

    • Add user

    • Add member to group

    • Update application

Monitor for suspicious patterns:

  • New user creation by service principals.

  • Group membership changes by service principals.

  • Application credential additions by service principals.

  • Bulk directory modifications outside of change management windows.

References

Last updated

Was this helpful?