Detection rules › Kusto

API - Suspicious Login

Status
available
Severity
high
Time window
5m
Group by
SourceIp
Source
github.com/Azure/Azure-Sentinel

'42Crunch API protection against suspicious login'

MITRE ATT&CK coverage

TacticTechniques
Initial Access
Credential Access

Rule body

id: 7bdc10d6-aa24-4ca9-9a93-802cd8761354
name: API - Suspicious Login
description: |
  '42Crunch API protection against suspicious login'
severity: High
requiredDataConnectors:
  - connectorId: 42CrunchAPIProtection
    dataTypes:
      - FortyTwoCrunchAPIProtection
  - connectorId: FortyTwoCrunchAPIProtection
    dataTypes:
      - FortyTwoCrunchAPIProtection
queryFrequency: 5m
queryPeriod: 5m
triggerOperator: gt
triggerThreshold: 0
eventGroupingSettings:
  aggregationKind: SingleAlert
status: Available
tactics:
  - CredentialAccess
  - InitialAccess
relevantTechniques:
  - T1110
  - T1190
query: |
  let firstRec = FortyTwoCrunchAPIProtection
  | where TimeGenerated >= ago(5m) 
  | project-away NonBlockingMode, SourcePort, DestinationPort, Query, ApiId, RequestHeader, ResponseHeader, Errors, EventType, Uuid
  | where UriPath has "/api/login?user=" and Status in (200, 403);
  let ipAddressCount = toscalar(firstRec | summarize by SourceIp | count);
  let secondRec = firstRec | summarize arg_max(TimeGenerated, *) by SourceIp;
  let recCount = iff((toscalar(secondRec | count) > 3), ipAddressCount, 0);
  secondRec | take recCount
customDetails:
entityMappings:
  - entityType: IP
    fieldMappings:
      - identifier: Address
        columnName: SourceIp
  - entityType: Host
    fieldMappings:
      - identifier: HostName
        columnName: Hostname
  - entityType: Account
    fieldMappings:
      - identifier: FullName
        columnName: InstanceName
version: 3.0.1
kind: Scheduled

Stages and Predicates

let firstRec and let secondRec are inlined into the numbered stages below.

Let binding: ipAddressCount

let ipAddressCount = toscalar(firstRec | summarize by SourceIp | count);

Let binding: recCount used in Stage 6

let recCount = iff((toscalar(secondRec | count) > 3), ipAddressCount, 0);

Stages 1 to 5 define let secondRec (the rule's main pipeline source); stage 6 runs on it.

Stage 1: source

FortyTwoCrunchAPIProtection

Stage 2: where

| where TimeGenerated >= ago(5m)

Stage 3: project-away

| project-away NonBlockingMode, SourcePort, DestinationPort, Query, ApiId, RequestHeader, ResponseHeader, Errors, EventType, Uuid

Stage 4: where

| where UriPath has "/api/login?user=" and Status in (200, 403)

Stage 5: summarize

| summarize arg_max(TimeGenerated, *) by SourceIp

Stage 6: take

secondRec
| take recCount

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
Statusin
  • 200
  • 403
field:"Status" kind:in
UriPathmatch
  • /api/login?user= transforms: term
field:"UriPath" kind:match value:"/api/login?user="

Output fields

These fields are emitted when the rule matches.

FieldSource
SourceIpsummarize