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

Azure Diagnostic settings removed from a resource

Back
Id6e95aef3-a1e0-4063-8e74-cd59aa59f245
RulenameAzure Diagnostic settings removed from a resource
DescriptionThis query looks for diagnostic settings that are removed from a resource.

This could indicate an attacker or malicious internal trying to evade detection before malicious act is performed.

If the diagnostic settings are being deleted as part of a parent resource deletion, the event is ignores.
SeverityMedium
TacticsDefenseEvasion
TechniquesT1562.008
Required data connectorsAzureActivity
KindScheduled
Query frequency1h
Query period2h
Trigger threshold0
Trigger operatorgt
Source Urihttps://github.com/Azure/Azure-Sentinel/blob/master/Detections/AzureActivity/AzDiagSettingsDeleted.yaml
Version1.0.1
Arm template6e95aef3-a1e0-4063-8e74-cd59aa59f245.json
Deploy To Azure
AzureActivity
  | where OperationNameValue == 'MICROSOFT.INSIGHTS/DIAGNOSTICSETTINGS/DELETE' and ActivityStatusValue == "Start"
  | extend ParentResource_a = split(_ResourceId,"/")
  | extend ParentResourceLength = array_length(ParentResource_a)-4
  | extend ParentResourceSplit = array_split(ParentResource_a,ParentResourceLength)
  | extend resource = strcat_array(ParentResourceSplit[0],"/")
  | project Diagdelete = TimeGenerated, Caller, ResourceProviderValue, _ResourceId, SubscriptionId, ResourceGroup, OperationNameValue, ActivityStatusValue, ActivitySubstatusValue, Start=TimeGenerated, resource, CallerIpAddress
  | join kind=leftanti  ( AzureActivity
  | where OperationNameValue != 'MICROSOFT.INSIGHTS/DIAGNOSTICSETTINGS/DELETE' and OperationNameValue endswith "/DELETE"
  | where ActivityStatusValue == 'Start'
  | project Caller, ResourceProviderValue, resource = tostring(parse_json(Properties).resource), SubscriptionId, ResourceGroup, OperationNameValue, ActivityStatusValue, ActivitySubstatusValue, Start=TimeGenerated) on $left.resource == $right.resource
  | project Caller, ResourceProviderValue, resource, SubscriptionId, ResourceGroup, OperationNameValue, ActivityStatusValue, ActivitySubstatusValue, Start, CallerIpAddress
tactics:
- DefenseEvasion
severity: Medium
requiredDataConnectors:
- connectorId: AzureActivity
  dataTypes:
  - AzureActivity
triggerOperator: gt
query: |
  AzureActivity
    | where OperationNameValue == 'MICROSOFT.INSIGHTS/DIAGNOSTICSETTINGS/DELETE' and ActivityStatusValue == "Start"
    | extend ParentResource_a = split(_ResourceId,"/")
    | extend ParentResourceLength = array_length(ParentResource_a)-4
    | extend ParentResourceSplit = array_split(ParentResource_a,ParentResourceLength)
    | extend resource = strcat_array(ParentResourceSplit[0],"/")
    | project Diagdelete = TimeGenerated, Caller, ResourceProviderValue, _ResourceId, SubscriptionId, ResourceGroup, OperationNameValue, ActivityStatusValue, ActivitySubstatusValue, Start=TimeGenerated, resource, CallerIpAddress
    | join kind=leftanti  ( AzureActivity
    | where OperationNameValue != 'MICROSOFT.INSIGHTS/DIAGNOSTICSETTINGS/DELETE' and OperationNameValue endswith "/DELETE"
    | where ActivityStatusValue == 'Start'
    | project Caller, ResourceProviderValue, resource = tostring(parse_json(Properties).resource), SubscriptionId, ResourceGroup, OperationNameValue, ActivityStatusValue, ActivitySubstatusValue, Start=TimeGenerated) on $left.resource == $right.resource
    | project Caller, ResourceProviderValue, resource, SubscriptionId, ResourceGroup, OperationNameValue, ActivityStatusValue, ActivitySubstatusValue, Start, CallerIpAddress  
triggerThreshold: 0
name: Azure Diagnostic settings removed from a resource
kind: Scheduled
version: 1.0.1
relevantTechniques:
- T1562.008
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Detections/AzureActivity/AzDiagSettingsDeleted.yaml
description: |
  'This query looks for diagnostic settings that are removed from a resource.
  This could indicate an attacker or malicious internal trying to evade detection before malicious act is performed.
  If the diagnostic settings are being deleted as part of a parent resource deletion, the event is ignores.'  
entityMappings:
- entityType: Account
  fieldMappings:
  - identifier: Name
    columnName: Caller
- entityType: IP
  fieldMappings:
  - identifier: Address
    columnName: CallerIpAddress
queryFrequency: 1h
queryPeriod: 2h
metadata:
  support:
    tier: Community
  categories:
    domains:
    - Security - Others
    - Platform
  source:
    kind: Community
  author:
    name: KennethMLdk
id: 6e95aef3-a1e0-4063-8e74-cd59aa59f245
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "workspace": {
      "type": "String"
    }
  },
  "resources": [
    {
      "id": "[concat(resourceId('Microsoft.OperationalInsights/workspaces/providers', parameters('workspace'), 'Microsoft.SecurityInsights'),'/alertRules/6e95aef3-a1e0-4063-8e74-cd59aa59f245')]",
      "name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/6e95aef3-a1e0-4063-8e74-cd59aa59f245')]",
      "type": "Microsoft.OperationalInsights/workspaces/providers/alertRules",
      "kind": "Scheduled",
      "apiVersion": "2022-11-01",
      "properties": {
        "displayName": "Azure Diagnostic settings removed from a resource",
        "description": "'This query looks for diagnostic settings that are removed from a resource.\nThis could indicate an attacker or malicious internal trying to evade detection before malicious act is performed.\nIf the diagnostic settings are being deleted as part of a parent resource deletion, the event is ignores.'\n",
        "severity": "Medium",
        "enabled": true,
        "query": "AzureActivity\n  | where OperationNameValue == 'MICROSOFT.INSIGHTS/DIAGNOSTICSETTINGS/DELETE' and ActivityStatusValue == \"Start\"\n  | extend ParentResource_a = split(_ResourceId,\"/\")\n  | extend ParentResourceLength = array_length(ParentResource_a)-4\n  | extend ParentResourceSplit = array_split(ParentResource_a,ParentResourceLength)\n  | extend resource = strcat_array(ParentResourceSplit[0],\"/\")\n  | project Diagdelete = TimeGenerated, Caller, ResourceProviderValue, _ResourceId, SubscriptionId, ResourceGroup, OperationNameValue, ActivityStatusValue, ActivitySubstatusValue, Start=TimeGenerated, resource, CallerIpAddress\n  | join kind=leftanti  ( AzureActivity\n  | where OperationNameValue != 'MICROSOFT.INSIGHTS/DIAGNOSTICSETTINGS/DELETE' and OperationNameValue endswith \"/DELETE\"\n  | where ActivityStatusValue == 'Start'\n  | project Caller, ResourceProviderValue, resource = tostring(parse_json(Properties).resource), SubscriptionId, ResourceGroup, OperationNameValue, ActivityStatusValue, ActivitySubstatusValue, Start=TimeGenerated) on $left.resource == $right.resource\n  | project Caller, ResourceProviderValue, resource, SubscriptionId, ResourceGroup, OperationNameValue, ActivityStatusValue, ActivitySubstatusValue, Start, CallerIpAddress\n",
        "queryFrequency": "PT1H",
        "queryPeriod": "PT2H",
        "triggerOperator": "GreaterThan",
        "triggerThreshold": 0,
        "suppressionDuration": "PT1H",
        "suppressionEnabled": false,
        "tactics": [
          "DefenseEvasion"
        ],
        "techniques": [
          "T1562.008"
        ],
        "alertRuleTemplateName": "6e95aef3-a1e0-4063-8e74-cd59aa59f245",
        "customDetails": null,
        "entityMappings": [
          {
            "fieldMappings": [
              {
                "columnName": "Caller",
                "identifier": "Name"
              }
            ],
            "entityType": "Account"
          },
          {
            "fieldMappings": [
              {
                "columnName": "CallerIpAddress",
                "identifier": "Address"
              }
            ],
            "entityType": "IP"
          }
        ],
        "OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Detections/AzureActivity/AzDiagSettingsDeleted.yaml",
        "templateVersion": "1.0.1"
      }
    }
  ]
}