{
  "$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/f59e08b0-c9c0-4af8-8065-f868f2e8a040')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/f59e08b0-c9c0-4af8-8065-f868f2e8a040')]",
      "properties": {
        "alertRuleTemplateName": "f59e08b0-c9c0-4af8-8065-f868f2e8a040",
        "customDetails": {
          "CombinationsAfter": "CombinationsAfter",
          "CombinationsBefore": "CombinationsBefore",
          "InitiatingApp": "InitiatingAppName",
          "Operation": "OperationName",
          "StrengthId": "StrengthId"
        },
        "description": "Identifies when the allowed sign-in method combinations of a custom authentication strength are changed in Microsoft Entra ID.\nAn authentication strength lists the method combinations that satisfy a Conditional Access policy, for example phishing-resistant methods only.\nAn attacker with the Conditional Access Administrator role could add a weaker method to a strength that a policy already uses, so the policy stays in place but accepts weaker sign-ins.\nCreating or deleting a whole strength is not covered, and neither are the advanced options (AAGUIDs and certificate issuers).\nThe alert shows the combinations before and after the change and the id of the strength.\nRef: https://learn.microsoft.com/entra/identity/authentication/concept-authentication-strengths\n",
        "displayName": "Entra ID authentication strength change",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "InitiatingUserPrincipalName",
                "identifier": "FullName"
              },
              {
                "columnName": "InitiatingAccountName",
                "identifier": "Name"
              },
              {
                "columnName": "InitiatingAccountUPNSuffix",
                "identifier": "UPNSuffix"
              }
            ]
          },
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "InitiatingAadUserId",
                "identifier": "AadUserId"
              }
            ]
          },
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "InitiatingIPAddress",
                "identifier": "Address"
              }
            ]
          }
        ],
        "eventGroupingSettings": {
          "aggregationKind": "AlertPerResult"
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Detections/AuditLogs/AuthenticationStrengthChange.yaml",
        "query": "AuditLogs\n| where TimeGenerated > ago(2h)\n| where ingestion_time() > ago(1h)\n| where OperationName =~ \"Authentication Strength Policy Update\"\n| where Result !~ \"failure\"\n| extend InitiatingAppName = tostring(InitiatedBy.app.displayName)\n| extend InitiatingUserPrincipalName = tostring(InitiatedBy.user.userPrincipalName)\n| extend InitiatingAadUserId = tostring(InitiatedBy.user.id)\n| extend InitiatingIPAddress = tostring(iff(isnotempty(InitiatedBy.user.ipAddress), InitiatedBy.user.ipAddress, InitiatedBy.app.ipAddress))\n| extend InitiatingAccountName = tostring(split(InitiatingUserPrincipalName, \"@\")[0]), InitiatingAccountUPNSuffix = tostring(split(InitiatingUserPrincipalName, \"@\")[1])\n| mv-apply Target = TargetResources on (\n    mv-expand Property = Target.modifiedProperties\n    | summarize PropertyBag = make_bag(bag_pack(tostring(Property.displayName), bag_pack(\"old\", tostring(Property.oldValue), \"new\", tostring(Property.newValue))))\n  )\n| extend CombinationsBefore = trim('\"', tostring(PropertyBag.AllowedCombinations.old))\n| extend CombinationsAfter = trim('\"', tostring(PropertyBag.AllowedCombinations.new))\n| extend StrengthId = trim('\"', tostring(PropertyBag.Id.new))\n| where isnotempty(CombinationsAfter)\n| mv-apply Combination = split(CombinationsBefore, \"|\") to typeof(string) on (\n    extend Methods = strcat_array(array_sort_asc(split(replace_string(Combination, \" \", \"\"), \",\")), \",\")\n    | where isnotempty(Methods)\n    | summarize NormalizedBefore = tostring(array_sort_asc(make_set(Methods)))\n  )\n| mv-apply Combination = split(CombinationsAfter, \"|\") to typeof(string) on (\n    extend Methods = strcat_array(array_sort_asc(split(replace_string(Combination, \" \", \"\"), \",\")), \",\")\n    | where isnotempty(Methods)\n    | summarize NormalizedAfter = tostring(array_sort_asc(make_set(Methods)))\n  )\n| where NormalizedBefore != NormalizedAfter\n| project-away NormalizedBefore, NormalizedAfter\n| project-reorder TimeGenerated, OperationName, StrengthId, CombinationsBefore, CombinationsAfter, InitiatingUserPrincipalName, InitiatingAppName, InitiatingIPAddress\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "PT2H",
        "severity": "Medium",
        "status": "InPreview",
        "subTechniques": [
          "T1556.006",
          "T1556.009"
        ],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "CredentialAccess",
          "DefenseEvasion",
          "Persistence"
        ],
        "techniques": [
          "T1556"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
