API - BOLA
Id | 1b047dc3-a879-4f99-949b-d1dc867efc83 |
Rulename | API - BOLA |
Description | 42Crunch API protection against BOLA |
Severity | Medium |
Tactics | Exfiltration |
Techniques | T1020 |
Required data connectors | 42CrunchAPIProtection |
Kind | Scheduled |
Query frequency | 5m |
Query period | 5m |
Trigger threshold | 0 |
Trigger operator | gt |
Source Uri | https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/42Crunch API Protection/Analytic Rules/APIBOLA.yaml |
Version | 1.0.1 |
Arm template | 1b047dc3-a879-4f99-949b-d1dc867efc83.json |
let loginRec = 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_5" and URI_Path_s has "/api/login" and Status_d == 200;
let ipAddress = toscalar(loginRec
| top 1 by Timestamp_t desc
| summarize by Source_IP_s);
let listRec = 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_5" and URI_Path_s has "/api/accounts/list" and Status_d == 200;
let listCnt = (toscalar(listRec | count));
let accountRec = 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_5" and Source_IP_s == ipAddress and URI_Path_s matches regex "/api/accounts/\\d{6}$";
let accountCnt = (toscalar(accountRec | count));
let recCount = iff((toscalar(listRec | count) == 0) and (accountCnt > 5), accountCnt, 0);
accountRec | take recCount
relevantTechniques:
- T1020
name: API - BOLA
requiredDataConnectors:
- dataTypes:
- apifirewall_log_1_CL
connectorId: 42CrunchAPIProtection
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
triggerThreshold: 0
id: 1b047dc3-a879-4f99-949b-d1dc867efc83
tactics:
- Exfiltration
version: 1.0.1
customDetails:
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/42Crunch API Protection/Analytic Rules/APIBOLA.yaml
queryPeriod: 5m
kind: Scheduled
eventGroupingSettings:
aggregationKind: SingleAlert
queryFrequency: 5m
severity: Medium
status: Available
description: |
'42Crunch API protection against BOLA'
query: |
let loginRec = 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_5" and URI_Path_s has "/api/login" and Status_d == 200;
let ipAddress = toscalar(loginRec
| top 1 by Timestamp_t desc
| summarize by Source_IP_s);
let listRec = 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_5" and URI_Path_s has "/api/accounts/list" and Status_d == 200;
let listCnt = (toscalar(listRec | count));
let accountRec = 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_5" and Source_IP_s == ipAddress and URI_Path_s matches regex "/api/accounts/\\d{6}$";
let accountCnt = (toscalar(accountRec | count));
let recCount = iff((toscalar(listRec | count) == 0) and (accountCnt > 5), accountCnt, 0);
accountRec | take recCount
triggerOperator: gt
{
"$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/1b047dc3-a879-4f99-949b-d1dc867efc83')]",
"kind": "Scheduled",
"name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/1b047dc3-a879-4f99-949b-d1dc867efc83')]",
"properties": {
"alertRuleTemplateName": "1b047dc3-a879-4f99-949b-d1dc867efc83",
"customDetails": null,
"description": "'42Crunch API protection against BOLA'\n",
"displayName": "API - BOLA",
"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/APIBOLA.yaml",
"query": "let loginRec = 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_5\" and URI_Path_s has \"/api/login\" and Status_d == 200;\nlet ipAddress = toscalar(loginRec\n| top 1 by Timestamp_t desc\n| summarize by Source_IP_s);\nlet listRec = 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_5\" and URI_Path_s has \"/api/accounts/list\" and Status_d == 200;\nlet listCnt = (toscalar(listRec | count));\nlet accountRec = 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_5\" and Source_IP_s == ipAddress and URI_Path_s matches regex \"/api/accounts/\\\\d{6}$\";\nlet accountCnt = (toscalar(accountRec | count));\nlet recCount = iff((toscalar(listRec | count) == 0) and (accountCnt > 5), accountCnt, 0);\naccountRec | take recCount\n",
"queryFrequency": "PT5M",
"queryPeriod": "PT5M",
"severity": "Medium",
"status": "Available",
"subTechniques": [],
"suppressionDuration": "PT1H",
"suppressionEnabled": false,
"tactics": [
"Exfiltration"
],
"techniques": [
"T1020"
],
"templateVersion": "1.0.1",
"triggerOperator": "GreaterThan",
"triggerThreshold": 0
},
"type": "Microsoft.OperationalInsights/workspaces/providers/alertRules"
}
]
}