Detection rules › Kusto

New Device/Location sign-in along with critical operation

Status
available
Severity
medium
Time window
1h
Group by
actor_alternateId_s, actor_displayName_s, authenticationContext_externalSessionId_s, client_device_s, client_geographicalContext_city_s, client_geographicalContext_country_s, client_geographicalContext_geolocation_lat_d, client_geographicalContext_geolocation_lon_d, client_ipAddress_s, client_userAgent_browser_s, client_userAgent_os_s, client_userAgent_rawUserAgent_s, debugContext_debugData_threatSuspected_s, displayMessage_s, outcome_reason_s, outcome_result_s, timekey
Source
github.com/Azure/Azure-Sentinel

This query identifies users seen login from new geo location/country as well as a new device and performing critical operations.

MITRE ATT&CK coverage

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: 41e843a8-92e7-444d-8d72-638f1145d1e1
name: New Device/Location sign-in along with critical operation
description: |
  'This query identifies users seen login from new geo location/country as well as a new device and performing critical operations.'
severity: Medium
status: Available
requiredDataConnectors:
  - connectorId: OktaSSO
    dataTypes:
      - Okta_CL
  - connectorId: OktaSSOv2
    dataTypes:
      - OktaSSO
queryFrequency: 1h
queryPeriod: 1h
triggerOperator: gt
triggerThreshold: 0
tactics:
  - InitialAccess
  - Persistence
relevantTechniques:
  - T1078
  - T1556
query: |
  let timeframe = 1h;
  let RiskyOperations = dynamic(["policy.rule.update","policy.rule.create","policy.rule.delete", "policy.rule.deactivate", "policy.lifecycle.update", "policy.rule.modify", "policy.lifecycle.create", "policy.lifecycle.delete", "policy.lifecycle.deactivate", "policy.lifecycle.modify", "network_zone.rule.disabled", "system.api_token.create", "system.api_token.revoke", "application.policy.sign_on.update", "application.policy.sign_on.rule.delete","user.mfa.factor.deactivate", "user.mfa.factor.reset_all", "system.mfa.factor.deactivate", "user.mfa.attempt_bypass"]);
  let UserLoginNewCountryDevice = OktaSSO
  | where eventType_s == "user.session.start"
  | where outcome_result_s == "SUCCESS"
  | extend debugContext_debugData_logOnlySecurityData_s = column_ifexists('debugContext_debugData_logOnlySecurityData_s', '{}')
  | where parse_json(tostring(parse_json(debugContext_debugData_logOnlySecurityData_s).behaviors)).["New Country"] == "POSITIVE"
  | where parse_json(tostring(parse_json(debugContext_debugData_logOnlySecurityData_s).behaviors)).["New Geo-Location"] == "POSITIVE"
  | where parse_json(tostring(parse_json(debugContext_debugData_logOnlySecurityData_s).behaviors)).["New Device"] == "POSITIVE"
  | summarize by timekey = bin(TimeGenerated, timeframe), actor_alternateId_s, actor_displayName_s, client_userAgent_os_s, client_userAgent_browser_s, client_device_s, client_userAgent_rawUserAgent_s, client_ipAddress_s, authenticationContext_externalSessionId_s, client_geographicalContext_country_s, client_geographicalContext_city_s, displayMessage_s, outcome_result_s, outcome_reason_s, column_ifexists('debugContext_debugData_logOnlySecurityData_s', ""), debugContext_debugData_threatSuspected_s, client_geographicalContext_geolocation_lat_d, client_geographicalContext_geolocation_lon_d
  | extend Location = strcat(client_geographicalContext_city_s, "-", client_geographicalContext_country_s);
  let RiskyOperationsObserved = OktaSSO
  | where eventType_s in (RiskyOperations)
  | where outcome_result_s == "SUCCESS"
  | summarize by timekey = bin(TimeGenerated, timeframe), actor_alternateId_s, actor_displayName_s, client_userAgent_os_s, client_userAgent_browser_s, client_device_s, client_userAgent_rawUserAgent_s, client_ipAddress_s, authenticationContext_externalSessionId_s, client_geographicalContext_country_s, client_geographicalContext_city_s, displayMessage_s, outcome_result_s, outcome_reason_s, column_ifexists('debugContext_debugData_logOnlySecurityData_s', ""), debugContext_debugData_threatSuspected_s, client_geographicalContext_geolocation_lat_d, client_geographicalContext_geolocation_lon_d;
  UserLoginNewCountryDevice
  | join kind=inner (RiskyOperationsObserved) on timekey, actor_displayName_s, client_ipAddress_s
entityMappings:
  - entityType: Account
    fieldMappings:
      - identifier: Name
        columnName: actor_alternateId_s
      - identifier: DisplayName
        columnName: actor_displayName_s
  - entityType: IP
    fieldMappings:
      - identifier: Address
        columnName: client_ipAddress_s
customDetails:
  SessionId: authenticationContext_externalSessionId_s
  Location:  Location
alertDetailsOverride:
  alertDisplayNameFormat: New Device/Location {{Location}} sign-in along with critical operation
  alertDescriptionFormat: |
    This query identifies users seen login from new geo location/country {{Location}} as well as a new device and performing critical operations
version: 1.1.1
kind: Scheduled

Stages and Predicates

Parameters

let timeframe = 1h;

Let binding: RiskyOperations

let RiskyOperations = dynamic(["policy.rule.update","policy.rule.create","policy.rule.delete", "policy.rule.deactivate", "policy.lifecycle.update", "policy.rule.modify", "policy.lifecycle.create", "policy.lifecycle.delete", "policy.lifecycle.deactivate", "policy.lifecycle.modify", "network_zone.rule.disabled", "system.api_token.create", "system.api_token.revoke", "application.policy.sign_on.update", "application.policy.sign_on.rule.delete","user.mfa.factor.deactivate", "user.mfa.factor.reset_all", "system.mfa.factor.deactivate", "user.mfa.attempt_bypass"]);

Let binding: RiskyOperationsObserved

let RiskyOperationsObserved = OktaSSO
| where eventType_s in (RiskyOperations)
| where outcome_result_s == "SUCCESS"
| summarize by timekey = bin(TimeGenerated, timeframe), actor_alternateId_s, actor_displayName_s, client_userAgent_os_s, client_userAgent_browser_s, client_device_s, client_userAgent_rawUserAgent_s, client_ipAddress_s, authenticationContext_externalSessionId_s, client_geographicalContext_country_s, client_geographicalContext_city_s, displayMessage_s, outcome_result_s, outcome_reason_s, column_ifexists('debugContext_debugData_logOnlySecurityData_s', ""), debugContext_debugData_threatSuspected_s, client_geographicalContext_geolocation_lat_d, client_geographicalContext_geolocation_lon_d;

Derived from timeframe, RiskyOperations.

The stages below define let UserLoginNewCountryDevice (the rule's main pipeline source).

Stage 1: source

OktaSSO

Stage 2: where

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

Stage 3: where

| where outcome_result_s == "SUCCESS"

Stage 4: extend

| extend debugContext_debugData_logOnlySecurityData_s = column_ifexists('debugContext_debugData_logOnlySecurityData_s', '{}')

Stage 5: where

| where parse_json(tostring(parse_json(debugContext_debugData_logOnlySecurityData_s).behaviors)).["New Country"] == "POSITIVE"

Stage 6: where

| where parse_json(tostring(parse_json(debugContext_debugData_logOnlySecurityData_s).behaviors)).["New Geo-Location"] == "POSITIVE"

Stage 7: where

| where parse_json(tostring(parse_json(debugContext_debugData_logOnlySecurityData_s).behaviors)).["New Device"] == "POSITIVE"

Stage 8: summarize

| summarize by timekey = bin(TimeGenerated, timeframe), actor_alternateId_s, actor_displayName_s, client_userAgent_os_s, client_userAgent_browser_s, client_device_s, client_userAgent_rawUserAgent_s, client_ipAddress_s, authenticationContext_externalSessionId_s, client_geographicalContext_country_s, client_geographicalContext_city_s, displayMessage_s, outcome_result_s, outcome_reason_s, column_ifexists('debugContext_debugData_logOnlySecurityData_s', ""), debugContext_debugData_threatSuspected_s, client_geographicalContext_geolocation_lat_d, client_geographicalContext_geolocation_lon_d

Stage 9: extend

| extend Location = strcat(client_geographicalContext_city_s, "-", client_geographicalContext_country_s)

The stages below run on UserLoginNewCountryDevice (the outer pipeline).

Stage 10: join

UserLoginNewCountryDevice
| join kind=inner (RiskyOperationsObserved) on timekey, actor_displayName_s, client_ipAddress_s

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
New Countryeq
  • POSITIVE transforms: cased
New Deviceeq
  • POSITIVE transforms: cased
New Geo-Locationeq
  • POSITIVE transforms: cased
eventType_seq
  • user.session.start transforms: cased
eventType_sin
  • application.policy.sign_on.rule.delete transforms: cased
  • application.policy.sign_on.update transforms: cased
  • network_zone.rule.disabled transforms: cased
  • policy.lifecycle.create transforms: cased
  • policy.lifecycle.deactivate transforms: cased
  • policy.lifecycle.delete transforms: cased
  • policy.lifecycle.modify transforms: cased
  • policy.lifecycle.update transforms: cased
  • policy.rule.create transforms: cased
  • policy.rule.deactivate transforms: cased
  • policy.rule.delete transforms: cased
  • policy.rule.modify transforms: cased
  • policy.rule.update transforms: cased
  • system.api_token.create transforms: cased
  • system.api_token.revoke transforms: cased
  • system.mfa.factor.deactivate transforms: cased
  • user.mfa.attempt_bypass transforms: cased
  • user.mfa.factor.deactivate transforms: cased
  • user.mfa.factor.reset_all transforms: cased
outcome_result_seq
  • SUCCESS transforms: 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
actor_alternateId_ssummarize
actor_displayName_ssummarize
authenticationContext_externalSessionId_ssummarize
client_device_ssummarize
client_geographicalContext_city_ssummarize
client_geographicalContext_country_ssummarize
client_geographicalContext_geolocation_lat_dsummarize
client_geographicalContext_geolocation_lon_dsummarize
client_ipAddress_ssummarize
client_userAgent_browser_ssummarize
client_userAgent_os_ssummarize
client_userAgent_rawUserAgent_ssummarize
debugContext_debugData_threatSuspected_ssummarize
displayMessage_ssummarize
outcome_reason_ssummarize
outcome_result_ssummarize
timekeysummarize
Locationextend