Detection rules › Kusto

TI Map URL Entity to EmailUrlInfo

Severity
medium
Time window
14d
Group by
Id, IndicatorId, NetworkMessageId, ObservableValue, Url, UrlDomain
Source
github.com/Azure/Azure-Sentinel

This query identifies any URL indicators of compromise (IOCs) from threat intelligence (TI) by searching for matches in EmailUrlInfo.

MITRE ATT&CK coverage

TacticTechniques
Command & Control

Telemetry coverage

Rule body

id: 9e32e545-e60c-47de-9941-f9ca1ada0a42
name: TI Map URL Entity to EmailUrlInfo
description: |
  'This query identifies any URL indicators of compromise (IOCs) from threat intelligence (TI) by searching for matches in EmailUrlInfo.'
severity: Medium
requiredDataConnectors:
  - connectorId: MicrosoftThreatProtection
    dataTypes:
      - EmailUrlInfo
  - connectorId: ThreatIntelligence
    dataTypes:
      - ThreatIntelIndicators
  - connectorId: ThreatIntelligenceTaxii
    dataTypes:
      - ThreatIntelIndicators
  - connectorId: MicrosoftDefenderThreatIntelligence
    dataTypes:
      - ThreatIntelIndicators
queryFrequency: 1h
queryPeriod: 14d
triggerOperator: gt
triggerThreshold: 0
tactics:
  - CommandAndControl
relevantTechniques:
  - T1071
query: |
  let dt_lookBack = 1h;
  let ioc_lookBack = 14d;
  let EmailUrlInfo_ = materialize(EmailUrlInfo
      | where TimeGenerated >= ago(dt_lookBack)
      | extend EmailUrlInfo_TimeGenerated = TimeGenerated);
  let EmailUrls = EmailUrlInfo_ | distinct Url | summarize make_list(Url);
  let EmailUrlDomains = EmailUrlInfo_ | distinct UrlDomain | summarize make_list(UrlDomain);
  let EmailEvents_ = materialize(EmailEvents
      | where TimeGenerated >= ago(dt_lookBack));
  let TI = materialize(ThreatIntelIndicators
     //extract key part of kv pair
  | extend IndicatorType = replace(@"\[|\]|\""", "", tostring(split(ObservableKey, ":", 0)))
  | where IndicatorType == "url"
  | extend Url = ObservableValue
  | extend TrafficLightProtocolLevel = tostring(parse_json(AdditionalFields).TLPLevel)
  | extend IndicatorId = tostring(split(Id, "--")[2])
      | where TimeGenerated >= ago(ioc_lookBack)
      | where tolower(Url) in (EmailUrls) or tolower(Url) in (EmailUrlDomains)
      | summarize LatestIndicatorTime = arg_max(TimeGenerated, *) by Id, ObservableValue
      | where IsActive and (ValidUntil > now() or isempty(ValidUntil)));
  (union
      (TI | join kind=innerunique (EmailUrlInfo_) on Url),
      (TI | join kind=innerunique (EmailUrlInfo_) on $left.Url == $right.UrlDomain))
  | where EmailUrlInfo_TimeGenerated < ValidUntil
  | summarize EmailUrlInfo_TimeGenerated = arg_max(EmailUrlInfo_TimeGenerated, *) by IndicatorId, Url
  | extend Description = tostring(parse_json(Data).description)
  | extend ActivityGroupNames = extract(@"ActivityGroup:(\S+)", 1, tostring(parse_json(Data).labels))
  | project EmailUrlInfo_TimeGenerated, Description, ActivityGroupNames, IndicatorId, Type, ValidUntil, Confidence, Url, UrlDomain, UrlLocation, NetworkMessageId
  | extend timestamp = EmailUrlInfo_TimeGenerated
  | join kind=inner (EmailEvents_) on NetworkMessageId
  | where DeliveryAction !has "Blocked"
  | extend Name = tostring(split(RecipientEmailAddress, '@', 0)[0]), UPNSuffix = tostring(split(RecipientEmailAddress, '@', 1)[0])
entityMappings:
  - entityType: Account
    fieldMappings:
      - identifier: FullName
        columnName: RecipientEmailAddress
      - identifier: Name
        columnName: Name
      - identifier: UPNSuffix
        columnName: UPNSuffix
  - entityType: URL
    fieldMappings:
      - identifier: Url
        columnName: Url
version: 1.0.5
kind: Scheduled

Stages and Predicates

Stage 0: let

let dt_lookBack = 1h;
let ioc_lookBack = 14d;
let EmailUrlInfo_ = materialize(EmailUrlInfo
    | where TimeGenerated >= ago(dt_lookBack)
    | extend EmailUrlInfo_TimeGenerated = TimeGenerated);
let EmailUrls = EmailUrlInfo_ | distinct Url | summarize make_list(Url);
let EmailUrlDomains = EmailUrlInfo_ | distinct UrlDomain | summarize make_list(UrlDomain);
let EmailEvents_ = materialize(EmailEvents
    | where TimeGenerated >= ago(dt_lookBack));
let TI = materialize(<inlined as stages below>);

Stage 1: source

let EmailUrlInfo_

Stage 2: source

let EmailUrls

Stage 3: source

let EmailUrlDomains

Stage 4: source

let EmailEvents_

Stage 5: union

union of 2 branches

Stage 6: source

ThreatIntelIndicators

Stage 7: extend

extend IndicatorType

Stage 8: where

where IndicatorType =~ "url"

Stage 9: extend (3 consecutive steps)

extend IndicatorId, TrafficLightProtocolLevel, Url

Stage 10: where

where TimeGenerated >= ago(1209600s)

Stage 11: where

where (Url =~ "EmailUrlDomains" or Url =~ "EmailUrls")

Stage 12: summarize

summarize LatestIndicatorTime by Id, ObservableValue

Stage 13: where

where (isempty(ValidUntil) or ValidUntil > now())

Stage 14: join

join kind=innerunique (EmailUrlInfo_) on Url

Stage 15: source

ThreatIntelIndicators

Stage 16: extend

extend IndicatorType

Stage 17: where

where IndicatorType =~ "url"

Stage 18: extend (3 consecutive steps)

extend IndicatorId, TrafficLightProtocolLevel, Url

Stage 19: where

where TimeGenerated >= ago(1209600s)

Stage 20: where

where (Url =~ "EmailUrlDomains" or Url =~ "EmailUrls")

Stage 21: summarize

summarize LatestIndicatorTime by Id, ObservableValue

Stage 22: where

where (isempty(ValidUntil) or ValidUntil > now())

Stage 23: join

join kind=innerunique (EmailUrlInfo_) on Url, UrlDomain

Stage 24: where

where EmailUrlInfo_TimeGenerated < ValidUntil

Stage 25: summarize

summarize EmailUrlInfo_TimeGenerated by IndicatorId, Url

Stage 26: extend

extend Description

Stage 27: extend

extend ActivityGroupNames

Stage 28: project

project ActivityGroupNames, Confidence, Description, EmailUrlInfo_TimeGenerated, IndicatorId, NetworkMessageId, Type, Url, UrlDomain, UrlLocation, ValidUntil

Stage 29: extend

extend timestamp

Stage 30: join

join kind=inner (EmailEvents_) on NetworkMessageId

Stage 31: where

where not (DeliveryAction contains "Blocked")

Stage 32: extend

extend Name, UPNSuffix

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
EmailUrlInfo_TimeGeneratedcross_field_compare
  • ValidUntil transforms: op:lt
field:"EmailUrlInfo_TimeGenerated" kind:cross_field_compare value:"ValidUntil"
IndicatorTypeeq
  • url
field:"IndicatorType" kind:eq value:"url"
Urlin
  • EmailUrlDomains transforms: tolower
  • EmailUrls transforms: tolower
field:"Url" kind:in
ValidUntilis_null
  • (no value, null check)
field:"ValidUntil" kind:is_null

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
DeliveryActionmatchBlockedexcludes:DeliveryAction field:"DeliveryAction" value:"Blocked"

Output fields

These fields are emitted when the rule matches.

FieldSource
ActivityGroupNamesproject
Confidenceproject
Descriptionproject
EmailUrlInfo_TimeGeneratedproject
IndicatorIdproject
NetworkMessageIdproject
Typeproject
Urlproject
UrlDomainproject
UrlLocationproject
ValidUntilproject
timestampextend
Nameextend
UPNSuffixextend