Detection rules › Kusto

Several deny actions registered

Status
available
Severity
medium
Time window
1h
Group by
Action, Fqdn, Protocol, SourceIp
Source
github.com/Azure/Azure-Sentinel

'Identifies attack pattern when attacker tries to move, or scan, from resource to resource on the network and creates an incident when a source has more than 1 registered deny action in Azure Firewall.'

MITRE ATT&CK coverage

Rule body

id: f8dad4e9-3f19-4d70-ab7f-8f19ccd43a3e
name: Several deny actions registered
description: |
  'Identifies attack pattern when attacker tries to move, or scan, from resource to resource on the network and creates an incident when a source has more than 1 registered deny action in Azure Firewall.'
severity: Medium
status: Available
requiredDataConnectors:
  - connectorId: AzureFirewall
    dataTypes:
      - AzureDiagnostics
      - AZFWApplicationRule
      - AZFWNetworkRule
      - AZFWFlowTrace
      - AZFWIdpsSignature
queryFrequency: 1h
queryPeriod: 1h
triggerOperator: gt
triggerThreshold: 0
tactics:
  - Discovery
  - LateralMovement
  - CommandAndControl
relevantTechniques:
  - T1046
  - T1071
  - T1210
query: |
  let threshold = 2;
  union isfuzzy=true(
  AZFWApplicationRule
  | where Action == "Deny"
  | summarize StartTime = min(TimeGenerated), count() by SourceIp, Fqdn, Action, Protocol
  | where count_ >= threshold),
  (AZFWNetworkRule
  | where Action == "Deny"
  | extend Fqdn = DestinationIp
  | summarize StartTime = min(TimeGenerated), count_ = dcount(DestinationPort), Protocols = make_set(Protocol) by SourceIp, Fqdn, Action
  | where count_ >= threshold
  | extend Protocol = strcat_array(Protocols, "/")),
  (AZFWFlowTrace
  | where Action == "Deny"
  | extend Fqdn = DestinationIp
  | summarize StartTime = min(TimeGenerated), count() by SourceIp, Fqdn, Action, Protocol
  | where count_ >= threshold),
  (AZFWIdpsSignature
  | where Action == "Deny"
  | extend Fqdn = DestinationIp
  | summarize StartTime = min(TimeGenerated), count() by SourceIp, Fqdn, Action, Protocol
  | where count_ >= threshold),
  (AzureDiagnostics
  | where OperationName in ("AzureFirewallApplicationRuleLog","AzureFirewallNetworkRuleLog")
  | extend msg_s_replaced0 = replace(@"\s\s",@" ",msg_s)
  | extend msg_s_replaced1 = replace(@"\.\s",@" ",msg_s_replaced0)
  | extend msg_a = split(msg_s_replaced1," ")
  | extend srcAddr_a = split(msg_a[3],":") , destAddr_a = split(msg_a[5],":")
  | extend Protocol = tostring(msg_a[0]), SourceIp = tostring(srcAddr_a[0]), srcPort = tostring(srcAddr_a[1]), DestinationIp = tostring(destAddr_a[0]), destPort = tostring(destAddr_a[1]), Action = tostring(msg_a[7])
  | where Action == "Deny"
  | extend Fqdn = iff(DestinationIp matches regex "\\d+\\.\\d+\\.\\d+\\.\\d+","",DestinationIp)
  | summarize StartTime = min(TimeGenerated), count() by SourceIp, Fqdn, Action, Protocol
  | where count_ >= threshold)
entityMappings:
  - entityType: IP
    fieldMappings:
      - identifier: Address
        columnName: SourceIp
  - entityType: URL
    fieldMappings:
      - identifier: Url
        columnName: Fqdn
customDetails:
  NetworkProtocol: Protocol
alertDetailsOverride:
  alertDisplayNameFormat: 'Multiple Deny Actions Detected from {{SourceIp}} to {{Fqdn}}'
  alertDescriptionFormat: 'Source IP {{SourceIp}} has triggered multiple deny actions to destination {{Fqdn}} using protocol {{Protocol}}, which may indicate malicious activity such as lateral movement or reconnaissance.'
version: 1.1.3
kind: Scheduled

Stages and Predicates

Stage 0: let

let threshold = 2;

Stage 1: union

union of 5 branches

Stage 2: source

AZFWApplicationRule

Stage 3: where

| where Action == "Deny"

Stage 4: summarize

| summarize StartTime = min(TimeGenerated), count() by SourceIp, Fqdn, Action, Protocol

Stage 5: where

| where count_ >= threshold

Stage 6: source

AZFWNetworkRule

Stage 7: where

| where Action == "Deny"

Stage 8: extend

| extend Fqdn = DestinationIp

Stage 9: summarize

| summarize StartTime = min(TimeGenerated), count_ = dcount(DestinationPort), Protocols = make_set(Protocol) by SourceIp, Fqdn, Action

Stage 10: where

| where count_ >= threshold

Stage 11: extend

| extend Protocol = strcat_array(Protocols, "/")

Stage 12: source

AZFWFlowTrace

Stage 13: where

| where Action == "Deny"

Stage 14: extend

| extend Fqdn = DestinationIp

Stage 15: summarize

| summarize StartTime = min(TimeGenerated), count() by SourceIp, Fqdn, Action, Protocol

Stage 16: where

| where count_ >= threshold

Stage 17: source

AZFWIdpsSignature

Stage 18: where

| where Action == "Deny"

Stage 19: extend

| extend Fqdn = DestinationIp

Stage 20: summarize

| summarize StartTime = min(TimeGenerated), count() by SourceIp, Fqdn, Action, Protocol

Stage 21: where

| where count_ >= threshold

Stage 22: source

AzureDiagnostics

Stage 23: where

| where OperationName in ("AzureFirewallApplicationRuleLog","AzureFirewallNetworkRuleLog")

Stage 24: extend (5 consecutive steps)

| extend msg_s_replaced0 = replace(@"\s\s",@" ",msg_s)
| extend msg_s_replaced1 = replace(@"\.\s",@" ",msg_s_replaced0)
| extend msg_a = split(msg_s_replaced1," ")
| extend srcAddr_a = split(msg_a[3],":") , destAddr_a = split(msg_a[5],":")
| extend Protocol = tostring(msg_a[0]), SourceIp = tostring(srcAddr_a[0]), srcPort = tostring(srcAddr_a[1]), DestinationIp = tostring(destAddr_a[0]), destPort = tostring(destAddr_a[1]), Action = tostring(msg_a[7])

Stage 25: where

| where Action == "Deny"

Stage 26: extend

| extend Fqdn = iff(DestinationIp matches regex "\\d+\\.\\d+\\.\\d+\\.\\d+","",DestinationIp)
Fqdn =
ifDestinationIp matches regex @"\d+\.\d+\.\d+\.\d+"""
elseDestinationIp

Stage 27: summarize

| summarize StartTime = min(TimeGenerated), count() by SourceIp, Fqdn, Action, Protocol

Stage 28: where

| where count_ >= threshold

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
Actioneq
  • Deny
field:"Action" kind:eq value:"Deny"
OperationNamein
  • AzureFirewallApplicationRuleLog
  • AzureFirewallNetworkRuleLog
field:"OperationName" kind:in
count_ge
  • 2
field:"count_" kind:ge value:"2"

Output fields

These fields are emitted when the rule matches.

FieldSource
Actionsummarize
Fqdnsummarize
Protocolsummarize
SourceIpsummarize
StartTimesummarize