Detection rules › Kusto

User Login from Different Countries within 3 hours

Status
available
Severity
high
Time window
3h
Group by
actor_alternateId_s
Source
github.com/Azure/Azure-Sentinel

This query searches for successful user logins to the Okta Console from different countries within 3 hours.

MITRE ATT&CK coverage

TacticTechniques
Initial AccessT1078.004 Valid Accounts: Cloud Accounts

Event coverage

Rules detecting the same action

Other rules on this platform that filter on the same API call or operation.

Rule body kusto

id: 2954d424-f786-4677-9ffc-c24c44c6e7d5
name: User Login from Different Countries within 3 hours
description: |
  'This query searches for successful user logins to the Okta Console from different countries within 3 hours.'
severity: High
status: Available
requiredDataConnectors:
  - connectorId: OktaSSO
    dataTypes:
      - Okta_CL
  - connectorId: OktaSSOv2
    dataTypes:
      - OktaSSO
queryFrequency: 3h
queryPeriod: 3h
triggerOperator: gt
triggerThreshold: 0
tactics:
  - InitialAccess
relevantTechniques:
  - T1078.004
query: |
  let timeframe = ago(3h);
  let threshold = 2;
  OktaSSO
  | where column_ifexists('published_t', now()) >= timeframe
  | where eventType_s =~ "user.session.start"
  | where outcome_result_s =~ "SUCCESS"
  | summarize StartTime = min(TimeGenerated), EndTime = max(TimeGenerated), NumOfCountries = dcount(column_ifexists('client_geographicalContext_country_s', int(null))) by actor_alternateId_s
  | where NumOfCountries >= threshold
entityMappings:
  - entityType: Account
    fieldMappings:
      - identifier: FullName
        columnName: actor_alternateId_s
version: 1.1.1
kind: Scheduled

Stages and Predicates

Parameters

let timeframe = ago(3h);
let threshold = 2;

Stage 1: source

OktaSSO

Stage 2: where

| where column_ifexists('published_t', now()) >= timeframe

Stage 3: where

| where eventType_s =~ "user.session.start"

Stage 4: where

| where outcome_result_s =~ "SUCCESS"

Stage 5: summarize

| summarize StartTime = min(TimeGenerated), EndTime = max(TimeGenerated), NumOfCountries = dcount(column_ifexists('client_geographicalContext_country_s', int(null))) by actor_alternateId_s
Threshold
ge 2

Stage 6: where

| where NumOfCountries >= threshold

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
NumOfCountriesge
  • 2 transforms: cased
eventType_seq
  • user.session.start
outcome_result_seq
  • SUCCESS
published_tge
  • timeframe transforms: column_ifexists, cased

Output fields

Fields the rule emits when it matches. Chronicle authors list these in the outcome block; they appear on the detection and $risk_score drives alerting. Sentinel / Defender XDR rules build them up through project / summarize / extend stages. Sentinel maps these into alert fields via entityMappings and customDetails; Defender XDR custom detections surface them as alert fields directly.

FieldSource
EndTimesummarize
NumOfCountriessummarize
StartTimesummarize
actor_alternateId_ssummarize