HAFNIUM UM Service writing suspicious file
Id | 7d6d8a8e-b08a-4082-8dbb-d7fd2cbbc35e |
Rulename | HAFNIUM UM Service writing suspicious file |
Description | This query looks for the Exchange server UM process writing suspicious files that may be indicative of webshells. Reference: https://www.microsoft.com/security/blog/2021/03/02/hafnium-targeting-exchange-servers/ |
Severity | High |
Tactics | InitialAccess |
Techniques | T1190 |
Required data connectors | MicrosoftThreatProtection SecurityEvents WindowsForwardedEvents WindowsSecurityEvents |
Kind | Scheduled |
Query frequency | 1d |
Query period | 1d |
Trigger threshold | 0 |
Trigger operator | gt |
Source Uri | https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Legacy IOC based Threat Protection/Analytic Rules/HAFNIUMUmServiceSuspiciousFile.yaml |
Version | 1.2.3 |
Arm template | 7d6d8a8e-b08a-4082-8dbb-d7fd2cbbc35e.json |
let scriptExtensions = dynamic([".php", ".jsp", ".js", ".aspx", ".asmx", ".asax", ".cfm", ".shtml"]);
union isfuzzy=true
(SecurityEvent
| where EventID == 4663
| where Process has_any ("umworkerprocess.exe", "UMService.exe")
| where ObjectName has_any (scriptExtensions)
| where AccessMask in ('0x2','0x100', '0x10', '0x4')
| extend timestamp = TimeGenerated, AccountCustomEntity = Account, HostCustomEntity = Computer, IPCustomEntity = IpAddress
),
(WindowsEvent
| where EventID == 4663 and EventData has_any ("umworkerprocess.exe", "UMService.exe") and EventData has_any (scriptExtensions)
| where EventData has_any ('0x2','0x100', '0x10', '0x4')
| extend NewProcessName = tostring(EventData.NewProcessName)
| extend Process=tostring(split(NewProcessName, '\\')[-1])
| where Process has_any ("umworkerprocess.exe", "UMService.exe")
| extend ObjectName = tostring(EventData.ObjectName)
| where ObjectName has_any (scriptExtensions)
| extend AccessMask = tostring(EventData.AccessMask)
| where AccessMask in ('0x2','0x100', '0x10', '0x4')
| extend Account = strcat(EventData.SubjectDomainName,"\\", EventData.SubjectUserName)
| extend IpAddress = tostring(EventData.IpAddress)
| extend timestamp = TimeGenerated, AccountCustomEntity = Account, HostCustomEntity = Computer, IPCustomEntity = IpAddress
),
(imFileEvent
| where EventType == "FileCreated"
| where ActingProcessName has_any ("umworkerprocess.exe", "UMService.exe")
and
TargetFileName has_any (scriptExtensions)
| extend timestamp = TimeGenerated, AccountCustomEntity = ActorUsername, HostCustomEntity = DvcHostname
),
(DeviceFileEvents
| where ActionType =~ "FileCreated"
| where InitiatingProcessFileName has_any ("umworkerprocess.exe", "UMService.exe")
| where FileName has_any(scriptExtensions)
| extend timestamp = TimeGenerated, AccountCustomEntity = InitiatingProcessAccountUpn, HostCustomEntity = DeviceName, IPCustomEntity = RequestSourceIP)
triggerOperator: gt
id: 7d6d8a8e-b08a-4082-8dbb-d7fd2cbbc35e
queryFrequency: 1d
entityMappings:
- entityType: Account
fieldMappings:
- columnName: InitiatingProcessAccountUpn
identifier: FullName
- entityType: Account
fieldMappings:
- columnName: AccountCustomEntity
identifier: FullName
- entityType: Host
fieldMappings:
- columnName: HostCustomEntity
identifier: FullName
- entityType: Host
fieldMappings:
- columnName: DeviceName
identifier: FullName
- entityType: IP
fieldMappings:
- columnName: IPCustomEntity
identifier: Address
requiredDataConnectors:
- dataTypes:
- SecurityEvent
connectorId: SecurityEvents
- dataTypes:
- DeviceFileEvents
connectorId: MicrosoftThreatProtection
- dataTypes:
- SecurityEvents
connectorId: WindowsSecurityEvents
- dataTypes:
- WindowsEvent
connectorId: WindowsForwardedEvents
severity: High
metadata:
source:
kind: Community
categories:
domains:
- Security - Threat Protection
support:
tier: Community
author:
name: Jessen
triggerThreshold: 0
kind: Scheduled
status: Available
queryPeriod: 1d
OriginalUri: https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Legacy IOC based Threat Protection/Analytic Rules/HAFNIUMUmServiceSuspiciousFile.yaml
query: |
let scriptExtensions = dynamic([".php", ".jsp", ".js", ".aspx", ".asmx", ".asax", ".cfm", ".shtml"]);
union isfuzzy=true
(SecurityEvent
| where EventID == 4663
| where Process has_any ("umworkerprocess.exe", "UMService.exe")
| where ObjectName has_any (scriptExtensions)
| where AccessMask in ('0x2','0x100', '0x10', '0x4')
| extend timestamp = TimeGenerated, AccountCustomEntity = Account, HostCustomEntity = Computer, IPCustomEntity = IpAddress
),
(WindowsEvent
| where EventID == 4663 and EventData has_any ("umworkerprocess.exe", "UMService.exe") and EventData has_any (scriptExtensions)
| where EventData has_any ('0x2','0x100', '0x10', '0x4')
| extend NewProcessName = tostring(EventData.NewProcessName)
| extend Process=tostring(split(NewProcessName, '\\')[-1])
| where Process has_any ("umworkerprocess.exe", "UMService.exe")
| extend ObjectName = tostring(EventData.ObjectName)
| where ObjectName has_any (scriptExtensions)
| extend AccessMask = tostring(EventData.AccessMask)
| where AccessMask in ('0x2','0x100', '0x10', '0x4')
| extend Account = strcat(EventData.SubjectDomainName,"\\", EventData.SubjectUserName)
| extend IpAddress = tostring(EventData.IpAddress)
| extend timestamp = TimeGenerated, AccountCustomEntity = Account, HostCustomEntity = Computer, IPCustomEntity = IpAddress
),
(imFileEvent
| where EventType == "FileCreated"
| where ActingProcessName has_any ("umworkerprocess.exe", "UMService.exe")
and
TargetFileName has_any (scriptExtensions)
| extend timestamp = TimeGenerated, AccountCustomEntity = ActorUsername, HostCustomEntity = DvcHostname
),
(DeviceFileEvents
| where ActionType =~ "FileCreated"
| where InitiatingProcessFileName has_any ("umworkerprocess.exe", "UMService.exe")
| where FileName has_any(scriptExtensions)
| extend timestamp = TimeGenerated, AccountCustomEntity = InitiatingProcessAccountUpn, HostCustomEntity = DeviceName, IPCustomEntity = RequestSourceIP)
description: |
'This query looks for the Exchange server UM process writing suspicious files that may be indicative of webshells.
Reference: https://www.microsoft.com/security/blog/2021/03/02/hafnium-targeting-exchange-servers/'
name: HAFNIUM UM Service writing suspicious file
relevantTechniques:
- T1190
tactics:
- InitialAccess
version: 1.2.3
tags:
- Schema: ASIMFileEvent
SchemaVersion: 0.1.0
{
"$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/7d6d8a8e-b08a-4082-8dbb-d7fd2cbbc35e')]",
"name": "[concat(parameters('workspace'),'/Microsoft.SecurityInsights/7d6d8a8e-b08a-4082-8dbb-d7fd2cbbc35e')]",
"type": "Microsoft.OperationalInsights/workspaces/providers/alertRules",
"kind": "Scheduled",
"apiVersion": "2022-11-01",
"properties": {
"displayName": "HAFNIUM UM Service writing suspicious file",
"description": "'This query looks for the Exchange server UM process writing suspicious files that may be indicative of webshells.\nReference: https://www.microsoft.com/security/blog/2021/03/02/hafnium-targeting-exchange-servers/'\n",
"severity": "High",
"enabled": true,
"query": "let scriptExtensions = dynamic([\".php\", \".jsp\", \".js\", \".aspx\", \".asmx\", \".asax\", \".cfm\", \".shtml\"]);\nunion isfuzzy=true\n(SecurityEvent\n| where EventID == 4663\n| where Process has_any (\"umworkerprocess.exe\", \"UMService.exe\")\n| where ObjectName has_any (scriptExtensions)\n| where AccessMask in ('0x2','0x100', '0x10', '0x4')\n| extend timestamp = TimeGenerated, AccountCustomEntity = Account, HostCustomEntity = Computer, IPCustomEntity = IpAddress\n),\n (WindowsEvent\n| where EventID == 4663 and EventData has_any (\"umworkerprocess.exe\", \"UMService.exe\") and EventData has_any (scriptExtensions) \n| where EventData has_any ('0x2','0x100', '0x10', '0x4')\n| extend NewProcessName = tostring(EventData.NewProcessName)\n| extend Process=tostring(split(NewProcessName, '\\\\')[-1])\n| where Process has_any (\"umworkerprocess.exe\", \"UMService.exe\")\n| extend ObjectName = tostring(EventData.ObjectName)\n| where ObjectName has_any (scriptExtensions)\n| extend AccessMask = tostring(EventData.AccessMask)\n| where AccessMask in ('0x2','0x100', '0x10', '0x4')\n| extend Account = strcat(EventData.SubjectDomainName,\"\\\\\", EventData.SubjectUserName)\n| extend IpAddress = tostring(EventData.IpAddress)\n| extend timestamp = TimeGenerated, AccountCustomEntity = Account, HostCustomEntity = Computer, IPCustomEntity = IpAddress\n),\n(imFileEvent\n| where EventType == \"FileCreated\"\n| where ActingProcessName has_any (\"umworkerprocess.exe\", \"UMService.exe\")\n and\n TargetFileName has_any (scriptExtensions)\n| extend timestamp = TimeGenerated, AccountCustomEntity = ActorUsername, HostCustomEntity = DvcHostname\n),\n(DeviceFileEvents\n| where ActionType =~ \"FileCreated\"\n| where InitiatingProcessFileName has_any (\"umworkerprocess.exe\", \"UMService.exe\")\n| where FileName has_any(scriptExtensions)\n| extend timestamp = TimeGenerated, AccountCustomEntity = InitiatingProcessAccountUpn, HostCustomEntity = DeviceName, IPCustomEntity = RequestSourceIP)\n",
"queryFrequency": "P1D",
"queryPeriod": "P1D",
"triggerOperator": "GreaterThan",
"triggerThreshold": 0,
"suppressionDuration": "PT1H",
"suppressionEnabled": false,
"tactics": [
"InitialAccess"
],
"techniques": [
"T1190"
],
"alertRuleTemplateName": "7d6d8a8e-b08a-4082-8dbb-d7fd2cbbc35e",
"customDetails": null,
"entityMappings": [
{
"fieldMappings": [
{
"identifier": "FullName",
"columnName": "InitiatingProcessAccountUpn"
}
],
"entityType": "Account"
},
{
"fieldMappings": [
{
"identifier": "FullName",
"columnName": "AccountCustomEntity"
}
],
"entityType": "Account"
},
{
"fieldMappings": [
{
"identifier": "FullName",
"columnName": "HostCustomEntity"
}
],
"entityType": "Host"
},
{
"fieldMappings": [
{
"identifier": "FullName",
"columnName": "DeviceName"
}
],
"entityType": "Host"
},
{
"fieldMappings": [
{
"identifier": "Address",
"columnName": "IPCustomEntity"
}
],
"entityType": "IP"
}
],
"OriginalUri": "https://github.com/Azure/Azure-Sentinel/blob/master/Solutions/Legacy IOC based Threat Protection/Analytic Rules/HAFNIUMUmServiceSuspiciousFile.yaml",
"templateVersion": "1.2.3",
"tags": [
{
"Schema": "ASIMFileEvent",
"SchemaVersion": "0.1.0"
}
],
"status": "Available"
}
}
]
}