Adversary-in-the-middle (AiTM) phishing steals a signed-in session rather than a password, so the detection job in Entra ID is to spot a session that is being used from somewhere it was never issued to. A reverse proxy kit sits between the user and the real Microsoft sign-in page, relays the password and the MFA approval, and keeps the session cookie that comes back. The attacker then replays that cookie or token from their own infrastructure. MFA succeeded, so the sign-in looks legitimate unless you look at the right fields.
This guide covers the detection side only: which Microsoft Entra ID Protection risk detections relate to AiTM and token replay, which sign-in log columns carry the evidence, illustrative hunting queries, how to triage a hit and how to contain it. For how AiTM kits work, which authentication methods resist them and the wider control set, read the AiTM Phishing Guide first. This page does not repeat that material.
This is an independent guide from NHI Mgmt Group, based on Microsoft Entra's public documentation as of November 2026. It is not sponsored or reviewed by Microsoft. Product features change, so confirm settings against Microsoft Entra's current documentation.
Key takeaways
- AiTM succeeds after MFA, so "MFA satisfied" is not evidence of a legitimate user. Detection must focus on what happens to the session after it is issued.
- Entra ID Protection has named detections for this pattern: Attacker in the Middle (
attackerinTheMiddle), Anomalous Token (anomalousToken) and Token issuer anomaly (tokenIssuerAnomaly), plus supporting signals such as Unfamiliar sign-in properties and Suspicious inbox manipulation rules. - Several of these detections are premium and some are calculated offline. Know which ones your licences actually produce before you build alerts on them.
- In the
SigninLogstable, the most useful columns for replay hunting areSessionId,IPAddress,AutonomousSystemNumber,UserAgent,DeviceDetail,IncomingTokenTypeandTokenProtectionStatusDetails. - The core hunting idea is simple: one session identifier seen from more than one network or device profile in a short window deserves a look.
- Response must revoke sessions and then sweep for persistence. Resetting the password alone does not end a stolen session.
What AiTM and token replay look like in the logs
A normal sign-in produces one coherent story: a user on a known device, from an expected network, completes the required authentication and receives a session. In an AiTM attack the story splits into two halves.
The first half is the phishing sign-in. The user enters credentials and approves MFA through the proxy. From Entra ID's point of view the request comes from the proxy's IP address, often hosted infrastructure, with a user agent the kit forwards or substitutes. Authentication succeeds and a session is created.
The second half is the replay. The attacker presents the captured session cookie or token from their own environment. This activity can come from a different IP address, a different autonomous system, a different browser or operating system, and no compliant or registered device. Because the session was already authenticated, the attacker does not need to complete MFA again.
Detection lives in the gap between those halves. You are looking for one of three things:
- A risk detection that Entra ID Protection has already raised against the sign-in or the user.
- A session whose properties change in a way a real user's would not, such as one session identifier appearing from two unrelated networks.
- Post-compromise actions that commonly follow AiTM, such as new inbox rules, new MFA methods or new app consents, shortly after a sign-in from unfamiliar infrastructure.
The ATT&CK techniques that map to this flow are T1557 Adversary-in-the-Middle, T1539 Steal Web Session Cookie and T1550.004 Web Session Cookie for the replay itself.
Entra ID Protection detections that matter
Microsoft documents its risk detections with a display name, a riskEventType value used in the API and logs, whether the detection is real-time or offline, and the licence it needs. The table below lists those most relevant to AiTM and token replay, as Microsoft publishes them.
| Detection | riskEventType | Level | Timing | Licence (per Microsoft) |
|---|---|---|---|---|
| Attacker in the Middle | attackerinTheMiddle | User | Offline | Microsoft 365 E5 with EMS E5 |
| Anomalous Token | anomalousToken | Sign-in and user | Real-time or offline | Entra ID P2 |
| Token issuer anomaly | tokenIssuerAnomaly | Sign-in | Offline | Entra ID P2 |
| Unfamiliar sign-in properties | unfamiliarFeatures | Sign-in | Real-time | Entra ID P2 |
| Malicious IP address | maliciousIPAddress | Sign-in | Offline | Entra ID P2 |
| Atypical travel | unlikelyTravel | Sign-in | Real-time | Entra ID P2 |
| Suspicious inbox manipulation rules | mcasSuspiciousInboxManipulationRules | Sign-in | Offline | Entra ID P2 plus Defender for Cloud Apps, or Microsoft 365 E5 with EMS E5 |
| Suspicious inbox forwarding | suspiciousInboxForwarding | Sign-in | Offline | Entra ID P2 plus Defender for Cloud Apps, or Microsoft 365 E5 with EMS E5 |
| Possible attempt to access Primary Refresh Token (PRT) | attemptedPrtAccess | User | Offline | Entra ID P2 plus Defender for Cloud Apps, or Microsoft 365 E5 with EMS E5 |
| Suspicious credential addition | suspiciousCredentialAddition | User | Real-time | Entra ID P2 |
Three practical points follow from Microsoft's documentation.
Watch the casing. Microsoft lists the Attacker in the Middle value as attackerinTheMiddle, with a lower-case "i" in "in". String comparisons in KQL with == are case-sensitive, so use the exact value or a case-insensitive operator such as =~.
Know what lower licence tiers see. Tenants on Entra ID Free or P1 receive premium detections under the generic label "Additional risk detected" with the value generic. If your rules key on anomalousToken and you do not have P2, they will never fire. Likewise, the RiskLevelDuringSignIn column in sign-in logs returns hidden for customers without P2, according to Microsoft's table reference.
Offline means later. Offline detections are calculated after the sign-in. A detection such as Attacker in the Middle or Token issuer anomaly may arrive some time after the attacker has already used the session. Build your triage so that an offline detection triggers a look back over the user's recent activity, not just the single sign-in it is attached to.
Sign-in log columns to use
If you stream Entra ID sign-in logs to a Log Analytics workspace, they land in the SigninLogs table. Microsoft's table reference describes the columns below. These are the ones that carry most of the AiTM and replay evidence.
| Column | What Microsoft says it holds | Why it matters for AiTM |
|---|---|---|
SessionId | The ID of the session generated during the sign-in | Lets you follow one session across sign-ins and spot it moving between networks |
UniqueTokenIdentifier | A request identifier used to track tokens as they are redeemed at resource providers | Pivot from a sign-in to where the token was used |
OriginalRequestId | The request identifier of the first request in the authentication sequence | Groups the steps of one authentication flow |
IPAddress | The client IP address of the sign-in | Proxy and replay infrastructure usually differ from the user's network |
AutonomousSystemNumber | The ASN of the network used | Hosting and VPS networks stand out against residential and corporate ASNs |
UserAgent | User agent information for the sign-in | A user agent change inside one session is a strong signal |
DeviceDetail | Device information, including device ID, operating system and browser | Replay from an unregistered device shows an empty or different device ID |
AuthenticationRequirement | The highest level of authentication needed through all sign-in steps | Separates sign-ins that required MFA from single-factor ones |
AuthenticationDetails | The result of the authentication attempt and method details | Shows which method was used and whether a prior claim was reused |
IncomingTokenType | The type of token used to sign in, for example primary refresh token or SAML assertion | Helps tell a fresh interactive sign-in from token-based access |
TokenProtectionStatusDetails | Whether the sign-in token was bound to the device | Unbound tokens on apps you intend to protect are a gap; bound tokens cannot be replayed elsewhere |
RiskEventTypes_V2 | The list of risk event types associated with the sign-in | Filter for real-time risk on the sign-in itself |
RiskLevelDuringSignIn | Risk level during sign-in: none, low, medium, high or hidden | Quick triage filter, P2 only |
ConditionalAccessStatus | success, failure or notApplied | A notApplied result on a sensitive app can mean a policy gap the attacker used |
ResultType | The error code; 0 indicates success | Most replay you care about has succeeded |
AppDisplayName | The application name | AiTM kits commonly target the Microsoft 365 sign-in, so mail and file apps are the usual first stop |
For user-level risk detections, the AADUserRiskEvents table holds RiskEventType, DetectionTimingType, IpAddress, Location, RequestId, CorrelationId, UserPrincipalName, RiskLevel, RiskState, Source, TokenIssuerType, AdditionalInfo and ActivityDateTime. Microsoft notes that RequestId and CorrelationId are null when the detection is not associated with a sign-in, which is often the case for offline user-level detections.
Microsoft's token protection guidance also recommends capturing both interactive and non-interactive sign-in logs. Replay of a stolen session often shows up as non-interactive activity, so make sure both are collected before you rely on any of the hunts below.
Illustrative hunting queries
The queries below are illustrative starting points written by NHI Mgmt Group. They use only column names from Microsoft's published table references. Test them in your own workspace, set the time range in the query pane, and tune thresholds to your environment before you turn any of them into a scheduled rule.
1. Pull named AiTM and token risk detections
This lists user risk events of the types most associated with AiTM and replay, with their timing and state.
AADUserRiskEvents
| where RiskEventType in~ ("attackerinTheMiddle", "anomalousToken", "tokenIssuerAnomaly", "attemptedPrtAccess")
| project ActivityDateTime, UserPrincipalName, RiskEventType, DetectionTimingType, RiskLevel, RiskState, IpAddress, Location, TokenIssuerType, RequestId
| order by ActivityDateTime desc
Use the in~ operator so that casing differences in attackerinTheMiddle do not cause misses. Treat any result with RiskState of atRisk as open work.
2. One session, more than one network
This is the core replay hunt. It groups successful sign-ins by SessionId and flags sessions that appear from more than one IP address or ASN.
SigninLogs
| where ResultType == "0" and isnotempty(SessionId)
| summarize IPs = dcount(IPAddress), ASNs = dcount(AutonomousSystemNumber), Agents = dcount(UserAgent), IPList = make_set(IPAddress, 10), AsnList = make_set(AutonomousSystemNumber, 10), Apps = make_set(AppDisplayName, 10) by SessionId
| where ASNs > 1 or Agents > 1
| order by ASNs desc
Expect some noise. Users move between home broadband, mobile data and the corporate network, and some mobile carriers rotate addresses. A change of ASN within a session is much more interesting when one of the ASNs belongs to a hosting provider, or when the user agent also changes.
3. Successful MFA sign-ins with risk attached
AiTM sign-ins satisfy MFA. This query finds successful sign-ins that required MFA and still carried real-time risk.
SigninLogs
| where ResultType == "0"
| where AuthenticationRequirement == "multiFactorAuthentication"
| where RiskLevelDuringSignIn in ("medium", "high") or RiskEventTypes_V2 has_any ("unfamiliarFeatures", "maliciousIPAddress", "anonymizedIPAddress", "unlikelyTravel")
| project SessionId, IPAddress, AutonomousSystemNumber, UserAgent, DeviceDetail, AppDisplayName, RiskLevelDuringSignIn, RiskEventTypes_V2, ConditionalAccessStatus
Check the exact string your tenant records in AuthenticationRequirement before relying on the filter. Microsoft describes the column but the value format can differ from what you expect, so look at a sample of rows first.
4. Unbound tokens on apps you intend to protect
If you have started deploying token protection, look for sign-ins where the token was not bound. TokenProtectionStatusDetails is a dynamic column, so inspect a few rows to learn its structure in your tenant before filtering on a property.
SigninLogs
| where AppDisplayName in ("Office 365 Exchange Online", "Office 365 SharePoint Online", "Microsoft Teams")
| where isnotempty(TokenProtectionStatusDetails)
| project SessionId, AppDisplayName, IPAddress, DeviceDetail, TokenProtectionStatusDetails
| take 50
The application display names here are examples. Confirm how the apps appear in your own logs.
5. Sign-ins with no device identity
Replay from attacker infrastructure usually comes from a browser with no registered or joined device. This query surfaces successful sign-ins to mail and file apps where DeviceDetail carries no device ID.
SigninLogs
| where ResultType == "0"
| extend DeviceId = tostring(DeviceDetail.deviceId)
| where isempty(DeviceId)
| summarize count(), IPList = make_set(IPAddress, 10), AsnList = make_set(AutonomousSystemNumber, 10) by AppDisplayName, UserAgent
| order by count_ desc
On its own this is a baseline, not an alert. Unmanaged access is normal in many tenants. Its value is in showing which ASNs and user agents normally appear, so that the odd one stands out.
Triage: confirming a stolen session
When a detection or hunt returns a hit, work through these questions in order. Each one either strengthens or weakens the case for a stolen session.
- Is there a phishing sign-in before the suspicious activity? Look for a successful sign-in with MFA from an unfamiliar IP address or hosting ASN shortly before the replay. The phishing half and the replay half often come from different infrastructure.
- Does the session change shape? Compare
IPAddress,AutonomousSystemNumber,UserAgentandDeviceDetailacross all sign-ins with the sameSessionId. A real user rarely switches operating system mid-session. - Did the user recently click something? Check with the user and with your email security tooling for a recent phishing message, especially one that led to a Microsoft-branded sign-in page.
- What did the session do? Follow
UniqueTokenIdentifierand the session into mailbox and file activity. Reading mail, searching for finance or payment terms and downloading files are common first actions. - Has persistence been added? Look for new inbox rules, mail forwarding, newly registered MFA methods, new device registrations and new OAuth consents for the user. The Suspicious inbox manipulation rules and Suspicious credential addition detections are useful corroboration here.
- Is it one user or a campaign? Search for the same IP addresses, ASNs and user agents across other users. AiTM campaigns usually target many recipients at once.
If two or more of these line up, treat the account as compromised and move to containment. Microsoft's detection list also includes an Admin confirmed user compromised detection (adminConfirmedUserCompromised) that you can use to keep confirmed cases visible in risk reporting.
Containment and response
Speed matters because the attacker already holds a valid session. Order of operations:
- Revoke sessions. Microsoft Graph's
revokeSignInSessionsaction invalidates all refresh tokens issued to applications for the user, and session cookies in the user's browser, by resetting the user'ssignInSessionsValidFromDateTimeproperty. Microsoft notes there can be a delay of a few minutes before tokens are revoked. The least privileged permission isUser.RevokeSessions.All. - Reset the password. Do this alongside revocation, not instead of it. A password reset on its own does not end a session the attacker already holds.
- Remove attacker-added authentication methods. Review the user's registered methods and delete any the user does not recognise.
- Sweep for persistence. Inbox rules, forwarding, app consents and device registrations can all survive a password reset. The companion guide How to check a recovered account for leftover persistence covers that sweep.
- Block the infrastructure. Add the attacker's IP addresses to a named location used by a blocking Conditional Access policy, and search for other users who signed in from them.
- Look for business email compromise follow-on. Check sent items and any outbound messages from the account during the compromise window, and warn recipients if fraudulent messages were sent.
The Account Takeover Response Playbook gives a full template for roles, communications and post-incident review.
Reducing what detection has to catch
Detection is the safety net. The fewer stolen sessions that can be replayed, the less your SOC has to chase. Two controls interact directly with the detections above.
Token protection. Microsoft describes token protection as creating a cryptographic tie between sign-in session tokens and the device they were issued to, so that a stolen token cannot be used from another device. According to Microsoft's documentation, native applications on Windows, iOS and iPadOS, and macOS are generally available, with browser support in preview for selected web apps accessing Azure Resource Manager. Supported native resources include Exchange Online, SharePoint Online and Microsoft Teams. Microsoft recommends starting the Conditional Access policy in report-only mode with a pilot group, analysing interactive and non-interactive sign-in logs over a period that covers normal use, and then enforcing. Once enforced, the TokenProtectionStatusDetails column becomes a useful coverage measure. See the Entra Token Protection Guide for rollout detail.
Risk-based Conditional Access. Where you have P2, policies that require reauthentication or block access on high sign-in or user risk turn real-time detections into enforcement. Offline detections cannot block the original sign-in, which is why session revocation remains part of the response. The Conditional Access Guide covers policy design.
Phishing-resistant authentication, such as FIDO2 security keys and Windows Hello for Business, removes the proxy's ability to relay authentication in the first place. Coverage of those methods, and why they resist AiTM, is in the AiTM Phishing Guide.
Common failure patterns
- Trusting "MFA satisfied". Analysts close alerts because the sign-in passed MFA. With AiTM, passing MFA is expected.
- Rules on detections the tenant never produces. Alerts keyed on
anomalousTokenorattackerinTheMiddlein a tenant without the required licence silently never fire, while the real signal arrives asgeneric. - Case-sensitive mismatches. A rule written with
attackerInTheMiddleand a case-sensitive comparison misses Microsoft's documented value. - Interactive logs only. Replay often appears as non-interactive activity. Collecting only interactive sign-ins hides it.
- Treating offline detections as point-in-time. An offline detection is investigated against one sign-in, while the attacker's activity from the preceding hours is not reviewed.
- Password reset without revocation. The account is "recovered" but the attacker's session keeps working until it expires or is revoked.
- No persistence sweep. Sessions are revoked, but an inbox rule or app consent added during the compromise keeps the attacker's access or visibility.
- Single-user scope. The one reported user is cleaned up while other recipients of the same campaign are never checked.
Practitioner checklist
- Confirm which Entra ID Protection detections your licences produce, and whether lower-tier users see
genericinstead. - Stream interactive and non-interactive sign-in logs, plus user risk events, to your SIEM or Log Analytics workspace.
- Build an alert on
attackerinTheMiddle,anomalousTokenandtokenIssuerAnomalyusing case-insensitive matching. - Run the one-session-many-networks hunt weekly and tune it against your own ASN and user agent baseline.
- Document a triage runbook that checks for a preceding phishing sign-in, session shape changes, post-compromise actions and campaign spread.
- Make session revocation with
revokeSignInSessionsthe first containment step, alongside a password reset. - Run a full persistence sweep on every confirmed AiTM account before closing the case.
- Pilot token protection in report-only mode, then use
TokenProtectionStatusDetailsto measure coverage. - Add risk-based Conditional Access where licensing allows, and track how many AiTM detections were blocked rather than detected after the fact.
Standards and references
- Microsoft Learn: What are risk detections? (Microsoft Entra ID Protection)
- Microsoft Learn: SigninLogs table reference
- Microsoft Learn: AADUserRiskEvents table reference
- Microsoft Learn: Token protection in Microsoft Entra Conditional Access
- Microsoft Learn: user: revokeSignInSessions
- MITRE ATT&CK: T1557 Adversary-in-the-Middle
- MITRE ATT&CK: T1539 Steal Web Session Cookie
- CISA: Implementing Phishing-Resistant MFA
Related NHI Mgmt Group resources: AiTM Phishing Guide · Entra Token Protection Guide · Session Hijacking and Cookie Theft Guide · Account Takeover Response Playbook