Entra ID & AiTM Detection · T1550.004

Primary Refresh Token (PRT) & Session Cookie Replay Indicators in Entra Logs

Direct Answer (Key Forensic Takeaway)

When infostealer malware or post-exploitation tools extract a Windows Primary Refresh Token (PRT) or browser session cookie (`ESTSAUTH`) from an endpoint, Entra Sign-In logs reveal the stolen sessionId or PRT-bound deviceId suddenly replaying from a foreign hosting/residential IP—often exhibiting mismatched OS/Browser strings or missing device compliance.

Why This Artifact Matters in M365 Incident Response

Not every cloud account takeover begins with an email phishing link. Commodity infostealers (such as Lumma, StealC, and RedLine) and red-team road-token tools routinely dump live Entra browser cookies (`ESTSAUTHPERSISTENT`) or Windows CloudAP Primary Refresh Tokens straight from infected laptops.

Because a stolen PRT already carries an MFA claim and device context, an attacker importing it on another machine bypasses passwords and MFA completely—unless defenders spot the endpoint-to-cloud telemetry mismatch or enforce Entra Token Protection.

When analyzing Entra Sign-In JSON exports in AuditVane, inspect `deviceDetail` (`deviceId`, `operatingSystem`, `browser`, `isManaged`, `isCompliant`), `sessionId`, and `authenticationProcessingDetails` (`Is PRT Present`). A legitimate PRT sign-in originates from the corporate laptop’s IP and maintains consistent OS/Edge metadata.

During cookie or PRT replay, you will frequently see the exact same `sessionId` jump from the employee’s corporate Windows laptop IP to a foreign VPS or residential proxy (`AV-009`), or see a `session` claiming a `Windows 10` device ID simultaneously operating alongside `python-requests` or unmanaged Chrome profiles (`isCompliant: false`).

1. RAW TELEMETRY Entra ID & AiTM Detection T1550.004 2. CLIENT-SIDE PARSE AuditVane Engine PRT replay indicators Entra sign-i 0 Bytes Uploaded 3. SOC OUTCOME Scoped Containment IOCs · CSV · KQL
Local browser DFIR workflow for PRT replay indicators Entra sign-in logs (T1550.004)
AdSense-Ready In-Article Placement

Step-by-Step Attack Reconstruction Timeline

An engineer’s personal Windows laptop executes a trojanized installer that dumps Chrome’s encrypted `ESTSAUTHPERSISTENT` cookies. Two hours later, Entra Sign-In JSON shows the exact `sessionId` previously bound to Austin, TX suddenly making Non-Interactive Exchange and Graph calls from `185.220.101.45` in Amsterdam (`deviceDetail.isCompliant: false`).

Investigators correlate the `sessionId` inside AuditVane, revoke cloud tokens via `Revoke-MgUserSignInSession`, AND isolate the infected endpoint via EDR—preventing the attacker from immediately re-harvesting fresh tokens.

Cross-ASN Cookie / Token Replay Record in Entra Sign-In JSON

{
  "createdDateTime": "2026-12-02T17:15:40Z",
  "userPrincipalName": "dev.ops@contoso-demo.invalid",
  "sessionId": "aa11bb22-33cc-44dd-55ee-667788990011",
  "ipAddress": "185.220.101.45",
  "deviceDetail": {
    "deviceId": "dev-0091-windows",
    "operatingSystem": "Windows 10",
    "browser": "Chrome 131.0",
    "isCompliant": false,
    "isManaged": false
  },
  "location": { "city": "Amsterdam", "countryOrRegion": "NL" }
}

Look at `deviceDetail.isCompliant: false` alongside `sessionId` matching an earlier Austin session—showing a stolen browser session cookie replayed outside the managed corporate workstation.

Forensic Telemetry Fields & High-Signal Indicators

Telemetry Field / Pattern Meaning in M365 / Entra High-Signal Threat Indicator
sessionIdShared across initial auth & stolen token refreshesSame sessionId appearing across 2 ASNs/countries
deviceDetail.deviceIdEntra ID device GUIDCheck if device IP/OS matches corporate EDR telemetry
deviceDetail.isCompliant / isManagedIntune compliance & Entra Join statusReplay from attacker browser often flips to false
authenticationProcessingDetailsContains "Is PRT Present" & token metadataCross-check PRT usage against non-corporate IP
tokenIssuerTypeAzureAD vs. ADFS federated issuerAnomalies expose SAML or token minting abuse
userAgent mismatchSudden shift from Edge/Outlook to script/LinuxStrong sign of cookie export into attacker tooling

Revoke Stolen Cloud Tokens & Inspect Registered Entra Devices

Connect-MgGraph -Scopes "User.ReadWrite.All","Device.ReadWrite.All"
$upn = "dev.ops@domain.com"
Revoke-MgUserSignInSession -UserId $upn
Get-MgUserRegisteredDevice -UserId $upn | Format-Table Id, DisplayName, OperatingSystem, ApproximateLastSignInDateTime, TrustType
# Check Entra Conditional Access Token Protection readiness (requires Entra ID P2)

Sample Registered Devices Review

Id                                   DisplayName     OperatingSystem TrustType
--                                   -----------     --------------- ---------
dev-0091-windows                     DEVOPS-LAPTOP01 Windows         AzureAd

Normal Endpoint PRT Refresh vs. Stolen Cookie / PRT Replay

SignalLegitimate Managed LaptopStolen Cookie / PRT Replay
Source IP & ASNConsistent corporate VPN or employee home ISPSudden jump to hosting provider or foreign residential proxy
sessionId ContinuitySingle IP/device lineageIdentical sessionId used simultaneously from 2 continents
Device ComplianceisCompliant = true, isManaged = trueOften false on browser cookie replay without TPM binding
Remediation NeededNoneBOTH cloud Revoke-MgUserSignInSession AND endpoint EDR wipe!

Step-by-Step Triage, Containment & Verification

  1. Drop Entra Interactive and Non-Interactive Sign-In JSON exports into AuditVane and inspect AV-009 (Multi-Country / IP Hopping).
  2. Check `sessionId` continuity and `deviceDetail.deviceId` / `isCompliant` inside AuditVane’s Flattened Event Inspector.
  3. Run `Revoke-MgUserSignInSession` immediately to invalidate stolen refresh tokens.
  4. Check EDR / Defender for Endpoint on the physical host tied to `deviceId` for infostealers, malicious browser extensions, or LSASS/CloudAP cookie dumping.
  5. If endpoint compromise is confirmed, isolate/reimage the endpoint BEFORE allowing the user to sign back into M365.
  6. Enable **Entra ID Token Protection** (Conditional Access Session Control -> Require token protection for sign-in sessions) on supported Windows apps to cryptographically bind future PRTs/refresh tokens to the endpoint TPM.

How to Verify Containment Completed Cleanly

  • Cloud sessions revoked via Revoke-MgUserSignInSession.
  • Physical endpoint cleared or reimaged in EDR so active infostealers cannot steal newly minted PRTs.
  • Registered Entra devices audited for unexpected attacker-joined Windows/Linux devices.

Analyst Blind Spots, Licensing Quirks & False Positives

The #1 operational mistake in infostealer-driven M365 compromises is resetting the password and revoking cloud tokens while leaving the infostealer active on the employee’s laptop—within 5 minutes of the user logging back in, the malware uploads the fresh cookies straight back to the attacker.

Also watch out for attackers registering their own device (`Add registered users to device`)—check `Get-MgUserRegisteredDevice` during cleanup.

Frequently Asked Questions

How does Microsoft Entra Token Protection stop cookie and PRT theft?

Token Protection binds refresh tokens cryptographically to a hardware-backed TPM key on the Windows device—so even if malware steals the token bytes, replaying them from another machine fails signature verification.

How is PRT/cookie theft different from AiTM phishing?

AiTM captures cookies in transit via a reverse proxy website; PRT/cookie theft extracts them directly off an infected endpoint via infostealers or malicious extensions.

Does AuditVane show flattened deviceDetail fields?

Yes! Click any row in AuditVane to view every flattened deviceDetail.deviceId, operatingSystem, isCompliant, and sessionId value.

Does Revoke-MgUserSignInSession revoke an endpoint PRT?

It invalidates refresh tokens server-side in Entra ID so the stolen PRT cannot obtain new access tokens.

Related Forensics Guides