Detection rules › Kusto

Zscaler - Unexpected ZPA session duration

Status
available
Severity
medium
Time window
1d
Group by
ConnectionID, DstUserName, SrcIpAddr
Source
github.com/Azure/Azure-Sentinel

'Detects Unexpected ZPA session duration.'

MITRE ATT&CK coverage

Rule body kusto

id: e07846e0-43ad-11ec-81d3-0242ac130003
name: Zscaler - Unexpected ZPA session duration
description: |
  'Detects Unexpected ZPA session duration.'
severity: Medium
status: Available
requiredDataConnectors:
  - connectorId: CustomLogsAma
    datatypes:
      - ZPA_CL
queryFrequency: 1h
queryPeriod: 24h
triggerOperator: gt
triggerThreshold: 0
tactics:
  - InitialAccess
relevantTechniques:
  - T1078
  - T1133
query: |
  let dt_lookBack = 24h;
  let time_treshhold = timespan(08:00:00);
  let open_sessions =
  ZPAEvent
  | where TimeGenerated > ago(dt_lookBack)
  | where DvcAction == 'open'
  | summarize timestampstart = min(TimeGenerated) by DstUserName, SrcIpAddr, ConnectionID
  | sort by timestampstart asc;
  let closed_sessions =
  ZPAEvent
  | where TimeGenerated > ago(dt_lookBack)
  | where DvcAction == 'close'
  | summarize timestampend = max(TimeGenerated) by DstUserName, SrcIpAddr, ConnectionID
  | sort by timestampend asc;
  open_sessions
  | join (closed_sessions) on DstUserName, SrcIpAddr, ConnectionID
  | extend duration = timestampend - timestampstart
  | where duration > time_treshhold
  | where DstUserName !has "ZPA LSS"
  | sort by timestampstart asc
  | extend IPCustomEntity = SrcIpAddr, AccountCustomEntity = DstUserName
entityMappings:
  - entityType: Account
    fieldMappings:
      - identifier: Name
        columnName: AccountCustomEntity
  - entityType: IP
    fieldMappings:
      - identifier: Address
        columnName: IPCustomEntity
version: 1.0.3
kind: Scheduled

Stages and Predicates

Parameters

let dt_lookBack = 24h;
let time_treshhold = timespan(08:00:00);

Let binding: closed_sessions

let closed_sessions = ZPAEvent
| where TimeGenerated > ago(dt_lookBack)
| where DvcAction == 'close'
| summarize timestampend = max(TimeGenerated) by DstUserName, SrcIpAddr, ConnectionID
| sort by timestampend asc;

Derived from dt_lookBack.

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

Stage 1: source

ZPAEvent

Stage 2: where

| where TimeGenerated > ago(dt_lookBack)

Stage 3: where

| where DvcAction == 'open'

Stage 4: summarize

| summarize timestampstart = min(TimeGenerated) by DstUserName, SrcIpAddr, ConnectionID

Stage 5: sort

| sort by timestampstart asc

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

Stage 6: join

open_sessions
| join (closed_sessions) on DstUserName, SrcIpAddr, ConnectionID

Stage 7: extend

| extend duration = timestampend - timestampstart

Stage 8: where

| where duration > time_treshhold

Stage 9: where

| where DstUserName !has "ZPA LSS"

Stage 10: sort

| sort by timestampstart asc

Stage 11: extend

| extend IPCustomEntity = SrcIpAddr, AccountCustomEntity = DstUserName

Exclusions

Top-level NOT(...) conjuncts: predicates this rule actively suppresses.

FieldKindExcluded values
DstUserNamematchZPA LSS

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
DvcActioneq
  • close transforms: cased
  • open transforms: cased
durationgt
  • time_treshhold 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
ConnectionIDsummarize
DstUserNamesummarize
SrcIpAddrsummarize
timestampstartsummarize
durationextend
AccountCustomEntityextend
IPCustomEntityextend