Azure Resource Group Deleted by Unusual Principal

Identifies Azure resource group deletions by a principal that has not performed this operation in the prior 7 days. Deletion of a resource group is permanent and removes all resources in the group. This rule uses an ES|QL first-seen (new terms) approach keyed on the acting principal so routine infrastructure-as-code teardown is suppressed after the first occurrence, while still surfacing first-time or unusual identities performing the delete.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/08/17"
  3integration = ["azure"]
  4maturity = "production"
  5updated_date = "2026/09/21"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies Azure resource group deletions by a principal that has not performed this operation in the prior 7 days.
 11Deletion of a resource group is permanent and removes all resources in the group. This rule uses an ES|QL first-seen
 12(new terms) approach keyed on the acting principal so routine infrastructure-as-code teardown is suppressed after the
 13first occurrence, while still surfacing first-time or unusual identities performing the delete.
 14"""
 15false_positives = [
 16    """
 17    Infrastructure-as-code, CI/CD, and platform automation (for example Crossplane, Terraform, ARM/Bicep, AKS control
 18    plane) commonly delete resource groups during environment teardown. The first occurrence per principal will alert;
 19    baseline expected service principals and exclude them if the activity is authorized.
 20    """,
 21    """
 22    Administrators may delete resource groups during decommissioning, lab cleanup, or organizational restructuring.
 23    Verify the actor, change ticket, and whether the deleted group was non-production before treating the event as
 24    malicious.
 25    """,
 26]
 27from = "now-7d"
 28language = "esql"
 29license = "Elastic License v2"
 30name = "Azure Resource Group Deleted by Unusual Principal"
 31note = """## Triage and analysis
 32
 33### Investigating Azure Resource Group Deleted by Unusual Principal
 34
 35Azure Resource Groups contain related resources for a solution. Deleting a group is irreversible and removes every resource in it. This rule aggregates successful `RESOURCEGROUPS/DELETE` operations over a 7-day lookback and alerts when a principal's first delete in that window falls in the current schedule interval. Repeat deletes by the same automation identity are suppressed; a newly seen user or service principal is not.
 36
 37### Possible investigation steps
 38
 39- Identify the acting principal from `azure.activitylogs.identity.authorization.evidence.principal_id` and check `Esql.principal_type_values` (User vs ServicePrincipal vs Group). Resolve the human-readable name from `Esql.initiated_by_user_values`.
 40- Review `Esql.appid_values` and `Esql.role_values` to distinguish first-party / IaC identities from interactive clients such as Azure Portal or Azure CLI. `Esql.role_assignment_id_values` shows which assignment granted delete.
 41- Pivot on `Esql.session_id_values` (`azure.activitylogs.identity.claims.sid`) and `Esql.unique_token_id_values` to Entra sign-in logs and Microsoft Graph activity for the same session.
 42- Use `Esql.correlation_id_values` to find related ARM operations (lock removal, mass deletes, RBAC changes) in the same activity-log transaction.
 43- Inspect `Esql.resource_group_values` and `Esql.resource_id_values` for the groups that were deleted and whether they look like lab, ephemeral, or production naming.
 44- Check `Esql.source_ip_values`, `Esql.source_country_values`, and `Esql.source_as_number_values`, then correlate Entra ID sign-in logs for the same principal around `Esql.first_time_seen`.
 45- Look for related activity by the same principal: role assignments, lock removal, mass resource deletes, or snapshot/backup deletion.
 46- Confirm whether the delete was ticketed or matches a known pipeline / GitOps controller.
 47
 48### False positive analysis
 49
 50- Crossplane, Terraform, GitHub Actions, and similar automation will alert on the first resource-group delete per principal in 7 days, then go quiet. Exclude verified automation principals after review.
 51- AKS and other Microsoft-owned control-plane identities may delete managed node resource groups as part of cluster lifecycle.
 52- Newly provisioned automation identities performing expected teardown will fire once; do not allowlist by tenant or user GUID.
 53
 54### Response and remediation
 55
 56- If unauthorized, disable the principal, revoke standing Contributor/Owner on the subscription, and place resource locks on remaining critical groups.
 57- Restore from backup or IaC state if the deleted group hosted production resources.
 58- Audit other deletes and RBAC changes by the same principal during the same window.
 59- Require privileged delete operations to go through PIM or a change-control pipeline.
 60"""
 61references = [
 62    "https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/manage-resource-groups-portal",
 63]
 64risk_score = 47
 65rule_id = "bb4fe8d2-7ae2-475c-8b5d-55b449e4264f"
 66severity = "medium"
 67tags = [
 68    "Domain: Cloud",
 69    "Data Source: Azure",
 70    "Use Case: Log Auditing",
 71    "Tactic: Impact",
 72    "Resources: Investigation Guide",
 73    "Noise: Low",
 74    "Performance: Fast",
 75    "Profile: Recommended",
 76    "Tactic: Defense Evasion",
 77    "Rule Type: ES|QL",
 78    "Platform: Azure",
 79    "Data Source: Azure Activity Logs",
 80    "Service: Azure Resource Manager",
 81]
 82timestamp_override = "event.ingested"
 83type = "esql"
 84
 85query = '''
 86FROM logs-azure.activitylogs-*, filebeat-*
 87| WHERE data_stream.dataset == "azure.activitylogs"
 88    AND event.action == "MICROSOFT.RESOURCES/SUBSCRIPTIONS/RESOURCEGROUPS/DELETE"
 89    AND event.outcome IN ("success", "Success")
 90    AND azure.activitylogs.identity.authorization.evidence.principal_id IS NOT NULL
 91| STATS Esql.first_time_seen = MIN(@timestamp),
 92        Esql.last_time_seen = MAX(@timestamp),
 93        Esql.event_count = COUNT(*),
 94        Esql.resource_group_values = VALUES(azure.resource.group),
 95        Esql.resource_name_values = VALUES(azure.resource.name),
 96        Esql.resource_id_values = VALUES(azure.resource.id),
 97        Esql.principal_type_values = VALUES(azure.activitylogs.identity.authorization.evidence.principal_type),
 98        Esql.initiated_by_user_values = VALUES(azure.activitylogs.identity.claims_initiated_by_user.name),
 99        Esql.appid_values = VALUES(azure.activitylogs.identity.claims.appid),
100        Esql.session_id_values = VALUES(azure.activitylogs.identity.claims.sid),
101        Esql.unique_token_id_values = VALUES(azure.activitylogs.identity.claims.uti),
102        Esql.correlation_id_values = VALUES(azure.correlation_id),
103        Esql.role_values = VALUES(azure.activitylogs.identity.authorization.evidence.role),
104        Esql.role_assignment_id_values = VALUES(azure.activitylogs.identity.authorization.evidence.role_assignment_id),
105        Esql.source_ip_values = VALUES(source.ip),
106        Esql.source_country_values = VALUES(source.geo.country_name),
107        Esql.source_as_number_values = VALUES(source.`as`.number),
108        Esql.subscription_id_values = VALUES(azure.subscription_id)
109        BY azure.activitylogs.identity.authorization.evidence.principal_id
110// new terms emulation: fire when this principal's first_seen falls in the current interval
111// (schedule + ingest-lag buffer), i.e. it was absent from the rest of the 7-day window
112| EVAL Esql.recent_minutes = DATE_DIFF("minute", Esql.first_time_seen, NOW())
113| WHERE Esql.recent_minutes <= 10
114| KEEP azure.*, Esql.*
115'''
116
117
118[[rule.threat]]
119framework = "MITRE ATT&CK"
120[[rule.threat.technique]]
121id = "T1529"
122name = "System Shutdown/Reboot"
123reference = "https://attack.mitre.org/techniques/T1529/"
124
125[[rule.threat.technique]]
126id = "T1490"
127name = "Inhibit System Recovery"
128reference = "https://attack.mitre.org/techniques/T1490/"
129
130[[rule.threat.technique]]
131id = "T1489"
132name = "Service Stop"
133reference = "https://attack.mitre.org/techniques/T1489/"
134
135[[rule.threat.technique]]
136id = "T1485"
137name = "Data Destruction"
138reference = "https://attack.mitre.org/techniques/T1485/"
139
140
141[rule.threat.tactic]
142id = "TA0040"
143name = "Impact"
144reference = "https://attack.mitre.org/tactics/TA0040/"
145[[rule.threat]]
146framework = "MITRE ATT&CK"
147[[rule.threat.technique]]
148id = "T1562"
149name = "Impair Defenses"
150reference = "https://attack.mitre.org/techniques/T1562/"
151[[rule.threat.technique.subtechnique]]
152id = "T1562.001"
153name = "Disable or Modify Tools"
154reference = "https://attack.mitre.org/techniques/T1562/001/"
155
156
157
158[rule.threat.tactic]
159id = "TA0005"
160name = "Defense Evasion"
161reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and analysis

Investigating Azure Resource Group Deleted by Unusual Principal

Azure Resource Groups contain related resources for a solution. Deleting a group is irreversible and removes every resource in it. This rule aggregates successful RESOURCEGROUPS/DELETE operations over a 7-day lookback and alerts when a principal's first delete in that window falls in the current schedule interval. Repeat deletes by the same automation identity are suppressed; a newly seen user or service principal is not.

Possible investigation steps

  • Identify the acting principal from azure.activitylogs.identity.authorization.evidence.principal_id and check Esql.principal_type_values (User vs ServicePrincipal vs Group). Resolve the human-readable name from Esql.initiated_by_user_values.
  • Review Esql.appid_values and Esql.role_values to distinguish first-party / IaC identities from interactive clients such as Azure Portal or Azure CLI. Esql.role_assignment_id_values shows which assignment granted delete.
  • Pivot on Esql.session_id_values (azure.activitylogs.identity.claims.sid) and Esql.unique_token_id_values to Entra sign-in logs and Microsoft Graph activity for the same session.
  • Use Esql.correlation_id_values to find related ARM operations (lock removal, mass deletes, RBAC changes) in the same activity-log transaction.
  • Inspect Esql.resource_group_values and Esql.resource_id_values for the groups that were deleted and whether they look like lab, ephemeral, or production naming.
  • Check Esql.source_ip_values, Esql.source_country_values, and Esql.source_as_number_values, then correlate Entra ID sign-in logs for the same principal around Esql.first_time_seen.
  • Look for related activity by the same principal: role assignments, lock removal, mass resource deletes, or snapshot/backup deletion.
  • Confirm whether the delete was ticketed or matches a known pipeline / GitOps controller.

False positive analysis

  • Crossplane, Terraform, GitHub Actions, and similar automation will alert on the first resource-group delete per principal in 7 days, then go quiet. Exclude verified automation principals after review.
  • AKS and other Microsoft-owned control-plane identities may delete managed node resource groups as part of cluster lifecycle.
  • Newly provisioned automation identities performing expected teardown will fire once; do not allowlist by tenant or user GUID.

Response and remediation

  • If unauthorized, disable the principal, revoke standing Contributor/Owner on the subscription, and place resource locks on remaining critical groups.
  • Restore from backup or IaC state if the deleted group hosted production resources.
  • Audit other deletes and RBAC changes by the same principal during the same window.
  • Require privileged delete operations to go through PIM or a change-control pipeline.

References

Related rules

to-top