Investigation · Identity
Was this session cookie stolen by an adversary-in-the-middle phishing kit?
Confirm adversary-in-the-middle session theft in Entra ID: the proxied MFA sign-in, the same session replayed from new infrastructure, and the changes after it.
When you would ask thisA user entered their password and approved MFA on a convincing sign-in page, and the account now shows activity from infrastructure the user does not use, with no failed MFA anywhere. You need to know whether a reverse-proxy phishing kit captured the session cookie and what the attacker did with it.
Steps
- 1
Find the phished sign-in and its risk signals
An adversary-in-the-middle (AiTM) kit, such as Evilginx and its many derivatives, sits between the user and the real Microsoft sign-in page and relays every request. The user completes the genuine password and MFA prompts, so Entra records a successful sign-in with MFA satisfied, and the kit keeps the session cookie Entra issues. Because the proxy makes the request, that sign-in usually comes from the proxy's IP (often a hosting provider ASN), while the user agent can be the victim's own browser passed through. Start with the user's sign-ins around the time they clicked and read RiskLevelDuringSignIn and RiskEventTypes_V2. Entra ID Protection has a detection for this pattern (listed as Attacker in the Middle, riskEventType attackerinTheMiddle, in Microsoft's risk detection reference), alongside related detections such as anomalousToken and unfamiliarFeatures. These need Entra ID P2 and several are calculated offline, so confirm the exact strings and timing in your tenant and treat their absence as inconclusive.
The user's sign-ins with risk and session detail (Sentinel KQL)SigninLogs | where TimeGenerated > ago(14d) | where UserPrincipalName =~ "[email protected]" // Tenant-wide alternative: | where tostring(RiskEventTypes_V2) has "attackerinTheMiddle" | project TimeGenerated, IPAddress, AutonomousSystemNumber, UserAgent, AppDisplayName, ResultType, AuthenticationRequirement, RiskLevelDuringSignIn, RiskEventTypes = tostring(RiskEventTypes_V2), SessionId, UniqueTokenIdentifier | order by TimeGenerated asc - 2
Look for the same SessionId from a second IP, ASN or user agent
This is the core test. When the attacker loads the stolen cookie into their own browser, Entra continues the existing session rather than starting a new one, so the attacker's activity carries the same SessionId as the phished sign-in but arrives from a different IP, ASN or user agent, usually within minutes or hours of it. The replay can be logged as interactive or non-interactive depending on how the client presents the cookie and refreshes tokens, so search SigninLogs and AADNonInteractiveUserSignInLogs together. In the authentication details, replayed sign-ins typically show the MFA requirement as already satisfied by a claim in the token rather than a fresh prompt. One SessionId seen from two unrelated ASNs within a short window, for a user with one device, is strong evidence of cookie theft. Mobile networks and VPN reconnects can also change the IP mid-session, so weigh ASN and user agent, not the IP alone.
Sessions used from more than one ASN or user agent (Sentinel KQL)let user = "[email protected]"; union isfuzzy=true (SigninLogs | project TimeGenerated, UserPrincipalName, ResultType = tostring(ResultType), SessionId, IPAddress, ASN = tostring(AutonomousSystemNumber), UserAgent, Source = "interactive"), (AADNonInteractiveUserSignInLogs | project TimeGenerated, UserPrincipalName, ResultType = tostring(ResultType), SessionId, IPAddress, ASN = tostring(AutonomousSystemNumber), UserAgent, Source = "non-interactive") | where TimeGenerated > ago(14d) | where UserPrincipalName =~ user and ResultType == "0" and isnotempty(SessionId) | summarize FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated), IPs = make_set(IPAddress, 20), ASNs = make_set(ASN, 20), UserAgents = make_set(UserAgent, 20), Sources = make_set(Source) by SessionId | where array_length(ASNs) > 1 or array_length(UserAgents) > 1 | order by FirstSeen asc - 3
Separate the proxy, the replay host and the real user
Build a short table of every IP, ASN and user agent on the suspect sessions and label each one: the user's normal egress (office, home, mobile carrier), the AiTM proxy that relayed the MFA sign-in, and the host the attacker replayed the cookie from (sometimes the same infrastructure as the proxy, sometimes a VPN or residential proxy). Then search the whole tenant for other sign-ins from the proxy and replay IPs, because AiTM campaigns often target many users at once and any other account that authenticated through the same proxy is likely also compromised. Record the UniqueTokenIdentifier values from the attacker's sign-ins; they are the join key into Microsoft Graph activity logs (SignInActivityId) and, where present, the unified audit log AppAccessContext.
Every account seen from the attacker's IPs (Sentinel KQL)let attackerIPs = dynamic(["<proxy-ip>", "<replay-ip>"]); union isfuzzy=true SigninLogs, AADNonInteractiveUserSignInLogs | where TimeGenerated > ago(30d) | where IPAddress in (attackerIPs) | summarize FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated), Apps = make_set(AppDisplayName, 20), Results = make_set(tostring(ResultType), 10) by UserPrincipalName, IPAddress | order by FirstSeen asc - 4
Check what the attacker changed after the replay
AiTM is usually a means to business email compromise, so look for the follow-on changes documented in these campaigns: inbox rules that hide replies (New-InboxRule, Set-InboxRule, UpdateInboxRules), mailbox forwarding (Set-Mailbox), new MFA methods registered so the attacker can sign in again once the cookie expires, device registration, app consent, and outbound phishing from the mailbox to the user's contacts. Filter the unified audit log and the Entra audit log to the attacker's IPs and the incident window. Entra audit activity names for security info registration vary by tenant and change over time, so filter on the Authentication Methods service and confirm the exact OperationName values in your tenant. If mail was read or sent, continue with the mailbox scoping playbook.
MFA, device and consent changes on the account (Sentinel KQL)AuditLogs | where TimeGenerated > ago(14d) | where tostring(TargetResources) has "[email protected]" or tostring(InitiatedBy) has "[email protected]" | where LoggedByService == "Authentication Methods" or OperationName has_any ("security info", "Register device", "Add registered owner to device", "Consent to application") | project TimeGenerated, OperationName, LoggedByService, Result, ActorIP = tostring(InitiatedBy.user.ipAddress) | order by TimeGenerated asc - 5
Scope what the stolen session reached
List the ResourceDisplayName and AppDisplayName values on the attacker's sessions from both sign-in tables; Exchange Online, SharePoint Online and Microsoft Graph are the usual targets. For mail, MailItemsAccessed and Send records tied to the attacker's IPs or session give the read and send record. For Graph, MicrosoftGraphActivityLogs (if it was enabled before the incident) records each API request with the calling AppId, the IPAddress and a SignInActivityId you can match to the UniqueTokenIdentifier values from the sign-in logs. Report every service the session touched, not only mail.
Graph requests made with the attacker's tokens (Sentinel KQL)let tokenIds = dynamic(["<UniqueTokenIdentifier-1>", "<UniqueTokenIdentifier-2>"]); MicrosoftGraphActivityLogs | where TimeGenerated > ago(14d) | where SignInActivityId in (tokenIds) | project TimeGenerated, RequestMethod, RequestUri, ResponseStatusCode, IPAddress, UserAgent, AppId | order by TimeGenerated asc - 6
Contain: revoke the session and close the gap
Revoke the user's sessions, which invalidates refresh tokens and session cookies, then reset the password and remove any MFA methods, devices, inbox rules and app consents the attacker added. Access tokens already issued stay valid until they expire unless the app supports Continuous Access Evaluation, so expect a short tail of activity and keep watching. A password reset alone does not end a stolen session and does not undo attacker-registered MFA. To prevent a repeat, move users toward phishing-resistant methods (passkeys or FIDO2 security keys, Windows Hello for Business, certificate-based authentication), which a relaying proxy cannot complete, and require a compliant or hybrid-joined device in Conditional Access, because the proxy cannot present the user's device identity. Token protection binds tokens to a device, but its coverage of platforms, apps and browser sessions is limited and changing, so check current support before relying on it against browser cookie theft.
Revoke sessions and review registered methods (Microsoft Graph PowerShell)# Connect-MgGraph -Scopes 'User.RevokeSessions.All','UserAuthenticationMethod.Read.All' Revoke-MgUserSignInSession -UserId [email protected] # List registered authentication methods; remove any the user does not recognize. Get-MgUserAuthenticationMethod -UserId [email protected] | Select-Object Id, @{n='Type';e={$_.AdditionalProperties['@odata.type']}}
Where it goes wrong
- A successful sign-in with MFA satisfied is expected in an AiTM case, because the user really did complete MFA through the proxy; MFA success is not evidence against cookie theft.
- The phished MFA sign-in usually comes from the proxy's IP, not the user's, while the user agent can be the victim's real browser passed through, so a familiar user agent does not clear an unfamiliar IP.
- Replayed sessions can land in AADNonInteractiveUserSignInLogs; comparing SessionId values in SigninLogs alone misses much of the attacker's activity.
- Entra ID Protection detections such as attackerinTheMiddle and anomalousToken need Entra ID P2, and offline detections can appear hours after the sign-in; no risk detection does not mean no theft.
- Revoking sessions does not cut off access tokens already issued; apps that do not support Continuous Access Evaluation accept them until they expire, so keep monitoring after containment.
- Several IPs on one SessionId can be innocent (mobile networks, VPN reconnects, IPv4 and IPv6 switching); weigh ASN, user agent, timing and what the session did, not the IP count alone.
Beyond event logs
The phishing lure and click record
The user's mailbox, and Defender for Office 365 URL click data (UrlClickEvents in advanced hunting, or Threat Explorer) where licensed
Shows the lure, the proxy domain and the click time, which anchors the start of the window and finds other recipients who clicked the same link.
Entra ID Protection risk detections
Entra admin center: Risky sign-ins and Risk detections reports; AADUserRiskEvents in Sentinel when exported
Lists each detection, whether it was real-time or offline, and the IP it fired on. Useful corroboration even when the sign-in record showed low risk at the moment of sign-in.
Web proxy and DNS logs
Corporate proxy, secure web gateway or DNS resolver logs for the user's device
Show the user's device resolving and visiting the phishing domain, which confirms the click came from the real user and dates it independently of Microsoft logs.
Keep going
Phishing context
References
- MITRE ATT&CK T1557 Adversary-in-the-Middle
- MITRE ATT&CK T1539 Steal Web Session Cookie
- MITRE ATT&CK T1550.004 Use Alternate Authentication Material: Web Session Cookie
- Microsoft Security: From cookie theft to BEC (AiTM phishing campaign)
- Microsoft Learn: Risk detections in Entra ID Protection
- Microsoft Learn: Token protection in Conditional Access