{
  "$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/3939f01f-9563-4cd3-8423-97a82e82719b')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/3939f01f-9563-4cd3-8423-97a82e82719b')]",
      "properties": {
        "alertRuleTemplateName": "3939f01f-9563-4cd3-8423-97a82e82719b",
        "customDetails": null,
        "description": "Detects a data export performed by an employee whose Uniqkey account was created or activated within the preceding 14 days. A freshly provisioned account has little legitimate reason to export organization credentials, so this pattern can indicate a compromised onboarding flow or an account created specifically to stage exfiltration. The action filter matches the provisioning action identifiers from the Uniqkey audit-log catalog, with a name-based fallback for future action variants.",
        "displayName": "Uniqkey - Credential export from newly created account",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "ActorEmail",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "SrcIpAddr",
                "identifier": "Address"
              }
            ]
          }
        ],
        "eventGroupingSettings": {
          "aggregationKind": "AlertPerResult"
        },
        "incidentConfiguration": {
          "createIncident": true,
          "groupingConfiguration": {
            "enabled": true,
            "lookbackDuration": "PT5H",
            "matchingMethod": "AllEntities",
            "reopenClosedIncident": false
          }
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Uniqkey/Analytic%20Rules/Uniqkey%20-%20Credential%20export%20from%20newly%20created%20account.yaml",
        "query": "let lookback = 14d;\nlet frequency = 1h;\nlet provisioningActionIds = dynamic([\n    \"eb7dea42-df3a-44c6-808d-94b7fc46dde9\", // Create employee account\n    \"263c44a2-2075-46bd-949d-aa828517a3d1\", // Link employee account\n    \"4ed5b3be-d1b1-4447-af32-9ae2f1c090c7\", // Activate employee\n    \"e494db5c-b135-441c-8fa3-6e5ad94d05f8\", // Activate employee account\n    \"a652e6df-5a3c-438b-afde-198cd62e8491\", // Activated account\n    \"c7d4f9b2-5e3a-4f8c-9b6d-2e7a1c8d5f3b\", // Activate SSO employee\n    \"3cc88450-39ef-472e-9e0c-06ad7c9af257\", // Process new employee\n    \"c9ebd265-3c60-4228-b948-863c8134d29c\", // Approve process new employee\n    \"1b6c2121-00cc-40fe-9ea4-01f6dd085c34\"  // Approve process invite employee\n]);\nlet newAccounts =\n    UniqkeyEvents_CL\n    | where TimeGenerated > ago(lookback)\n    | where Category == \"account_management\"\n    | where tolower(ActionId) in (provisioningActionIds) or Action has_any (\"create\", \"invite\", \"activate\", \"link\")\n    | where TargetType == \"employee\"\n    | project CreationTime = TimeGenerated, CreationAction = Action, NewEmployeeId = TargetId, NewEmployeeName = TargetName;\nUniqkeyEvents_CL\n| where TimeGenerated > ago(frequency)\n| where Category == \"data_export\"\n| join kind=inner newAccounts on $left.ActorId == $right.NewEmployeeId\n| where TimeGenerated > CreationTime\n| project TimeGenerated, ActorEmail, ActorType, Action, TargetType, TargetName, SrcIpAddr, CreationTime, CreationAction, NewEmployeeName",
        "queryFrequency": "PT1H",
        "queryPeriod": "P14D",
        "severity": "Medium",
        "subTechniques": [],
        "suppressionDuration": "PT5H",
        "suppressionEnabled": false,
        "tactics": [
          "CredentialAccess",
          "Persistence"
        ],
        "techniques": [
          "T1136",
          "T1555"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
