MSBuild Executed by Scripting Host
Detects the suspicious spawning of MSBuild.exe by Windows Script Host processes (cscript.exe or wscript.exe), a behavior often associated with malware executing malicious MSBuild processes via scripts.
This brief addresses the threat of malicious use of MSBuild.exe, a legitimate Microsoft build tool, by adversaries through scripting hosts like cscript.exe and wscript.exe. Attackers leverage this technique to bypass application control and execute arbitrary code. This activity is significant as it indicates an attempt to execute malicious code, leading to unauthorized code execution and potentially compromising the host. This technique is often associated with malware or adversaries executing malicious MSBuild processes via scripts on compromised hosts. The detection focuses on process creation events where MSBuild is a child of script hosts.
Attack Chain
- An attacker gains initial access via an undisclosed method.
- The attacker deploys a malicious script (e.g., VBScript, JScript) on the target system.
- The script is executed using Windows Script Host (cscript.exe or wscript.exe).
- The script spawns MSBuild.exe, often with command-line arguments that specify a malicious project file.
- MSBuild.exe loads and executes the malicious project file.
- The project file contains tasks designed to execute arbitrary code, download additional payloads, or perform other malicious activities.
- The executed code establishes persistence.
- The adversary achieves their objective, such as data exfiltration or lateral movement.
Impact
Successful exploitation can lead to unauthorized code execution, potentially compromising the host and allowing further malicious activities such as data theft, system compromise, or deployment of ransomware. While the number of victims and specific sectors are not specified, the potential impact is significant due to the widespread use of MSBuild and Windows Script Host in enterprise environments.
Recommendation
- Deploy the Sigma rule
MSBuild Spawned by Scripting Hostto your SIEM to identify suspicious MSBuild executions originating from scripting hosts. - Enable process creation logging (Event ID 4688 or Sysmon Event ID 1) to capture the necessary process relationships for the detection.
- Implement application control policies to restrict the execution of unsigned or untrusted MSBuild project files.
- Monitor parent-child process relationships for unusual executions of MSBuild.exe (e.g., spawned by scripting hosts) using EDR telemetry.
- Review and audit any scripts executing MSBuild.exe within the environment to identify potential malicious activity.
Detection coverage 2
MSBuild Spawned by Scripting Host
highDetects MSBuild.exe spawned by scripting hosts like wscript.exe or cscript.exe.
MSBuild Child Processes
mediumDetects MSBuild spawning suspicious child processes
Detection queries are kept inside the platform. Get full rules →