Back
Idc6258d51-7b82-4942-8293-94c1dcf91595
RulenameAPI - Rate limiting
Description42Crunch API protection against first-time access
SeverityLow
TacticsDiscovery
InitialAccess
TechniquesT1087
T1190
Required data connectors42CrunchAPIProtection
FortyTwoCrunchAPIProtection
KindScheduled
Query frequency1d
Query period7d
Trigger threshold0
Trigger operatorgt
Source Urihttps://github.com/Azure/Azure-Sentinel/blob/master/Solutions/42Crunch%20API%20Protection/Analytic%20Rules/APIFirstTimeAccess.yaml
Version3.0.1
Arm templatec6258d51-7b82-4942-8293-94c1dcf91595.json
Deploy To Azure
let firstRec = FortyTwoCrunchAPIProtection
| where TimeGenerated >= ago(5m) 
| project-away NonBlockingMode, SourcePort, DestinationPort, Query, ApiId, RequestHeader, ResponseHeader, Errors, EventType, Uuid
| where UriPath has "/api/login" |
top 1 by Timestamp desc;
let ipAddress = toscalar(firstRec | summarize by SourceIp);
let secondRec = FortyTwoCrunchAPIProtection
| where TimeGenerated >= ago(7d) 
| project-away NonBlockingMode, SourcePort, DestinationPort, Query, ApiId, RequestHeader, ResponseHeader, Errors, EventType, Uuid
| where UriPath has "/api/login" and SourceIp == ipAddress;
let recCount = iff((toscalar(secondRec | count) > 1), 0, 1);
secondRec | take recCount
entityMappings:
- entityType: IP
  fieldMappings:
  - identifier: Address
    columnName: SourceIp
- entityType: Host
  fieldMappings:
  - identifier: HostName
    columnName: Hostname
- entityType: Account
  fieldMappings:
  - identifier: FullName
    columnName: InstanceName
name: API - Rate limiting
kind: Scheduled
triggerOperator: gt
status: Available
customDetails: 
queryPeriod: 7d
requiredDataConnectors:
- connectorId: 42CrunchAPIProtection
  dataTypes:
  - FortyTwoCrunchAPIProtection
- connectorId: FortyTwoCrunchAPIProtection
  dataTypes:
  - FortyTwoCrunchAPIProtection
tactics:
- Discovery
- InitialAccess
query: |
  let firstRec = FortyTwoCrunchAPIProtection
  | where TimeGenerated >= ago(5m) 
  | project-away NonBlockingMode, SourcePort, DestinationPort, Query, ApiId, RequestHeader, ResponseHeader, Errors, EventType, Uuid
  | where UriPath has "/api/login" |
  top 1 by Timestamp desc;
  let ipAddress = toscalar(firstRec | summarize by SourceIp);
  let secondRec = FortyTwoCrunchAPIProtection
  | where TimeGenerated >= ago(7d) 
  | project-away NonBlockingMode, SourcePort, DestinationPort, Query, ApiId, RequestHeader, ResponseHeader, Errors, EventType, Uuid
  | where UriPath has "/api/login" and SourceIp == ipAddress;
  let recCount = iff((toscalar(secondRec | count) > 1), 0, 1);
  secondRec | take recCount
description: |
  '42Crunch API protection against first-time access'
severity: Low
id: c6258d51-7b82-4942-8293-94c1dcf91595
eventGroupingSettings:
  aggregationKind: SingleAlert
triggerThreshold: 0
queryFrequency: 1d
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/42Crunch%20API%20Protection/Analytic%20Rules/APIFirstTimeAccess.yaml
version: 3.0.1
relevantTechniques:
- T1087
- T1190
{
  "$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/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": "SourceIp",
                "identifier": "Address"
              }
            ]
          },
          {
            "entityType": "Host",
            "fieldMappings": [
              {
                "columnName": "Hostname",
                "identifier": "HostName"
              }
            ]
          },
          {
            "entityType": "Account",
            "fieldMappings": [
              {
                "columnName": "InstanceName",
                "identifier": "FullName"
              }
            ]
          }
        ],
        "eventGroupingSettings": {
          "aggregationKind": "SingleAlert"
        },
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/42Crunch%20API%20Protection/Analytic%20Rules/APIFirstTimeAccess.yaml",
        "query": "let firstRec = FortyTwoCrunchAPIProtection\n| where TimeGenerated >= ago(5m) \n| project-away NonBlockingMode, SourcePort, DestinationPort, Query, ApiId, RequestHeader, ResponseHeader, Errors, EventType, Uuid\n| where UriPath has \"/api/login\" |\ntop 1 by Timestamp desc;\nlet ipAddress = toscalar(firstRec | summarize by SourceIp);\nlet secondRec = FortyTwoCrunchAPIProtection\n| where TimeGenerated >= ago(7d) \n| project-away NonBlockingMode, SourcePort, DestinationPort, Query, ApiId, RequestHeader, ResponseHeader, Errors, EventType, Uuid\n| where UriPath has \"/api/login\" and SourceIp == ipAddress;\nlet recCount = iff((toscalar(secondRec | count) > 1), 0, 1);\nsecondRec | take recCount\n",
        "queryFrequency": "P1D",
        "queryPeriod": "P7D",
        "severity": "Low",
        "status": "Available",
        "subTechniques": [],
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "Discovery",
          "InitialAccess"
        ],
        "techniques": [
          "T1087",
          "T1190"
        ],
        "templateVersion": "3.0.1",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}