Overview
This lab deploys a five-rule detection stack for infostealer session hijacking to an existing Microsoft Sentinel workspace. Infostealers can steal browser cookies and session tokens that carry claims from an earlier MFA-protected sign-in, allowing an attacker to replay the session without repeating the victim’s interactive password and MFA ceremony while the session remains valid. The detection rules focus on the behavioral anomalies that stolen-token replay leaves in Entra ID non-interactive sign-in logs.
Blog post: Detecting Infostealer Session Hijacking with Microsoft Sentinel
Reviewed source: j-dahl7/session-hijack-detection-sentinel at 9cec443
Prerequisites
| Requirement | Details |
|---|---|
| Azure subscription | With Microsoft Sentinel enabled on a Log Analytics workspace |
| Entra ID P2 | For Identity Protection risk scoring and sign-in risk signals |
| Diagnostic settings | SigninLogs and NonInteractiveUserSignInLogs routed to the workspace |
| Azure CLI and RBAC | az CLI authenticated with Microsoft Sentinel Contributor for the workspace, Workbook Contributor for shared-workbook creation, and read access to inspect the workspace and diagnostic settings |
| PowerShell 7+ | For running deployment and simulation scripts |
Quick Start
# Clone the companion repo
git clone https://github.com/j-dahl7/session-hijack-detection-sentinel.git
cd session-hijack-detection-sentinel
git checkout 9cec4432e0f14b83cf871da90b0323273b8a8d37
# Deploy to your Sentinel workspace
./scripts/Deploy-Lab.ps1 -ResourceGroup "rg-sentinel-lab" -WorkspaceName "law-sentinel-lab"
# Run the simulation
./scripts/Test-SessionHijack.ps1
What Gets Deployed
| Resource | Type | MITRE |
|---|---|---|
| LAB - Token Replay from New Device or IP | Analytics Rule (High) | Unfamiliar user/IP/device-ID tuple; a new combination does not prove either value is globally new. T1539, T1550.001 |
| LAB - Impossible Travel on Token Refresh | Analytics Rule (High) | 500 km/h triage threshold; legitimate flights, VPN egress, and GeoIP error require context and tenant tuning. T1539 |
| LAB - Anomalous Non-Interactive Sign-in Surge | Analytics Rule (Medium) | T1539, T1550.001 |
| LAB - Browser or OS Mismatch in Same Session | Analytics Rule (Medium) | T1539, T1550.001 |
| LAB - Revoked Grant Followed by New-IP Authentication | Analytics Rule (High) | Entra error 50173, then a same-UserId success from a different IP; triage lead, not proof of theft or CAE. T1539, T1550.001 |
| Session Hijack Threat Dashboard | Workbook | โ |
Test Scenarios
Test-SessionHijack.ps1 is a safe connectivity and seed-activity helper, not a deterministic incident generator:
- Varied Graph request headers โ validates five low-privilege
/merequests; those headers are not guaranteed to become EntraDeviceDetailfingerprints. - Graph request burst โ validates a controlled request path; cached-token requests do not create one new Entra refresh row per request.
- Current-IP token use โ provides context when the actual token activity produces a new source IP.
- Impossible travel โ still requires controlled token issuance or refresh from a VPN or Azure Cloud Shell region.
- Revoked grant followed by new-IP authentication โ requires an authorized manual sequence: produce a real 50173 row for a dedicated lab user, then authenticate the same immutable
UserIdfrom a different IP within 30 minutes.
Earlier revisions of all five rule families have historical live-incident evidence in the companion article. That evidence does not validate every condition in the current pinned queries: Rule 4 now requires one recorded SessionId; Rule 5 now requires documented error 50173 and correlates both sign-in tables on a nonempty immutable UserId; and Rule 1’s tuple/baseline behavior has changed. It also does not prove the helper caused Rules 3 and 4. Validate the surge rule with real non-interactive token issuance or refresh volume, and validate the fingerprint rule with controlled sign-ins that populate both SessionId and genuinely different DeviceDetail fingerprints for that same recorded session. Impossible travel and the revoked-grant sequence still require the documented manual steps. Error 50173 can also follow password changes, token expiry, or administrator revocation, so a match is a triage lead rather than proof of token theft or CAE enforcement.
Cost Estimate
This lab creates no new workspace or ingestion pipeline; it deploys analytics rules and a shared workbook into an existing Sentinel workspace. Existing Microsoft Sentinel and Log Analytics ingestion, retention, query, and related workspace charges still apply. AADNonInteractiveUserSignInLogs can be high-volume, so review the tenant’s data volume and retention settings before enabling or extending collection.
Cleanup
./scripts/Deploy-Lab.ps1 -ResourceGroup "rg-sentinel-lab" -WorkspaceName "law-sentinel-lab" -Destroy
This removes all 5 analytics rules and the workbook. Diagnostic settings are not modified.
