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

API - Suspicious Login

Back
Id7bdc10d6-aa24-4ca9-9a93-802cd8761354
RulenameAPI - Suspicious Login
Description42Crunch API protection against suspicious login
SeverityHigh
TacticsCredentialAccess
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/APISuspiciousLogin.yaml
Version1.0.0
Arm template7bdc10d6-aa24-4ca9-9a93-802cd8761354.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_6" and URI_Path_s has "/api/login?user=" and Status_d in (200, 403);
let ipAddressCount = toscalar(firstRec | summarize by Source_IP_s | count);
let secondRec = firstRec | summarize arg_max(Source_IP_s, *) by Source_IP_s;
let recCount = iff((toscalar(secondRec | count) > 3), ipAddressCount, 0);
secondRec | take recCount
queryFrequency: 5m
severity: High
id: 7bdc10d6-aa24-4ca9-9a93-802cd8761354
status: Available
requiredDataConnectors:
- dataTypes:
  - apifirewall_log_1_CL
  connectorId: 42CrunchAPIProtection
kind: Scheduled
description: |
    '42Crunch API protection against suspicious login'
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_6" and URI_Path_s has "/api/login?user=" and Status_d in (200, 403);
  let ipAddressCount = toscalar(firstRec | summarize by Source_IP_s | count);
  let secondRec = firstRec | summarize arg_max(Source_IP_s, *) by Source_IP_s;
  let recCount = iff((toscalar(secondRec | count) > 3), ipAddressCount, 0);
  secondRec | take recCount  
tactics:
- CredentialAccess
- InitialAccess
name: API - Suspicious Login
triggerThreshold: 0
triggerOperator: gt
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/42Crunch API Protection/Analytic Rules/APISuspiciousLogin.yaml
relevantTechniques: 
customDetails: 
entityMappings:
- entityType: IP
  fieldMappings:
  - identifier: Address
    columnName: Source_IP_s
- entityType: Host
  fieldMappings:
  - identifier: HostName
    columnName: Hostname_s
- entityType: Account
  fieldMappings:
  - identifier: FullName
    columnName: Instance_Name_s
version: 1.0.0
eventGroupingSettings:
  aggregationKind: SingleAlert
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/7bdc10d6-aa24-4ca9-9a93-802cd8761354')]",
      "kind": "Scheduled",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/7bdc10d6-aa24-4ca9-9a93-802cd8761354')]",
      "properties": {
        "alertRuleTemplateName": "7bdc10d6-aa24-4ca9-9a93-802cd8761354",
        "customDetails": null,
        "description": "'42Crunch API protection against suspicious login'\n",
        "displayName": "API - Suspicious Login",
        "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/APISuspiciousLogin.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_6\" and URI_Path_s has \"/api/login?user=\" and Status_d in (200, 403);\nlet ipAddressCount = toscalar(firstRec | summarize by Source_IP_s | count);\nlet secondRec = firstRec | summarize arg_max(Source_IP_s, *) by Source_IP_s;\nlet recCount = iff((toscalar(secondRec | count) > 3), ipAddressCount, 0);\nsecondRec | take recCount\n",
        "queryFrequency": "PT5M",
        "queryPeriod": "PT5M",
        "severity": "High",
        "status": "Available",
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "CredentialAccess",
          "InitialAccess"
        ],
        "techniques": null,
        "templateVersion": "1.0.0",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0
      },
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
    }
  ]
}