Microsoft Sentinel Analytic Rules
cloudbrothers.infoAzure Sentinel RepoToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Zscaler - Unexpected ZPA session duration

Back
Ide07846e0-43ad-11ec-81d3-0242ac130003
RulenameZscaler - Unexpected ZPA session duration
DescriptionDetects Unexpected ZPA session duration.
SeverityMedium
TacticsInitialAccess
TechniquesT1078
T1133
Required data connectorsCustomLogsAma
ZscalerPrivateAccess
KindScheduled
Query frequency1h
Query period24h
Trigger threshold0
Trigger operatorgt
Source Urihttps://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Zscaler Private Access (ZPA)/Analytic Rules/ZscalerZPAUnexpectedSessionDuration.yaml
Version1.0.1
Arm templatee07846e0-43ad-11ec-81d3-0242ac130003.json
Deploy To Azure
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, NetworkSessionId
| sort by timestampstart asc;
let closed_sessions =
ZPAEvent
| where TimeGenerated > ago(dt_lookBack)
| where DvcAction == 'close'
| summarize timestampend = max(TimeGenerated) by DstUserName, SrcIpAddr, NetworkSessionId
| sort by timestampend asc;
open_sessions
| join (closed_sessions) on DstUserName, SrcIpAddr, NetworkSessionId
| extend duration = timestampend - timestampstart
| where duration > time_treshhold
| where DstUserName !has "ZPA LSS"
| sort by timestampstart asc
| extend IPCustomEntity = SrcIpAddr, AccountCustomEntity = DstUserName
description: |
    'Detects Unexpected ZPA session duration.'
queryPeriod: 24h
name: Zscaler - Unexpected ZPA session duration
triggerThreshold: 0
tactics:
- InitialAccess
severity: Medium
kind: Scheduled
entityMappings:
- entityType: Account
  fieldMappings:
  - identifier: Name
    columnName: AccountCustomEntity
- entityType: IP
  fieldMappings:
  - identifier: Address
    columnName: IPCustomEntity
queryFrequency: 1h
triggerOperator: gt
id: e07846e0-43ad-11ec-81d3-0242ac130003
status: Available
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Zscaler Private Access (ZPA)/Analytic Rules/ZscalerZPAUnexpectedSessionDuration.yaml
version: 1.0.1
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, NetworkSessionId
  | sort by timestampstart asc;
  let closed_sessions =
  ZPAEvent
  | where TimeGenerated > ago(dt_lookBack)
  | where DvcAction == 'close'
  | summarize timestampend = max(TimeGenerated) by DstUserName, SrcIpAddr, NetworkSessionId
  | sort by timestampend asc;
  open_sessions
  | join (closed_sessions) on DstUserName, SrcIpAddr, NetworkSessionId
  | extend duration = timestampend - timestampstart
  | where duration > time_treshhold
  | where DstUserName !has "ZPA LSS"
  | sort by timestampstart asc
  | extend IPCustomEntity = SrcIpAddr, AccountCustomEntity = DstUserName  
requiredDataConnectors:
- connectorId: ZscalerPrivateAccess
  dataTypes:
  - ZPAEvent
- connectorId: CustomLogsAma
  datatypes:
  - ZPA_CL
relevantTechniques:
- T1078
- T1133
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspace": {
      "type": "String"
    }
  },
  "resources": [
    {
      "apiVersion": "2024-01-01-preview",
      "id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/e07846e0-43ad-11ec-81d3-0242ac130003')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/e07846e0-43ad-11ec-81d3-0242ac130003')]",
      "properties": {
        "alertRuleTemplateName": "e07846e0-43ad-11ec-81d3-0242ac130003",
        "customDetails": null,
        "description": "'Detects Unexpected ZPA session duration.'\n",
        "displayName": "Zscaler - Unexpected ZPA session duration",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "AccountCustomEntity",
                "identifier": "Name"
              }
            ]
          },
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "IPCustomEntity",
                "identifier": "Address"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Zscaler Private Access (ZPA)/Analytic Rules/ZscalerZPAUnexpectedSessionDuration.yaml",
        "query": "let dt_lookBack = 24h;\nlet time_treshhold = timespan(08:00:00);\nlet open_sessions =\nZPAEvent\n| where TimeGenerated > ago(dt_lookBack)\n| where DvcAction == 'open'\n| summarize timestampstart = min(TimeGenerated) by DstUserName, SrcIpAddr, NetworkSessionId\n| sort by timestampstart asc;\nlet closed_sessions =\nZPAEvent\n| where TimeGenerated > ago(dt_lookBack)\n| where DvcAction == 'close'\n| summarize timestampend = max(TimeGenerated) by DstUserName, SrcIpAddr, NetworkSessionId\n| sort by timestampend asc;\nopen_sessions\n| join (closed_sessions) on DstUserName, SrcIpAddr, NetworkSessionId\n| extend duration = timestampend - timestampstart\n| where duration > time_treshhold\n| where DstUserName !has \"ZPA LSS\"\n| sort by timestampstart asc\n| extend IPCustomEntity = SrcIpAddr, AccountCustomEntity = DstUserName\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "PT24H",
        "severity": "Medium",
        "status": "Available",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "InitialAccess"
        ],
        "techniques": [
          "T1078",
          "T1133"
        ],
        "templateVersion": "1.0.1",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}