1. Resources
  2. Detection rules
  3. Application Granted Access to All Mailboxes

Application Granted Access to All Mailboxes detection rules

An attacker who can grant application permissions gives an app full_access_as_app, Exchange.ManageAsApp or a Microsoft Graph mail permission. The app then reads or sends mail for every mailbox in Exchange Online with no user and no MFA.

Platform
Microsoft Exchange
Severity
High
Log source
Microsoft Entra ID audit logs, Microsoft 365 unified audit log (Exchange)
Last updated
Rule formats
Sigmaand queries for: SplunkMicrosoft SentinelIBM QRadar
What an attacker needs
An identity that can grant application permissions, such as Privileged Role Administrator or Application Administrator, plus a credential on the target application.
Impact
Read, write or send access to every mailbox in the tenant without a user sign-in, MFA or user Conditional Access, surviving password resets of every user.
Response
Disable the service principal that received the permission first, then remove the grant and revoke the sessions and consent rights of the identity that made it.
Mitigation
Scope mail access to the mailboxes each app needs with RBAC for Applications in Exchange Online, and limit who can consent to application permissions.
Audit activity
Add app role assignment to service principal
Operation
New-ServicePrincipal

How the attack works

Application permissions granted in Microsoft Entra ID let an app call Exchange Online as itself. full_access_as_app on the Office 365 Exchange Online API gives Exchange Web Services access to every mailbox. The Microsoft Graph application permissions Mail.Read, Mail.ReadWrite and Mail.Send do the same through Graph. Exchange.ManageAsApp lets the app sign in to Exchange Online PowerShell, where it holds whatever Exchange role it has been assigned, up to Exchange Administrator. All of them are unscoped: one grant covers every mailbox in the tenant. An app can also receive mailbox access inside Exchange Online through RBAC for Applications, and Microsoft states that those grants are independent of the grants in Microsoft Entra ID. A second rule on this page reads the creation of the Exchange service principal object that such a grant needs, and the role assignment itself is covered by the page on Exchange management roles.

The grant is written to the Microsoft Entra audit log as Add app role assignment to service principal, with the name of the permission in the modified property AppRole.Value of the target resource. Attackers make the grant after they reach an identity that can consent to application permissions, then add a credential to the app and collect mail without touching any user account. Microsoft's guidance on the Midnight Blizzard intrusion, published January 25, 2024, describes this pattern: the actor compromised a legacy test OAuth application, created additional malicious OAuth applications and used the legacy application to grant them the Office 365 Exchange Online full_access_as_app role, which allows access to mailboxes.

What an attacker needs

  • An identity that can grant application permissions. Microsoft documents that Privileged Role Administrator (and Global Administrator) can consent for any API, while Application Administrator and Cloud Application Administrator can consent to any permission except Microsoft Graph application permissions. The Office 365 Exchange Online permissions full_access_as_app and Exchange.ManageAsApp are therefore within reach of the two application administrator roles. An app that holds AppRoleAssignment.ReadWrite.All can also make the grant.
  • A credential on the target application, or the ability to add one.

Impact

Read, write or send access to every mailbox in the tenant, or Exchange Online administration as an application, without a user sign-in, MFA or user Conditional Access. The access survives password resets of every user.

Detection rules

Application Permission for All Mailboxes Granted to a Service Principal

Detects an application permission (app role assignment) that gives a service principal access to mailboxes across Exchange Online: full_access_as_app, Exchange.ManageAsApp, or the Microsoft Graph permissions Mail.Read, Mail.ReadWrite, Mail.Send, MailboxSettings.ReadWrite and the MailboxItem permissions. The permission name is in the AppRole.Value modified property of TargetResources. Requires Microsoft Entra audit logs.

LevelHighStatusExperimentalLog sourceMicrosoft Entra ID audit logs
title: Application Permission for All Mailboxes Granted to a Service Principal
id: 915852b8-1a5f-4e94-9b81-1a758d9e4feb
status: experimental
description: >-
  Detects an application permission (app role assignment) that gives a service
  principal access to mailboxes across Exchange Online: full_access_as_app,
  Exchange.ManageAsApp, or the Microsoft Graph permissions Mail.Read,
  Mail.ReadWrite, Mail.Send, MailboxSettings.ReadWrite and the MailboxItem
  permissions. The permission name is in the AppRole.Value modified property of
  TargetResources. Requires Microsoft Entra audit logs.
references:
  - https://attack.mitre.org/techniques/T1098/003/
  - https://learn.microsoft.com/en-us/exchange/permissions-exo/application-rbac
  - https://learn.microsoft.com/en-us/powershell/exchange/app-only-auth-powershell-v2
author: Forestall
date: 2026-11-11
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1098.003
logsource:
  product: azure
  service: auditlogs
detection:
  selection:
    OperationName: Add app role assignment to service principal
    TargetResources|contains:
      - full_access_as_app
      - Exchange.ManageAsApp
      - Mail.Read
      - Mail.Send
      - MailboxSettings.ReadWrite
      - MailboxItem.
  filter_failed:
    Result: failure
  condition: selection and not filter_failed
falsepositives:
  - Administrators onboarding an approved mail integration, backup or migration tool. Confirm a change record for each grant and check whether the app could use a scoped role in Exchange Online instead.
  - Mail.Read also matches Mail.ReadWrite and Mail.ReadBasic.All, which is intended.
level: high

False positives

  • Administrators onboarding an approved mail integration, backup or migration tool. Confirm a change record for each grant and check whether the app could use a scoped role in Exchange Online instead.
  • Mail.Read also matches Mail.ReadWrite and Mail.ReadBasic.All, which is intended.

Service Principal Registered in Exchange Online

Detects New-ServicePrincipal in Exchange Online, the cmdlet that creates the Exchange object for a Microsoft Entra service principal. RBAC for Applications needs this object before an application role such as Application Mail.Read or Application Mail Full Access can be assigned to an application inside Exchange. Microsoft states that these grants are independent of the grants in Microsoft Entra ID and act in addition to them, so mailbox access given this way is not among the application permissions of the Entra audit log that the other rule on this page reads. The cmdlet grants nothing by itself. It is the first step of an Exchange-side grant and is rare, because it is run once per application. The role assignment that follows is New-ManagementRoleAssignment, which the page on Exchange management roles covers. In an Exchange admin audit record the Operation is the name of the cmdlet and Parameters holds the names and values of its parameters, here AppId, ObjectId and DisplayName. Requires Microsoft 365 audit logging and the Exchange records of the unified audit log in the SIEM.

LevelLowStatusExperimentalLog sourceMicrosoft 365 unified audit log (Exchange)
title: Service Principal Registered in Exchange Online
id: ee624b45-0e34-4f0b-b09a-32d34d99911c
status: experimental
description: >-
  Detects New-ServicePrincipal in Exchange Online, the cmdlet that creates the
  Exchange object for a Microsoft Entra service principal. RBAC for
  Applications needs this object before an application role such as
  Application Mail.Read or Application Mail Full Access can be assigned to an
  application inside Exchange. Microsoft states that these grants are
  independent of the grants in Microsoft Entra ID and act in addition to them,
  so mailbox access given this way is not among the application permissions
  of the Entra audit log that the other rule on this page reads. The cmdlet
  grants nothing by itself. It is the first step of an Exchange-side grant and
  is rare, because it is run once per application. The role assignment that
  follows is New-ManagementRoleAssignment, which the page on Exchange
  management roles covers. In an Exchange admin audit record the Operation is
  the name of the cmdlet and Parameters holds the names and values of its
  parameters, here AppId, ObjectId and DisplayName. Requires Microsoft 365
  audit logging and the Exchange records of the unified audit log in the
  SIEM.
references:
  - https://learn.microsoft.com/en-us/exchange/permissions-exo/application-rbac
  - https://learn.microsoft.com/en-us/powershell/module/exchangepowershell/new-serviceprincipal
  - https://learn.microsoft.com/en-us/office/office-365-management-api/office-365-management-activity-api-schema
  - https://attack.mitre.org/techniques/T1098/003/
author: Forestall
date: 2026-11-18
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1098.003
logsource:
  product: m365
  service: exchange
detection:
  selection:
    Operation: New-ServicePrincipal
  condition: selection
falsepositives:
  - Administrators who move a mail integration from an unscoped Microsoft Entra permission to a scoped role in Exchange Online. Confirm a change record and check which role the application receives afterwards.
level: low

False positives

  • Administrators who move a mail integration from an unscoped Microsoft Entra permission to a scoped role in Exchange Online. Confirm a change record and check which role the application receives afterwards.

Detection logic

Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.

Mail permission granted and a credential added to the same application

Detection hypothesisSequence of events

A mail permission is useful to an attacker only together with a credential for the application. A grant and a new secret or certificate on the same application within a day, in either order, is the preparation for collecting mail as that application.

  1. Microsoft Entra audit log: Add app role assignment to service principal with a mail permission in the AppRole.Value modified property. Keep the application from TargetResources.
  2. Within 24 hours before or after: Add service principal credentials or Update application - Certificates and secrets management for the same application.
  3. Raise the priority when the same actor in InitiatedBy made both changes, or when the application was added to the tenant in the same period.

EventsAdd app role assignment to service principalAdd service principal credentials

LimitsOnboarding a new mail integration grants the permission and adds a credential in one change, which is the same sequence. Match it to a change record. The 24 hours are a starting point.

An application that never read mail starts reading many mailboxes

Detection hypothesisNeeds a baseline

The grant is only the preparation. Its use shows up in the mailbox audit log, where MailItemsAccessed records carry the identifier of the application that made the request. Mail integrations in a tenant are few and read the same mailboxes every day. An application identifier that appears for the first time and reads mail in many mailboxes within a day is the grant being used to collect.

  1. Exchange mailbox records: MailItemsAccessed. For each record keep AppId (or ClientAppId, the original caller), MailboxOwnerUPN, ClientIPAddress and MailAccessType in OperationProperties.
  2. Build a 30-day list of the application identifiers with the number of different MailboxOwnerUPN values each read per day.
  3. Alert when an identifier that is not on the list reads mail in more than a starting value of 5 mailboxes in a day, or when a listed identifier reads several times its usual number of mailboxes.
  4. Look the identifier up among the service principals that received a mail permission (the rule on this page) and read their sign-ins and credential changes.

EventsMailItemsAccessed

LimitsMicrosoft does not document which account UserId and LogonType show when an application reads mail without a user, so check a known integration in your own data first. MailItemsAccessed is on by default only for users with an Office 365 or Microsoft 365 E3 or E5 license. New backup, archiving and migration tools look the same. The 30 days and the counts are starting points.

Triage

  • Read TargetResources for the app that received the permission and the value of AppRole.Value, and InitiatedBy for who granted it.
  • Check whether the app is known, who owns it and whether a credential was added to it around the same time.
  • Review the app's service principal sign-ins and, in the unified audit log, the mailboxes it accessed after the grant.
  • Remove an unexplained grant and the app's credentials, then review the granting identity.

Response

Once the attack is confirmed:

  1. Disable the service principal that received the permission first, so mail access stops while the evidence is still in place.
  2. If the app received Exchange.ManageAsApp, also remove the Exchange role or directory role it was assigned, such as Exchange Administrator. The permission only lets the app sign in, and the role decides what it can do.
  3. Contain the identity that made the grant. Revoke its sessions, rotate its credentials and remove its right to consent to application permissions. If the grant was made by an application that holds AppRoleAssignment.ReadWrite.All, remove that permission and the application's credentials as well.
  4. Search for other applications created by the same identity or granted permissions by it in the same period, and for applications that hold mail permissions without a known owner. In the intrusion Microsoft described, more than one malicious application was created.
  5. Handle the mailboxes the app accessed as read. Notify their owners, and replace what was sent by mail and can be reused, such as password reset links and shared credentials.
  6. After cleanup, compare the service principals that hold mail permissions or Exchange.ManageAsApp with the approved list.

Mitigation

  • Scope mail access to the mailboxes each app needs with RBAC for Applications in Exchange Online, and remove the unscoped permission in Microsoft Entra ID.
  • Limit who can consent to application permissions, and review the apps that hold mail permissions and Exchange.ManageAsApp on a schedule.
  • Remove full_access_as_app from apps that have moved to Microsoft Graph. Microsoft is retiring Exchange Web Services in Exchange Online; its post of February 5, 2026 (updated October 27, 2026) says it is fully and permanently disabled starting April 1, 2027.
  • Use certificates or workload identity federation instead of client secrets on these apps, and alert on new credentials.

Frequently asked questions

Can an Application Administrator grant an app access to every mailbox?

For the Exchange permissions, yes. Microsoft documents that Application Administrator and Cloud Application Administrator can consent to any permission except Microsoft Graph application permissions. `full_access_as_app` and `Exchange.ManageAsApp` belong to the Office 365 Exchange Online API, so both roles can grant them. Consent to the Microsoft Graph mail permissions takes Privileged Role Administrator or Global Administrator.

Does Exchange.ManageAsApp on its own open mailboxes?

Not by itself. The permission lets the app sign in to Exchange Online PowerShell, where it holds whatever Exchange role it has been assigned, up to Exchange Administrator. Check which role the service principal holds in the same investigation, because that role decides what the app can do.

Why does the rule also match Mail.ReadWrite and Mail.ReadBasic.All?

The rule matches the text Mail.Read inside the permission name, which also covers Mail.ReadWrite and Mail.ReadBasic.All. This is intended. Read the exact value of AppRole.Value in the event to see which permission was granted.

How can a mail integration work without access to every mailbox?

Exchange Online offers RBAC for Applications, which scopes an app's mail access to the mailboxes it needs. Once the scoped role is in place, the unscoped permission in Microsoft Entra ID can be removed. Apps that still use `full_access_as_app` have to move in any case, because Microsoft is retiring Exchange Web Services in Exchange Online.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.