let dt_lastlogintime = 14d;
let activeUsers =
ZPAEvent
| where TimeGenerated > ago(dt_lastlogintime)
| where DvcAction == 'open'
| summarize lastLoginTime = max(TimeGenerated) by DstUserName
| summarize makelist(DstUserName);
ZPAEvent
| where DstUserName !in~ (activeUsers)
| summarize EventCount = count() by DstUserName
| project-away EventCount
| extend AccountCustomEntity = DstUserName
entityMappings:
- entityType: Account
fieldMappings:
- identifier: Name
columnName: AccountCustomEntity
queryFrequency: 1h
name: Zscaler - Connections by dormant user
kind: Scheduled
tactics:
- Persistence
triggerThreshold: 0
query: |
let dt_lastlogintime = 14d;
let activeUsers =
ZPAEvent
| where TimeGenerated > ago(dt_lastlogintime)
| where DvcAction == 'open'
| summarize lastLoginTime = max(TimeGenerated) by DstUserName
| summarize makelist(DstUserName);
ZPAEvent
| where DstUserName !in~ (activeUsers)
| summarize EventCount = count() by DstUserName
| project-away EventCount
| extend AccountCustomEntity = DstUserName
relevantTechniques:
- T1078
triggerOperator: gt
queryPeriod: 14d
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Zscaler Private Access (ZPA)/Analytic Rules/ZscalerZPAConnectionsByDormantUser.yaml
severity: High
status: Available
id: 66bc77ee-3e45-11ec-9bbc-0242ac130002
requiredDataConnectors:
- connectorId: CustomLogsAma
datatypes:
- ZPA_CL
version: 1.0.2
description: |
'Detects ZPA connections by dormant user.'
{
"$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/66bc77ee-3e45-11ec-9bbc-0242ac130002')]",
"kind": "Scheduled",
"name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/66bc77ee-3e45-11ec-9bbc-0242ac130002')]",
"properties": {
"alertRuleTemplateName": "66bc77ee-3e45-11ec-9bbc-0242ac130002",
"customDetails": null,
"description": "'Detects ZPA connections by dormant user.'\n",
"displayName": "Zscaler - Connections by dormant user",
"enabled": true,
"entityMappings": [
{
"entityType": "Account",
"fieldMappings": [
{
"columnName": "AccountCustomEntity",
"identifier": "Name"
}
]
}
],
"OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Zscaler Private Access (ZPA)/Analytic Rules/ZscalerZPAConnectionsByDormantUser.yaml",
"query": "let dt_lastlogintime = 14d;\nlet activeUsers =\nZPAEvent \n| where TimeGenerated > ago(dt_lastlogintime)\n| where DvcAction == 'open'\n| summarize lastLoginTime = max(TimeGenerated) by DstUserName\n| summarize makelist(DstUserName);\nZPAEvent\n| where DstUserName !in~ (activeUsers)\n| summarize EventCount = count() by DstUserName\n| project-away EventCount\n| extend AccountCustomEntity = DstUserName\n",
"queryFrequency": "PT1H",
"queryPeriod": "P14D",
"severity": "High",
"status": "Available",
"subTechniques": [],
"suppressionDuration": "PT1H",
"suppressionEnabled": false,
"tactics": [
"Persistence"
],
"techniques": [
"T1078"
],
"templateVersion": "1.0.2",
"triggerOperator": "GreaterThan",
"triggerThreshold": 0
},
"type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
}
]
}