Anomalous sign-in locations increase


Description

Identify the top three user and application pairs with the steepest increase in sign-in location diversity over 21 days, and list their associated locations.

Query · kql

SigninLogs
| where TimeGenerated > ago(21d)
| extend locationString = strcat(tostring(LocationDetails["countryOrRegion"]), "/", tostring(LocationDetails["state"]), "/", tostring(LocationDetails["city"]), ";")
| project TimeGenerated, AppDisplayName, UserPrincipalName, locationString
// Create time series
| make-series dLocationCount = dcount(locationString) on TimeGenerated step 1d by UserPrincipalName, AppDisplayName
// Compute best fit line for each entry
| extend (RSquare, Slope, Variance, RVariance, Interception, LineFit) = series_fit_line(dLocationCount)
// Chart the 3 most interesting lines
// A 0-value slope corresponds to an account being completely stable over time for a given Azure Active Directory application
| top 3 by Slope desc
// Extract the set of locations for each top user:
| join kind=inner (
    SigninLogs
    | where TimeGenerated > ago(21d)
    | extend locationString = strcat(tostring(LocationDetails["countryOrRegion"]), "/", tostring(LocationDetails["state"]), "/", tostring(LocationDetails["city"]), ";")
    | summarize locationList = makeset(locationString), threeDayWindowLocationCount = dcount(locationString) by AppDisplayName, UserPrincipalName, timerange = bin(TimeGenerated, 21d)
) on AppDisplayName, UserPrincipalName
| order by UserPrincipalName, timerange asc
| project timerange, AppDisplayName, UserPrincipalName, threeDayWindowLocationCount, locationList
| order by AppDisplayName, UserPrincipalName, timerange asc
| extend timestamp = timerange, AccountCustomEntity = UserPrincipalName
Raw source Anomalous sign-in locations increase · KQL
Esc
Published by Azure/Azure-Sentinel ↗, licensed under MIT ↗. Reproduced here unmodified.
id: 2c67a0a5-62f1-4eab-8a6c-e93a27f2c3e8
name: Anomalous sign-in locations increase
description: |
  Identify the top three user and application pairs with the steepest increase in sign-in location diversity over 21 days, and list their associated locations.
description-detailed: |
  Analyze Microsoft Entra ID sign-in logs using daily location counts and fitted trend lines to highlight unusual growth in location diversity. List the locations associated with each selected user and application within 21-day windows.
requiredDataConnectors:
  - connectorId: AzureActiveDirectory
    dataTypes:
      - SigninLogs
tactics:
  - InitialAccess
relevantTechniques:
  - T1078
query: |
  SigninLogs
  | where TimeGenerated > ago(21d)
  | extend locationString = strcat(tostring(LocationDetails["countryOrRegion"]), "/", tostring(LocationDetails["state"]), "/", tostring(LocationDetails["city"]), ";")
  | project TimeGenerated, AppDisplayName, UserPrincipalName, locationString
  // Create time series
  | make-series dLocationCount = dcount(locationString) on TimeGenerated step 1d by UserPrincipalName, AppDisplayName
  // Compute best fit line for each entry
  | extend (RSquare, Slope, Variance, RVariance, Interception, LineFit) = series_fit_line(dLocationCount)
  // Chart the 3 most interesting lines
  // A 0-value slope corresponds to an account being completely stable over time for a given Azure Active Directory application
  | top 3 by Slope desc
  // Extract the set of locations for each top user:
  | join kind=inner (
      SigninLogs
      | where TimeGenerated > ago(21d)
      | extend locationString = strcat(tostring(LocationDetails["countryOrRegion"]), "/", tostring(LocationDetails["state"]), "/", tostring(LocationDetails["city"]), ";")
      | summarize locationList = makeset(locationString), threeDayWindowLocationCount = dcount(locationString) by AppDisplayName, UserPrincipalName, timerange = bin(TimeGenerated, 21d)
  ) on AppDisplayName, UserPrincipalName
  | order by UserPrincipalName, timerange asc
  | project timerange, AppDisplayName, UserPrincipalName, threeDayWindowLocationCount, locationList
  | order by AppDisplayName, UserPrincipalName, timerange asc
  | extend timestamp = timerange, AccountCustomEntity = UserPrincipalName
entityMappings:
  - entityType: Account
    fieldMappings:
      - identifier: FullName
        columnName: AccountCustomEntity
version: 1.0.0
metadata:
  source:
    kind: Microsoft
  author:
    name: Microsoft Sentinel Team
  support:
    tier: Microsoft
  categories:
    domains:
      - Identity

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.