← Back to SOC feed Coverage →

detect-suspicious-mshta-usage

kql MEDIUM Azure-Sentinel
DeviceProcessEvents
huntingmicrosoftofficial
This rule was pulled from an open-source repository and enriched with AI. Validate in a test environment before deploying to production.
View original rule at Azure-Sentinel →
Retrieved: 2026-05-20T23:00:01Z · Confidence: medium

Hunt Hypothesis

Adversaries may use Microsoft HTA files to execute malicious code under the guise of legitimate scripts, leveraging HTA’s ability to run without user interaction. SOC teams should proactively hunt for this behavior in Azure Sentinel to identify potential Ursnif (Gozi) malware activity and prevent data exfiltration or persistence.

KQL Query

// mshta.exe script launching processes
DeviceProcessEvents 
| where Timestamp > ago(7d)
and InitiatingProcessFileName =~ 'mshta.exe'
and InitiatingProcessCommandLine contains '<script>'

Analytic Rule Definition

id: 9462573d-09e3-4878-a118-db5c964228e0
name: detect-suspicious-mshta-usage
description: |
  This query was originally published in the threat analytics report, Ursnif (Gozi) continues to evolve.
  Microsoft HTML Applications, or HTAs, are executable files that use the same technologies and models as Internet Explorer, but do not run inside of a web browser.
  Mshta.exe is a Windows utility that provides a host for HTA files to run in. Although it has legitimate uses, attackers can use mshta.exe to run malicious Javascript or VBScript commands. The MITRE ATT&CK framework includes Mshta among its list of enterprise attack techniques.
  The following query detects when mshta.exe has been run, which might include illegitimate usage by attackers.
  References:
  https://docs.microsoft.com/previous-versions/ms536496(v=vs.85)
  https://attack.mitre.org/techniques/T1170/
requiredDataConnectors:
- connectorId: MicrosoftThreatProtection
  dataTypes:
  - DeviceProcessEvents
tactics:
- Execution
- Execution
query: |
  // mshta.exe script launching processes
  DeviceProcessEvents 
  | where Timestamp > ago(7d)
  and InitiatingProcessFileName =~ 'mshta.exe'
  and InitiatingProcessCommandLine contains '<script>'

Required Data Sources

Sentinel TableNotes
DeviceProcessEventsEnsure this data connector is enabled

MITRE ATT&CK Context

References

False Positive Guidance

Original source: https://github.com/Azure/Azure-Sentinel/blob/main/Hunting Queries/Microsoft 365 Defender/Execution/detect-suspicious-mshta-usage.yaml