{
  "$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/b300c7f8-dc5e-4fc6-879b-63f0013358ce')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/b300c7f8-dc5e-4fc6-879b-63f0013358ce')]",
      "properties": {
        "alertDetailsOverride": {
          "alertDescriptionFormat": "Tier Model Alert TM001 - A {{ObjectTier}} object was added to non-{{ObjectTier}} group {{GroupName}}.\n\nResolution - Remove the object from the group\n",
          "alertDisplayNameFormat": "(TM001.1) A {{ObjectTier}} object was added to non-{{ObjectTier}} group {{GroupName}}"
        },
        "alertRuleTemplateName": "b300c7f8-dc5e-4fc6-879b-63f0013358ce",
        "customDetails": {
          "Account": "Account",
          "ActivityType": "ActivityType",
          "Channel": "Channel",
          "Domain": "Domain",
          "EventData": "EventData",
          "EventID": "EventID",
          "GroupName": "GroupName",
          "GroupTier": "GroupTier",
          "ObjectName": "ObjectName",
          "ObjectTier": "ObjectTier",
          "ObjectType": "ObjectType",
          "OperationType": "OperationType"
        },
        "description": "Added an object to a member of a Tier Model group that is outside of the same Tier. Example a Tier 0 user added to a Tier 1 group.\n",
        "displayName": "PROD (TM001.1) - GROUP - Added to Group Outside the Object Tier Level",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "ObjectName",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "SecurityGroup",
            "fieldMappings": [
              {
                "columnName": "GroupName",
                "identifier": "DistinguishedName"
              }
            ]
          },
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "Account",
                "identifier": "FullName"
              }
            ]
          },
          {
            "entityType": "Host",
            "fieldMappings": [
              {
                "columnName": "Computer",
                "identifier": "HostName"
              }
            ]
          }
        ],
        "eventGroupingSettings": {
          "aggregationKind": "AlertPerResult"
        },
        "incidentConfiguration": {
          "createIncident": true,
          "groupingConfiguration": {
            "enabled": false,
            "groupByCustomDetails": [
              "ObjectName"
            ],
            "groupByEntities": [
              "Account"
            ],
            "lookbackDuration": "PT5M",
            "matchingMethod": "Selected",
            "reopenClosedIncident": false
          }
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Microsoft%20Active%20Directory%20Tier%20Model/Analytic%20Rules/TM001_GROUPAddedToGroupOutsideTheObjectTierLevel.yaml",
        "query": "SecurityEvent \n| where EventID == 5136\n    and Activity has \"modified\"\n    and (EventData matches regex @\"(?i)OU=Tier 0 Accounts\" \n         or EventData matches regex @\"(?i)OU=Tier 1 Accounts\" \n         or EventData matches regex @\"(?i)OU=Tier 2 Accounts\"\n         or EventData matches regex @\"(?i)OU=Tier 0 Service Accounts\" \n         or EventData matches regex @\"(?i)OU=Tier 1 Service Accounts\" \n         or EventData matches regex @\"(?i)OU=Tier 2 Service Accounts\"\n         or EventData matches regex @\"(?i)OU=Tier 0 Groups\"\n         or EventData matches regex @\"(?i)OU=Tier 1 Groups\"\n         or EventData matches regex @\"(?i)OU=Tier 2 Groups\"\n         or EventData matches regex @\"(?i)OU=Tier 0 PAW\"\n         or EventData matches regex @\"(?i)OU=Tier 1 PAW\"\n         or EventData matches regex @\"(?i)OU=Tier 2 PAW\")\n    and EventData has '\"AttributeLDAPDisplayName\">member'\n    and EventData has 'OperationType\">14674', \"Added\", tostring(OperationType))\n| where GroupTier != ObjectTier\n| project TimeGenerated \n        , ObjectName\n        , ObjectTier\n        , ObjectType = AccountType\n        , GroupName\n        , GroupTier\n        , ActivityType\n        , OperationType\n        , Account\n        , Domain\n        , Computer\n        , Channel\n        , EventID\n        , EventData\n",
        "queryFrequency": "PT5M",
        "queryPeriod": "PT5M",
        "severity": "High",
        "status": "Available",
        "subTechniques": [
          "T1078.002"
        ],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "PrivilegeEscalation"
        ],
        "techniques": [
          "T1078"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
