AiTM on Microsoft 365: How Attackers Steal the Session Despite MFA
MFA passed and the password no longer matters. How AiTM steals the session, how to detect it with Defender XDR and Microsoft Sentinel, and how to shut it down.
Ahmed Eid 5 min read
- Topic
- Microsoft Security
- Level
- Intermediate
- Techniques
- T1557 · T1539 · T1564.008
- Data sources
- AADUserRiskEvents · OfficeActivity
- Exam
- SC-200
- You leave with
- The attack step by step, 3 hunting queries, and the layers of protection in order

The attack, step by step
- 1The victim receives a message with a link and opens a page that looks exactly like the Microsoft login.
- 2That page is a proxy: it requests the real login page from Microsoft and shows it to the victim unchanged.
- 3The victim types the password and approves MFA. The proxy relays all of it to Microsoft in real time.
- 4Microsoft returns a session cookie once MFA succeeds, and the proxy keeps a copy before passing it on.
- 5The attacker loads the cookie into their browser and opens Outlook as the victim, with no password or MFA.
- 6They create an inbox rule to hide replies and start sending fake invoices: Business Email Compromise.
If you think MFA closed the door on phishing, AiTM is the reason that’s not entirely true. The attacker doesn’t need to break MFA. They let you complete it yourself, then walk away with the result.
What AiTM is
Adversary-in-the-Middle (technique T1557 in ATT&CK) means the attacker places themselves between the victim and the real service. In the phishing variant, the attacker runs a reverse proxy using well-known open source tools, serves the real login page, and relays everything in both directions.
The target isn’t the password. It’s the session cookie Microsoft issues to the browser after MFA succeeds (T1539). With that cookie the attacker signs in as the victim until the session expires or is revoked.
Why standard MFA isn’t enough
An SMS message, an authenticator code and a push notification are all things the victim enters or approves personally, and the proxy simply relays them. MFA did its job, but on the attacker’s behalf.
What stops this attack is phishing-resistant MFA: passkeys and FIDO2, Windows Hello for Business, and certificate-based authentication in its multifactor form. With passkeys, FIDO2 and Windows Hello for Business, the key is bound to the real domain, so when the proxy requests it from a different domain the signature doesn’t work.
How Microsoft Defender detects it
If you have Microsoft Defender XDR and Microsoft Entra ID Protection, ready-made detections cover this scenario. The best known are:
- Entra ID Protection: Anomalous Token, Attacker in the Middle, and Unfamiliar sign-in properties.
- Defender XDR (with Defender for Cloud Apps and Defender for Endpoint): Stolen session cookie was used, and Possible AiTM phishing attempt.
- Defender for Office 365: alerts on malicious links that were clicked, and on messages removed after delivery.
- Attack Disruption: when the signals are strong, Defender XDR can contain the account and revoke its sessions automatically while the attack is still in its early stages.
3 hunting queries
Alerts are useful, but hunting finds what got past them. These three cover three stages of the attack: entry, concealment and theft.
1. A risk detection for an anomalous token or AiTM
AADUserRiskEvents
| where TimeGenerated > ago(7d)
| where RiskEventType in ("anomalousToken", "attackerinTheMiddle")
| project TimeGenerated, UserPrincipalName, IpAddress, Location, RiskEventType, RiskLevel, RiskStateindex=azure_ad sourcetype="azure:monitor:aad" category=UserRiskEvents
(properties.riskEventType="anomalousToken" OR properties.riskEventType="attackerinTheMiddle")
| table _time properties.userPrincipalName properties.ipAddress properties.riskEventType properties.riskLevelThe Attacker in the Middle detection is calculated offline, so it can take up to 48 hours to appear. That’s why this query runs on AADUserRiskEvents rather than SigninLogs.
2. A new inbox rule that hides messages
OfficeActivity
| where Operation in ("New-InboxRule", "Set-InboxRule", "UpdateInboxRules")
| where Parameters has_any ("DeleteMessage", "MoveToFolder", "MarkAsRead")
| project TimeGenerated, UserId, ClientIP, Operation, Parametersindex=o365 Operation IN ("New-InboxRule", "Set-InboxRule", "UpdateInboxRules")
| search Parameters="*DeleteMessage*" OR Parameters="*MoveToFolder*" OR Parameters="*MarkAsRead*"
| table _time UserId ClientIP Operation Parameters3. The same session from more than one country
AADNonInteractiveUserSignInLogs
| where TimeGenerated > ago(1d)
| summarize Countries = make_set(Location), IPs = dcount(IPAddress)
by SessionId, UserPrincipalName
| where array_length(Countries) > 1index=azure_ad sourcetype="azure:aad:signin" earliest=-1d
| stats dc(location.countryOrRegion) as countries values(ipAddress) as ips by sessionId userPrincipalName
| where countries > 1Splunk field names depend on the add-on that collects the logs, so check them against your environment before turning any query into a detection rule.
Closing the door: protection layers in order
- Phishing-resistant MFA through Authentication Strengths in Conditional Access. Start with admins.
- Require a compliant or hybrid joined device: a sign-in from the attacker’s server won’t meet this condition, so the token is never issued.
- Token Protection binds the token to the device it was issued to. Be aware of its limits: it covers specific native applications, and browser support is still in preview and limited to web apps that access Azure Resource Manager, so it doesn’t protect Microsoft 365 session cookies in the browser.
- Risk-based policies and Continuous Access Evaluation: when Entra ID raises user risk to High, access is revoked almost immediately in applications that support CAE.
- Defender XDR Attack Disruption with every workload enabled, and SmartScreen in Microsoft Edge to block the page itself.
You found signs of AiTM. Now what?
The key point in responding here is that changing the password alone isn’t enough, because the attacker already holds a working session. Microsoft recommends revoking session cookies along with the password change:
- 1Revoke the account's sessions and refresh tokens.
- 2Change the password, alongside revocation, not instead of it.
- 3Remove any MFA method the attacker added.
- 4Document suspicious inbox rules, then remove them.
- 5Look for other users who got the same link.
After containment, widen the investigation:
- Review all of the account’s sign-ins since the first sign of trouble, not just the latest alert.
- Look for new inbox rules, especially ones that move or delete messages.
- Review any change to MFA methods, and any newly registered devices.
- Check what the account sent and to whom, to catch BEC or internal phishing.
- Search for the same link across other users.
Common mistakes
- Treating standard MFA as complete protection against phishing.
- Changing the password and closing the ticket without revoking sessions.
- Deleting the inbox rule before documenting what it does.
- Investigating one account when the campaign reached others.
- Rolling out phishing-resistant MFA to admins only, and forgetting the people who handle money.
How this maps to SC-200
This scenario touches a large part of the SC-200 syllabus: alerts and incidents in Defender XDR, hunting with KQL in Defender and Microsoft Sentinel, and response on Entra ID and Microsoft 365 accounts. If you’re studying for the exam, try building these 3 queries as analytics rules in Sentinel. Alert grouping collects the alerts of a single rule into one incident, while correlation across the three rules is handled by the correlation engine in the Microsoft Defender portal. Automation rules come after that, for triage, assignment and running playbooks.
References
- Protecting tokens in Microsoft Entra: protections and detections for token theft.
- Microsoft Security Blog: a multi-stage AiTM and BEC campaign.
- MITRE ATT&CK T1557 and T1539.