Skip to main content

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

RequirementDetails
Azure subscriptionWith Microsoft Sentinel enabled on a Log Analytics workspace
Entra ID P2For Identity Protection risk scoring and sign-in risk signals
Diagnostic settingsSigninLogs and NonInteractiveUserSignInLogs routed to the workspace
Azure CLI and RBACaz 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

ResourceTypeMITRE
LAB - Token Replay from New Device or IPAnalytics 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 RefreshAnalytics 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 SurgeAnalytics Rule (Medium)T1539, T1550.001
LAB - Browser or OS Mismatch in Same SessionAnalytics Rule (Medium)T1539, T1550.001
LAB - Revoked Grant Followed by New-IP AuthenticationAnalytics 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 DashboardWorkbookโ€”

Test Scenarios

Test-SessionHijack.ps1 is a safe connectivity and seed-activity helper, not a deterministic incident generator:

  1. Varied Graph request headers โ€” validates five low-privilege /me requests; those headers are not guaranteed to become Entra DeviceDetail fingerprints.
  2. Graph request burst โ€” validates a controlled request path; cached-token requests do not create one new Entra refresh row per request.
  3. Current-IP token use โ€” provides context when the actual token activity produces a new source IP.
  4. Impossible travel โ€” still requires controlled token issuance or refresh from a VPN or Azure Cloud Shell region.
  5. 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 UserId from 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.