{
  "$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/5da571b5-54f6-42c2-8c3e-27edd987ceec')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/5da571b5-54f6-42c2-8c3e-27edd987ceec')]",
      "properties": {
        "alertRuleTemplateName": "5da571b5-54f6-42c2-8c3e-27edd987ceec",
        "customDetails": {
          "Company": "CompanyName",
          "Source": "Source",
          "Ticket": "TicketId"
        },
        "description": "'Correlates corporate credentials exposed in PRODAFT USTA Account Takeover Prevention\ntickets with successful Microsoft Entra ID sign-ins for the same user. A successful\nsign-in by an account whose credentials are known to be compromised is a strong signal\nof account takeover. Requires the Microsoft Entra ID (SigninLogs) connector. Username\nmatching is best-effort (case-insensitive) because USTA may record either an email or a\nbare username.'\n",
        "displayName": "PRODAFT USTA - Compromised credential used in successful sign-in",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "UserPrincipalName",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "IPAddress",
                "identifier": "Address"
              }
            ]
          }
        ],
        "incidentConfiguration": {
          "createIncident": true,
          "groupingConfiguration": {
            "enabled": true,
            "groupByEntities": [
              "Account"
            ],
            "lookbackDuration": "P1D",
            "matchingMethod": "Selected",
            "reopenClosedIncident": false
          }
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/PRODAFT%20USTA%20-%20Account%20Takeover%20Prevention/Analytic%20Rules/CompromisedCredentialUsedInSignin.yaml",
        "query": "let lookback = 14d;\nlet detection = 1h;\nlet compromised =\n    PRODAFTUstaCompromisedCredentials\n    | where Created > ago(lookback)\n    | where IsCorporate == true\n    | where isnotempty(Username)\n    | extend MatchName = tolower(Username)\n    | summarize arg_max(TimeGenerated, TicketId, CompanyName, InfectionDate, Source) by MatchName;\nSigninLogs\n| where TimeGenerated > ago(detection)\n| where ResultType == 0\n| where isnotempty(UserPrincipalName)\n| extend MatchName = tolower(UserPrincipalName)\n| join kind=inner compromised on MatchName\n| project\n    TimeGenerated,\n    UserPrincipalName,\n    IPAddress,\n    Location,\n    AppDisplayName,\n    ClientAppUsed,\n    TicketId,\n    CompanyName,\n    Source,\n    InfectionDate\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "P14D",
        "severity": "High",
        "status": "Available",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "CredentialAccess",
          "InitialAccess"
        ],
        "techniques": [
          "T1078",
          "T1555"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
