How the attack works
When a user signs in, Microsoft Entra ID hands out tokens that stand for the completed sign-in: a session cookie in the browser, refresh tokens for applications and, on a registered device, a Primary Refresh Token (PRT). Whoever presents a valid token is treated as the user, and because multifactor authentication was already satisfied when the token was issued, it is not asked for again. Stealing a token is therefore a way around both the password and MFA.
Attackers get tokens in two ways. In adversary-in-the-middle (AiTM) phishing the user is lured to a proxy that sits between them and the real sign-in page. The user types the password and completes MFA, the proxy passes everything through, and it keeps the session cookie that Microsoft Entra ID issues at the end. The other way is malware on a device where the user is signed in, which takes cookies and tokens from the device or tries to reach the PRT.
The attacker then replays the token from their own infrastructure. In the sign-in log this is an ordinary successful sign-in, so the useful signals come from Microsoft Entra ID Protection. "Attacker in the Middle" (attackerinTheMiddle) is raised when an authentication session is linked to a malicious reverse proxy. "Anomalous token" (anomalousToken) is raised for a session token or refresh token with abnormal characteristics, such as an unusual lifetime or use from an unfamiliar location. "Possible attempt to access Primary Refresh Token (PRT)" (attemptedPrtAccess) is based on Microsoft Defender for Endpoint.
These detections need licenses. Anomalous token needs Microsoft Entra ID P2. Attacker in the Middle needs Microsoft 365 E5 with Enterprise Mobility + Security E5. For the PRT detection Microsoft lists Microsoft Entra ID P2 with a standalone Microsoft Defender for Cloud Apps license, or that same E5 combination, and it fires only where Defender for Endpoint is deployed. All three are written to the risk detections report and, through the UserRiskEvents diagnostic setting, to the AADUserRiskEvents table. A fourth rule reads the Microsoft Graph activity log, which records the client address and the sign-in activity identifier of every Graph request, and counts the addresses that used one user token. It is a hint and not proof, because mobile networks and egress proxies change the address of a legitimate client.
What an attacker needs
- A user who can be led to a sign-in page behind the attacker's proxy, or malware on a device where the user is signed in.
- An authentication method that still works when it is passed through a proxy, such as a password with a one-time code, an SMS code or a push approval. Phishing-resistant methods do not complete through a proxy.
- No control that ties the session to the user's device, such as a Conditional Access requirement for a compliant device or Token Protection.
Impact
A session as the user that already carries the MFA claim, without the attacker knowing or needing the password. The attacker reads mail and files, and typically registers an authentication method of their own, creates inbox rules or uses the mailbox for fraud. For an administrator the session is control of whatever that role manages. The access lasts as long as the stolen token is valid, so it has to be revoked, not waited out.
Detection rules
ID Protection Detected an Anomalous Token
Detects the Microsoft Entra ID Protection risk detection "Anomalous token" (riskEventType anomalousToken). Microsoft raises it for session tokens and refresh tokens with abnormal characteristics, such as an unusual lifetime or a token played from an unfamiliar location, and asks administrators to treat it as an indicator of potential token replay when the location, application, IP address, user agent or other characteristics are unexpected for the user. It exists as a sign-in risk and as a user risk and is calculated in real time or offline. Microsoft states that low and medium risk levels carry a higher than normal chance of false positives, so start with RiskLevel high. It needs Microsoft Entra ID P2. Risk detections reach a SIEM through the UserRiskEvents diagnostic setting of Microsoft Entra ID.
title: ID Protection Detected an Anomalous Token
id: 263eb5f6-dbaf-41e9-a17a-1febd6744538
status: experimental
description: >-
Detects the Microsoft Entra ID Protection risk detection "Anomalous token"
(riskEventType anomalousToken). Microsoft raises it for session tokens and
refresh tokens with abnormal characteristics, such as an unusual lifetime or
a token played from an unfamiliar location, and asks administrators to treat
it as an indicator of potential token replay when the location, application,
IP address, user agent or other characteristics are unexpected for the user.
It exists as a sign-in risk and as a user risk and is calculated in real
time or offline. Microsoft states that low and medium risk levels carry a
higher than normal chance of false positives, so start with RiskLevel high.
It needs Microsoft Entra ID P2. Risk detections reach a SIEM through the
UserRiskEvents diagnostic setting of Microsoft Entra ID.
references:
- https://learn.microsoft.com/en-us/entra/id-protection/concept-identity-protection-risks
- https://learn.microsoft.com/en-us/entra/id-protection/howto-identity-protection-investigate-risk
- https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/aaduserriskevents
- https://attack.mitre.org/techniques/T1539/
- https://attack.mitre.org/techniques/T1550/004/
author: Forestall
date: 2026-11-15
tags:
- attack.credential-access
- attack.lateral-movement
- attack.t1539
- attack.t1550.004
logsource:
product: azure
service: riskdetection
detection:
selection:
RiskEventType: anomalousToken
condition: selection
falsepositives:
- Users who travel, change networks or use a VPN, which changes the properties a token is used with. Compare the detection with the history of the user and confirm the sign-in as safe in ID Protection when it fits. Microsoft reports more false positives at low and medium risk levels.
level: medium
False positives
- Users who travel, change networks or use a VPN, which changes the properties a token is used with. Compare the detection with the history of the user and confirm the sign-in as safe in ID Protection when it fits. Microsoft reports more false positives at low and medium risk levels.
ID Protection Detected an Attacker-in-the-Middle Session
Detects the Microsoft Entra ID Protection risk detection "Attacker in the Middle" (riskEventType attackerinTheMiddle). Microsoft raises it when an authentication session is linked to a malicious reverse proxy, which can intercept the credentials of the user and the tokens issued to the user, and it sets the user to high risk. Microsoft calls it a high precision detection and recommends a manual investigation of the user. It is calculated offline, so it arrives after the sign-in. It needs Microsoft 365 E5 with Enterprise Mobility + Security E5. Risk detections reach a SIEM through the UserRiskEvents diagnostic setting of Microsoft Entra ID.
title: ID Protection Detected an Attacker-in-the-Middle Session
id: c886bba3-42e7-476b-9fc7-20052294f8cc
status: experimental
description: >-
Detects the Microsoft Entra ID Protection risk detection "Attacker in the
Middle" (riskEventType attackerinTheMiddle). Microsoft raises it when an
authentication session is linked to a malicious reverse proxy, which can
intercept the credentials of the user and the tokens issued to the user, and
it sets the user to high risk. Microsoft calls it a high precision detection
and recommends a manual investigation of the user. It is calculated offline,
so it arrives after the sign-in. It needs Microsoft 365 E5 with Enterprise
Mobility + Security E5. Risk detections reach a SIEM through the
UserRiskEvents diagnostic setting of Microsoft Entra ID.
references:
- https://learn.microsoft.com/en-us/entra/id-protection/concept-identity-protection-risks
- https://learn.microsoft.com/en-us/graph/api/resources/riskdetection?view=graph-rest-beta
- https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/aaduserriskevents
- https://attack.mitre.org/techniques/T1539/
author: Forestall
date: 2026-11-15
tags:
- attack.credential-access
- attack.t1539
logsource:
product: azure
service: riskdetection
detection:
selection:
RiskEventType: attackerinTheMiddle
condition: selection
falsepositives:
- None documented. Microsoft describes the detection as high precision, so investigate every event before dismissing it.
level: high
False positives
- None documented. Microsoft describes the detection as high precision, so investigate every event before dismissing it.
One User Token Used for Microsoft Graph From Several IP Addresses
Counts the distinct client IP addresses that made Microsoft Graph requests with the same user token. The Microsoft Graph activity log records the client address of every request in IPAddress and the sign-in activity behind its token in SignInActivityId, which Microsoft's sample query joins to UniqueTokenIdentifier in the sign-in logs. A token that was stolen and replayed is used from the attacker's address while the owner's client may still use it from the owner's address. The rule fires when requests with one SignInActivityId come from three or more addresses within one hour. Read it as a hint and not as proof. Mobile networks, a change between Wi-Fi and mobile data, a client that uses IPv4 and IPv6 side by side, and egress proxies or secure web gateways with a pool of addresses all change the address of a legitimate client. In a network with such a proxy the rule fires on ordinary traffic until the proxy ranges are excluded. The threshold and the window are starting points. The log needs Microsoft Entra ID P1 or P2 and a diagnostic setting.
Fires when one SignInActivityId has at least 3 different IPAddress values within 1 hour.
title: Microsoft Graph Request Made With a User Token (Threshold Base Event)
id: 38e9ccb5-a357-4216-922e-c47a446a28a8
name: graph_request_with_user_token
status: experimental
description: >-
Base event of the threshold rule in this file. A Microsoft Graph request
that carries a user identity and a sign-in activity identifier, which ties
the request to the sign-in that issued its token.
logsource:
product: azure
service: graphactivitylogs
detection:
selection:
SignInActivityId|exists: true
UserId|exists: true
condition: selection
level: low
---
title: One User Token Used for Microsoft Graph From Several IP Addresses
id: ba497dd3-cda4-4c9e-8d1a-dfc3688a78ad
status: experimental
description: >-
Counts the distinct client IP addresses that made Microsoft Graph requests
with the same user token. The Microsoft Graph activity log records the
client address of every request in IPAddress and the sign-in activity
behind its token in SignInActivityId, which Microsoft's sample query joins
to UniqueTokenIdentifier in the sign-in logs. A token that was stolen and
replayed is used from the attacker's address while the owner's client may
still use it from the owner's address. The rule fires when requests with
one SignInActivityId come from three or more addresses within one hour.
Read it as a hint and not as proof. Mobile networks, a change between
Wi-Fi and mobile data, a client that uses IPv4 and IPv6 side by side, and
egress proxies or secure web gateways with a pool of addresses all change
the address of a legitimate client. In a network with such a proxy the
rule fires on ordinary traffic until the proxy ranges are excluded. The
threshold and the window are starting points. The log needs Microsoft
Entra ID P1 or P2 and a diagnostic setting.
references:
- https://learn.microsoft.com/en-us/graph/microsoft-graph-activity-logs-overview
- https://learn.microsoft.com/en-us/security/operations/token-theft-playbook
- https://attack.mitre.org/techniques/T1528/
- https://attack.mitre.org/techniques/T1550/004/
author: Forestall
date: 2026-11-18
tags:
- attack.credential-access
- attack.lateral-movement
- attack.t1528
- attack.t1550.004
correlation:
type: value_count
rules:
- graph_request_with_user_token
group-by:
- SignInActivityId
timespan: 1h
condition:
field: IPAddress
gte: 3
falsepositives:
- Users on mobile networks or on the move, whose address changes during the life of a token.
- Clients that reach Microsoft Graph over IPv4 and IPv6 at the same time, and split-tunnel VPN clients.
- Egress proxies, secure web gateways and virtual desktop pools that send one client's requests from several addresses. Exclude their ranges, or count only addresses outside them.
- The values of three addresses and one hour are starting points, not tested limits. Compare the addresses in the matching events with the IP address of the sign-in before you act.
level: low
False positives
- Users on mobile networks or on the move, whose address changes during the life of a token.
- Clients that reach Microsoft Graph over IPv4 and IPv6 at the same time, and split-tunnel VPN clients.
- Egress proxies, secure web gateways and virtual desktop pools that send one client's requests from several addresses. Exclude their ranges, or count only addresses outside them.
- The values of three addresses and one hour are starting points, not tested limits. Compare the addresses in the matching events with the IP address of the sign-in before you act.
ID Protection Reported an Attempt to Access a Primary Refresh Token
Detects the Microsoft Entra ID Protection risk detection "Possible attempt to access Primary Refresh Token (PRT)". The riskEventType is attemptedPrtAccess on the ID Protection page, and the Microsoft Graph beta reference writes it attemptedPRTAccess. The detection is based on information from Microsoft Defender for Endpoint, moves the user to high risk and fires only in organizations that deploy Defender for Endpoint. A PRT gives single sign-on to every application the user can reach from a registered device, which is why attackers try to get at it. Microsoft describes the detection as low volume and recommends prompt remediation. It is calculated offline. Microsoft lists Microsoft Entra ID P2 with a standalone Microsoft Defender for Cloud Apps license, or Microsoft 365 E5 with Enterprise Mobility + Security E5, as the license requirement.
title: ID Protection Reported an Attempt to Access a Primary Refresh Token
id: 864073dc-3f82-407e-90d4-f12ea1cde6b3
status: experimental
description: >-
Detects the Microsoft Entra ID Protection risk detection "Possible attempt
to access Primary Refresh Token (PRT)". The riskEventType is
attemptedPrtAccess on the ID Protection page, and the Microsoft Graph beta
reference writes it attemptedPRTAccess. The detection is based on
information from Microsoft Defender for Endpoint, moves the user to high
risk and fires only in organizations that deploy Defender for Endpoint. A
PRT gives single sign-on to every application the user can reach from a
registered device, which is why attackers try to get at it. Microsoft
describes the detection as low volume and recommends prompt remediation. It
is calculated offline. Microsoft lists Microsoft Entra ID P2 with a
standalone Microsoft Defender for Cloud Apps license, or Microsoft 365 E5
with Enterprise Mobility + Security E5, as the license requirement.
references:
- https://learn.microsoft.com/en-us/entra/id-protection/concept-identity-protection-risks
- https://learn.microsoft.com/en-us/graph/api/resources/riskdetection?view=graph-rest-beta
- https://learn.microsoft.com/en-us/azure/azure-monitor/reference/tables/aaduserriskevents
- https://attack.mitre.org/techniques/T1528/
author: Forestall
date: 2026-11-15
tags:
- attack.credential-access
- attack.t1528
logsource:
product: azure
service: riskdetection
detection:
selection:
RiskEventType: attemptedPrtAccess
condition: selection
falsepositives:
- None documented. Open the Microsoft Defender for Endpoint alert behind the detection and check which process on the device touched the token.
level: high
False positives
- None documented. Open the Microsoft Defender for Endpoint alert behind the detection and check which process on the device touched the token.
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.
Graph requests of a token from an address other than the one it was issued to
A token is issued to the address the user signed in from. When a phishing proxy or malware hands it to an attacker, the requests made with it come from somewhere else. Comparing the address of each Graph request with the address of the sign-in behind its token shows the replay without waiting for a risk detection.
- Microsoft Graph activity log: take
SignInActivityId,IPAddress,UserIdandUserAgentof the requests. - Join to the sign-in logs (interactive and non-interactive) on
SignInActivityIdequal toUniqueTokenIdentifier, as Microsoft's sample query does, and take theIPAddressof the sign-in. - Keep the requests whose address differs from the sign-in address and is outside your known egress ranges.
- Alert when such requests exist for a user, and raise the priority when the user agent of the requests also differs from the one the user normally has.
LimitsRoaming clients, split-tunnel VPNs and egress proxies with address pools produce the same difference, so the known ranges have to be excluded first. Microsoft notes that activity logs from Microsoft applications might not all have matching sign-in log entries, so some requests cannot be joined. It sees Microsoft Graph only.
One sign-in session used from two networks within minutes
A stolen session cookie or refresh token carries the session of the sign-in it came from. When the attacker replays it while the user keeps working, sign-ins of one session arrive from two networks at the same time, which one person on one device does not produce. The sign-in logs record the session identifier, the address, the network and the device of each sign-in.
- Interactive and non-interactive sign-in logs: successful sign-ins (
ResultType0) withUserPrincipalName,SessionId,IPAddress,AutonomousSystemNumber,UserAgentandDeviceDetail. - Group the sign-ins of each
SessionIdin windows of 10 minutes. - Keep sessions with two or more
AutonomousSystemNumbervalues in one window, or two operating systems inDeviceDetail, after removing your own egress ranges and VPN providers. - Alert, and raise the priority when one of the networks is new for the user or a sign-in of the session also carries an ID Protection risk.
LimitsPhones that switch between Wi-Fi and mobile data, split-tunnel VPN clients and secure web gateways change the network of a legitimate session, so their ranges have to be excluded first. Microsoft does not document how long a session keeps its SessionId; check in your own logs that the sign-ins of one session share it. The 10 minutes are a starting point.
Token theft risk detection followed by new persistence on the same account
An attacker with a stolen session usually secures the access before the token expires: a new authentication method, a registered device or a consent to an application. Microsoft's token theft playbook names these changes as the signs to look for. Joining the token detections to the audit log of the same user separates a replay that was used from one that was not.
- Risk detections (
AADUserRiskEventsin Microsoft Sentinel):RiskEventTypeanomalousToken or attackerinTheMiddle. TakeUserPrincipalName,IpAddressand the detection time. - Audit log, from 24 hours before to 72 hours after the detection:
User registered security info,Add registered owner to deviceorConsent to applicationwith that user inTargetResourcesorInitiatedBy. - Compare the address of the change, the
ipAddressof the user inInitiatedBy, with theIpAddressof the detection and with the user's usual addresses. - Alert on any match, and treat the added method, device or consent as the attacker's until the user confirms it.
EventsanomalousTokenattackerinTheMiddleUser registered security infoAdd registered owner to deviceConsent to application
LimitsUsers register methods and devices for good reasons, so a match needs the user's confirmation. The detections need Microsoft Entra ID P2 or Microsoft 365 E5 and arrive offline, sometimes hours after the sign-in. Inbox and forwarding rules, which the playbook also names, are in the Exchange audit log and not in this join. The windows are starting points.
Triage
- Read the detection. RiskEventType, RiskLevel, DetectionTimingType, IpAddress, Location and the user agent in AdditionalInfo say what was seen and from where.
- Find the sign-in the detection belongs to with CorrelationId or RequestId, and compare its location, application, IP address, user agent and device with the normal sign-ins of the user.
- For an anomalous token at low or medium risk, keep in mind that Microsoft reports a higher than normal share of false positives. Unexpected properties together with activity the user cannot explain make it real.
- Review what the session did (new authentication methods, inbox rules, application consent, file downloads, mail sent).
- Ask the user whether they followed a link and signed in shortly before the detection. Use a channel other than the mail or chat of that account, which may be in the hands of the attacker.
Response
Once the attack is confirmed:
- Revoke the sessions and refresh tokens of the user at once, and block sign-in for the account while the attacker is still active.
- Reset the password through a secure reset, and remove every authentication method the user does not recognize before they register again.
- Confirm the user as compromised in ID Protection, so the user risk is recorded and risk policies apply.
- Remove what the attacker left behind, such as inbox and forwarding rules, application consents and registered devices, and warn the recipients of mail sent in the name of the user.
- When the token came from a device (the PRT detection, or malware), isolate the device, investigate it and rebuild it before the user signs in on it again.
- Search the sign-in log for other users with sign-ins from the same IP address or after the same phishing message, and handle them in the same way.
Mitigation
- Move users, administrators first, to phishing-resistant authentication (FIDO2 security keys, passkeys, Windows Hello for Business, certificate-based authentication). A proxy cannot relay these methods.
- Require a compliant or Microsoft Entra hybrid joined device in Conditional Access, so that a sign-in through a proxy on an unmanaged machine is not given a token.
- Enforce Token Protection in Conditional Access for the applications and platforms that support it, so that a sign-in session token is accepted only from the device it was issued to.
- With Microsoft Entra ID P2, use sign-in risk and user risk policies that block access, or require reauthentication and a secure password change, at high risk.
- Send the
UserRiskEventsdiagnostic category to your SIEM and alert on the token-related risk detections. - Harden devices against malware that steals tokens and keep endpoint protection on every device that holds a session.
Frequently asked questions
Does MFA stop adversary-in-the-middle phishing?
Not the methods that can be relayed. The proxy passes the password and the MFA step through to the real sign-in page and keeps the session cookie that is issued afterwards, so one-time codes, SMS codes and push approvals do not help. Phishing-resistant methods such as FIDO2 security keys, passkeys, Windows Hello for Business and certificate-based authentication are tied to the genuine site and do not complete through a proxy.
Which licenses do the token theft risk detections need?
Anomalous token needs Microsoft Entra ID P2. Attacker in the Middle needs Microsoft 365 E5 with Enterprise Mobility + Security E5. For the Primary Refresh Token detection Microsoft lists Microsoft Entra ID P2 with a standalone Microsoft Defender for Cloud Apps license, or Microsoft 365 E5 with Enterprise Mobility + Security E5, and it fires only where Microsoft Defender for Endpoint is deployed. Without Microsoft Entra ID P2, premium detections appear as "Additional risk detected" with the type generic.
Is a password reset enough after a token was stolen?
No. The attacker holds a token, not only the password, so the session itself has to be ended. Revoke the sessions and refresh tokens of the user, reset the password, and check the authentication methods and inbox rules of the account, because an attacker who was signed in may have added their own. Microsoft notes that clearing the Attacker in the Middle risk might require a secure password reset or the revocation of existing sessions.
Why does the sign-in log not show a stolen token on its own?
A replayed token produces a normal successful sign-in for the user, with no password prompt and no MFA challenge that could fail. What gives it away are properties that do not fit the user, such as the location, IP address, user agent or device. Comparing those properties with the history of the user is what the ID Protection detections do.
References
- MITRE ATT&CK T1539: Steal Web Session Cookie
- MITRE ATT&CK T1528: Steal Application Access Token
- MITRE ATT&CK T1550.004: Use Alternate Authentication Material: Web Session Cookie
- What are risk detections? (Anomalous token, Attacker in the Middle, Possible attempt to access Primary Refresh Token)
- riskDetection resource type (riskEventType values)
- AADUserRiskEvents table reference
- How to export risk data (UserRiskEvents diagnostic setting)
- How to investigate risk (anomalous token and token issuer anomaly detections)
- Protecting tokens in Microsoft Entra
- Token Protection in Microsoft Entra Conditional Access
- Token theft playbook
- SigninLogs table reference (SessionId, OriginalTransferMethod, AutonomousSystemNumber, TokenIssuerName, AuthenticationProcessingDetails)
- AADNonInteractiveUserSignInLogs table reference
- Microsoft Entra audit log activities
- userIdentity resource type (ipAddress of the user who initiated an audited activity)