Investigators should compare the build context, project and package inputs, and process behavior before deciding whether a run was authorized.
How it works
How Does T1127.001 MSBuild Execute Untrusted Code?
MITRE says MSBuild reads XML project files and can compile and execute inline C# or Visual Basic tasks. Because MSBuild is signed, an application control policy that allows it may also allow code run through it. The parent T1127 technique covers other trusted developer utilities.
What Separates a Normal Build From Suspicious Execution?
Socket reported a separate route: a malicious NuGet package supplied an MSBuild targets file that ran a bundled DLL after each build. Its later application launch was another step; Socket did not report an inline task in that package. MITRE DET0556 pairs unusual MSBuild starts with suspicious behavior in the same process tree. Compare these events with approved build work and package inputs; the malicious library technique covers the user’s package action.
Which Related Supply Chain Question Matters?
The Compromise Software Supply Chain page covers tampered software before delivery. An untrusted dependency alone does not prove T1195.002. A software bill of materials helps identify dependencies; review build and endpoint events to assess what ran. Brandefense Cyber Threat Intelligence provides broader reported threat context.
A real example
Socket reported malicious NuGet packages in a fake developer job assessment and mapped the MSBuild behavior to T1127.001. Its analysis found a package targets file that launched a bundled DLL after builds. Socket did not establish which actor ran the operation. Its findings document build time execution, while local build and endpoint records remain necessary to assess any particular host.
How to detect
-
Check build context and arguments
MITRE DET0556 flags MSBuild outside known developer or CI work and with anomalous arguments. Compare the project path, caller and build job with approved activity.
-
Correlate child processes
MITRE DET0556 pairs an MSBuild start with unusual script interpreters or other high risk child processes in a short window. Check whether the build job expected each child.
-
Review files and loaded modules
MITRE DET0556 includes newly written executables or scripts in user writable locations and unsigned or invalid modules. Check file creation and module load events against expected build outputs.
-
Join network and process activity
MITRE DET0556 also includes outbound connections and process access or modification after MSBuild starts. Correlate these events with the same process tree before escalating.
How to defend
-
Remove MSBuild where unused
MITRE M1042 says MSBuild may be removed where the environment does not need it. Confirm the host's build role before making that change.
-
Block execution on hosts without build work
MITRE M1038 recommends application control rules that block msbuild.exe when a system does not require it. Test the policy against approved developer and CI jobs.
-
Review untrusted build inputs
Socket advises checking unfamiliar package references, restore sources and package targets before building a take home project. Use a disposable environment without developer credentials for untrusted assessments.
Frequently Asked Questions
Does an MSBuild process prove T1127.001?
No. MSBuild is a normal build utility. MITRE DET0556 looks for unexpected context and correlated child, file, module, process or network behavior.
Can a NuGet package run code during a build?
Yes. Socket documented a package targets file that ran a bundled DLL after builds. Review package targets and restore sources before building untrusted projects.
Where should MSBuild be restricted?
MITRE recommends removing or blocking MSBuild where it is not needed. Keep approved build hosts and jobs in scope when testing an application control policy.
