{
  "$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/3c5be96e-2eeb-439a-9856-1c23aa72cfdd')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/3c5be96e-2eeb-439a-9856-1c23aa72cfdd')]",
      "properties": {
        "alertRuleTemplateName": "3c5be96e-2eeb-439a-9856-1c23aa72cfdd",
        "customDetails": null,
        "description": "Detects applications with open BOLA/IDOR findings (OWASP API1, API3, API5)\nthat also show anomalous 4xx error traffic in Azure API Management.\nCorrelates StratoSecure BOLA findings with APIM gateway error spikes.\n",
        "displayName": "BOLA Finding with API Traffic Anomaly",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "CloudApplication",
            "fieldMappings": [
              {
                "columnName": "ApplicationId",
                "identifier": "AppId"
              }
            ]
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/StratoSecure/Analytic%20Rules/S3_BOLA_TrafficAnomaly.yaml",
        "query": "let lookback = 1h;\nlet enumThreshold = 100;\nlet BolaFindings = StratoSecure_Findings_CL\n    | where TimeGenerated >= ago(lookback)\n    | where FixStatus =~ \"open\"\n    | where OwaspCategory in (\"API1\", \"API3\", \"API5\")\n    | where Severity in (\"Critical\", \"High\")\n    | summarize FindingCount = count(), RuleIds = make_set(RuleId)\n        by ApplicationId, StraTenantId;\nlet TrafficAnomalies = ApiManagementGatewayLogs\n    | where TimeGenerated >= ago(lookback)\n    | where ResponseCode in (403, 401, 404)\n    | summarize ErrorCount = count(), DistinctCallers = dcount(CallerIpAddress),\n        Paths = make_set(Url, 30), LastSeen = max(TimeGenerated)\n        by ApiId, OperationId\n    | where ErrorCount >= enumThreshold;\nBolaFindings\n    | join kind=inner TrafficAnomalies on $left.ApplicationId == $right.ApiId\n    | project TimeGenerated = LastSeen, ApplicationId, StraTenantId,\n        FindingCount, RuleIds, ErrorCount, DistinctCallers, Paths\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "PT75M",
        "severity": "High",
        "status": "Available",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "Discovery",
          "InitialAccess"
        ],
        "techniques": [
          "T1083",
          "T1190"
        ],
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}
