Microsoft Sentinel Analytic Rules
cloudbrothers.infoAzure Sentinel RepoToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

API - Rate limiting

Back
Idc6258d51-7b82-4942-8293-94c1dcf91595
RulenameAPI - Rate limiting
Description42Crunch API protection against first-time access
SeverityLow
TacticsDiscovery
InitialAccess
Required data connectors42CrunchAPIProtection
KindScheduled
Query frequency5m
Query period5m
Trigger threshold0
Trigger operatorgt
Source Urihttps://github.com/Azure/Azure-Sentinel/blob/master/Solutions/42Crunch API Protection/Analytic Rules/APIFirstTimeAccess.yaml
Version1.0.0
Arm templatec6258d51-7b82-4942-8293-94c1dcf91595.json
Deploy To Azure
let firstRec = apifirewall_log_1_CL
| where TimeGenerated >= ago(5m) 
| project-away Non_blocking_mode_b, Source_Port_d, Destination_Port_d, Query_s, API_ID_g, Request_Header_s, Response_Header_s, Errors_s, Type, UUID_g
| where Instance_Name_s == "Instance_9" and URI_Path_s has "/api/login" |
top 1 by Timestamp_t desc;
let ipAddress = toscalar(firstRec | summarize by Source_IP_s);
let secondRec = apifirewall_log_1_CL
| where TimeGenerated >= ago(7d) 
| project-away Non_blocking_mode_b, Source_Port_d, Destination_Port_d, Query_s, API_ID_g, Request_Header_s, Response_Header_s, Errors_s, Type, UUID_g
| where Instance_Name_s == "Instance_9" and URI_Path_s has "/api/login" and Source_IP_s == ipAddress;
let recCount = iff((toscalar(secondRec | count) > 1), 0, 1);
secondRec | take recCount
status: Available
id: c6258d51-7b82-4942-8293-94c1dcf91595
requiredDataConnectors:
- connectorId: 42CrunchAPIProtection
  dataTypes:
  - apifirewall_log_1_CL
description: |
    '42Crunch API protection against first-time access'
eventGroupingSettings:
  aggregationKind: SingleAlert
severity: Low
version: 1.0.0
entityMappings:
- fieldMappings:
  - identifier: Address
    columnName: Source_IP_s
  entityType: IP
- fieldMappings:
  - identifier: HostName
    columnName: Hostname_s
  entityType: Host
- fieldMappings:
  - identifier: FullName
    columnName: Instance_Name_s
  entityType: Account
triggerOperator: gt
triggerThreshold: 0
kind: Scheduled
queryFrequency: 5m
query: |
  let firstRec = apifirewall_log_1_CL
  | where TimeGenerated >= ago(5m) 
  | project-away Non_blocking_mode_b, Source_Port_d, Destination_Port_d, Query_s, API_ID_g, Request_Header_s, Response_Header_s, Errors_s, Type, UUID_g
  | where Instance_Name_s == "Instance_9" and URI_Path_s has "/api/login" |
  top 1 by Timestamp_t desc;
  let ipAddress = toscalar(firstRec | summarize by Source_IP_s);
  let secondRec = apifirewall_log_1_CL
  | where TimeGenerated >= ago(7d) 
  | project-away Non_blocking_mode_b, Source_Port_d, Destination_Port_d, Query_s, API_ID_g, Request_Header_s, Response_Header_s, Errors_s, Type, UUID_g
  | where Instance_Name_s == "Instance_9" and URI_Path_s has "/api/login" and Source_IP_s == ipAddress;
  let recCount = iff((toscalar(secondRec | count) > 1), 0, 1);
  secondRec | take recCount  
customDetails: 
relevantTechniques: 
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/42Crunch API Protection/Analytic Rules/APIFirstTimeAccess.yaml
tactics:
- Discovery
- InitialAccess
name: API - Rate limiting
queryPeriod: 5m
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspace": {
      "type": "String"
    }
  },
  "resources": [
    {
      "apiVersion": "2023-02-01-preview",
      "id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/c6258d51-7b82-4942-8293-94c1dcf91595')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/c6258d51-7b82-4942-8293-94c1dcf91595')]",
      "properties": {
        "alertRuleTemplateName": "c6258d51-7b82-4942-8293-94c1dcf91595",
        "customDetails": null,
        "description": "'42Crunch API protection against first-time access'\n",
        "displayName": "API - Rate limiting",
        "enabled": true,
        "entityMappings": [
          {
            "entityType": "IP",
            "fieldMappings": [
              {
                "columnName": "Source_IP_s",
                "identifier": "Address"
              }
            ]
          },
          {
            "entityType": "Host",
            "fieldMappings": [
              {
                "columnName": "Hostname_s",
                "identifier": "HostName"
              }
            ]
          },
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "Instance_Name_s",
                "identifier": "FullName"
              }
            ]
          }
        ],
        "eventGroupingSettings": {
          "aggregationKind": "SingleAlert"
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/42Crunch API Protection/Analytic Rules/APIFirstTimeAccess.yaml",
        "query": "let firstRec = apifirewall_log_1_CL\n| where TimeGenerated >= ago(5m) \n| project-away Non_blocking_mode_b, Source_Port_d, Destination_Port_d, Query_s, API_ID_g, Request_Header_s, Response_Header_s, Errors_s, Type, UUID_g\n| where Instance_Name_s == \"Instance_9\" and URI_Path_s has \"/api/login\" |\ntop 1 by Timestamp_t desc;\nlet ipAddress = toscalar(firstRec | summarize by Source_IP_s);\nlet secondRec = apifirewall_log_1_CL\n| where TimeGenerated >= ago(7d) \n| project-away Non_blocking_mode_b, Source_Port_d, Destination_Port_d, Query_s, API_ID_g, Request_Header_s, Response_Header_s, Errors_s, Type, UUID_g\n| where Instance_Name_s == \"Instance_9\" and URI_Path_s has \"/api/login\" and Source_IP_s == ipAddress;\nlet recCount = iff((toscalar(secondRec | count) > 1), 0, 1);\nsecondRec | take recCount\n",
        "queryFrequency": "PT5M",
        "queryPeriod": "PT5M",
        "severity": "Low",
        "status": "Available",
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "Discovery",
          "InitialAccess"
        ],
        "techniques": null,
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}