← All articles
Microsoft Entra ID · Technical field note

Building an impossible-travel candidate hunt without confusing token activity with real travel

Use interactive sign-ins, coordinates and time windows to flag suspicious journeys without treating token refreshes as a person's location.

The detection problem

In August 2025, I worked on impossible-travel detection using Microsoft Sentinel and Entra interactive and non-interactive sign-in logs. The workspace also presented an IdentityInfo table resolution issue even though BehaviorAnalytics was available. The table issue was resolved during troubleshooting, but this article deliberately avoids assuming a particular enrichment table exists.

A change in IP or country is not, by itself, proof of impossible travel. Cloud proxy egress, mobile networks, VPNs, stale geolocation and token refreshes can all create misleading signals.

Build an interactive sign-in baseline

Start with successful interactive user sign-ins. Sort by principal and time; compare consecutive events and calculate approximate geographic distance. This illustrative hunt uses a deliberately conservative distance and speed gate, not a Microsoft default.

kusto
let MaxGap = 6h;
let MinDistanceKm = 500.0;
let MinSpeedKmh = 900.0;
SigninLogs
| where TimeGenerated > ago(1d)
| where ResultType == "0" and IsInteractive == true
| where isnotempty(UserId)
| extend Geo = parse_json(tostring(LocationDetails))
| extend Lat = todouble(Geo.geoCoordinates.latitude),
         Lon = todouble(Geo.geoCoordinates.longitude),
         Country = tostring(Geo.countryOrRegion)
| where isnotnull(Lat) and isnotnull(Lon)
| project TimeGenerated, UserId, UserPrincipalName,
    IPAddress, AppDisplayName, Country, Lat, Lon
| sort by UserId asc, TimeGenerated asc
| serialize
| extend PrevUser = prev(UserId), PrevTime = prev(TimeGenerated),
    PrevIP = prev(IPAddress), PrevCountry = prev(Country),
    PrevLat = prev(Lat), PrevLon = prev(Lon)
| where UserId == PrevUser and IPAddress != PrevIP
| extend Gap = TimeGenerated - PrevTime
| where Gap > 0s and Gap <= MaxGap
| extend DistanceKm = geo_distance_2points(
    PrevLon, PrevLat, Lon, Lat) / 1000.0
| extend SpeedKmh = DistanceKm / (Gap / 1h)
| where DistanceKm >= MinDistanceKm and SpeedKmh >= MinSpeedKmh
| project UserPrincipalName, UserId, PrevTime, TimeGenerated,
    PrevIP, IPAddress, PrevCountry, Country, DistanceKm,
    SpeedKmh, AppDisplayName

Before operationalising this, confirm the location schema and success representation in the tenant. Missing coordinates must not be replaced with zero, which creates artificial geographic jumps. Large tenants need bounded query windows and performance evaluation.

Use non-interactive sign-ins as enrichment

kusto
let principal = "[email protected]";
AADNonInteractiveUserSignInLogs
| where TimeGenerated > ago(1d)
| where UserPrincipalName =~ principal
| project TimeGenerated, IPAddress, AppDisplayName,
    ResultType, AuthenticationRequirement, ConditionalAccessStatus,
    LocationDetails
| order by TimeGenerated asc

A refresh-token event is not evidence of a person physically entering a location. Investigate it as technical session context. The IP associated with non-interactive activity may be recorded differently depending on client and token behavior.

Tune systematically

If IdentityInfo or BehaviorAnalytics is unavailable, verify Sentinel UEBA configuration, ingestion and permissions. The base query should still run independently of identity enrichment.

For scheduled analytics, review frequency, lookback and alert grouping settings separately. In the original troubleshooting an out-of-range LookbackDuration error appeared despite apparently valid scheduling values; do not assume that the schedule is the only duration field. Export and inspect the full rule configuration if the error persists.

Validation

Use a synthetic datatable containing consecutive London and New York coordinates for the same test identity, a plausible local journey, a same-IP event and a missing coordinate case. Verify that the first becomes a candidate and the controls do not. Test proxy and IPv6 scenarios before deploying.

References