Trusted Developer Utilities Proxy Execution: MSBuild

ID Name
T1127.001 MSBuild
T1127.002 ClickOnce

Adversaries may use MSBuild to proxy execution of code through a trusted Windows utility. MSBuild.exe (Microsoft Build Engine) is a software build platform used by Visual Studio. It handles XML formatted project files that define requirements for loading and building various platforms and configurations.[1]

Adversaries can abuse MSBuild to proxy execution of malicious code. The inline task capability of MSBuild that was introduced in .NET version 4 allows for C# or Visual Basic code to be inserted into an XML project file.[1][2] MSBuild will compile and execute the inline task. MSBuild.exe is a signed Microsoft binary, so when it is used this way it can execute arbitrary code and bypass application control defenses that are configured to allow MSBuild.exe execution.[3]

ID: T1127.001
Sub-technique of:  T1127
Tactic: Defense Evasion
Platforms: Windows
System Requirements: .NET Framework version 4 or higher
Contributors: @ionstorm; Carrie Roberts, @OrOneEqualsOne
Version: 1.3
Created: 27 March 2020
Last Modified: 14 August 2023

Procedure Examples

ID Name Description
S0363 Empire

Empire can use built-in modules to abuse trusted utilities like MSBuild.exe.[4]

C0001 Frankenstein

During Frankenstein, the threat actors used MSbuild to execute an actor-created file.[5]

S0013 PlugX

A version of PlugX loads as shellcode within a .NET Framework project using msbuild.exe, presumably to bypass application control techniques.[6]

Mitigations

ID Mitigation Description
M1042 Disable or Remove Feature or Program

MSBuild.exe may not be necessary within an environment and should be removed if not being used.

M1038 Execution Prevention

Use application control configured to block execution of msbuild.exe if it is not required for a given system or network to prevent potential misuse by adversaries. For example, in Windows 10 and Windows Server 2016 and above, Windows Defender Application Control (WDAC) policy rules may be applied to block the msbuild.exe application and to prevent abuse.[7]

Detection

ID Data Source Data Component Detects
DS0017 Command Command Execution

Monitor executed commands and arguments used before and after invocation of the utilities may also be useful in determining the origin and purpose of the binary being executed.

DS0009 Process Process Creation

Monitor for newly executed processes of MSBuild.exe. Compare recent invocations of those binaries with prior history of known good arguments and executed binaries to determine anomalous and potentially adversarial activity.

Trusted developer utilities such as MSBuild may be leveraged to run malicious code with elevated privileges. This analytic looks for any instances of msbuild.exe, which will execute any C# code placed within a given XML document; and msxsl.exe, which processes xsl transformation specifications for XML files and will execute a variaty of scripting languages contained within the XSL file. Both of these executables are rarely used outside of Visual Studio.

Analytic 1 - MSBuild and msxsl

(source="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode="1") OR (source="WinEventLog:Security" EventCode="4688")(Image="C:\Program Files (x86)\Microsoft Visual Studio\\bin\MSBuild.exe" OR Image="C:\Windows\Microsoft.NET\Framework\msbuild.exe" OR Image="C:\users\\appdata\roaming\microsoft\msxsl.exe") ParentImage!="\Microsoft Visual Studio*")

References