MSBUILD
INSTALLUTIL
INLINE TASKS
CSC.EXE
DetectionBlue TeamSOCOctober 12, 2026•9 min read

Detecting MSBuild and InstallUtil Abuse

MSBuild compiles and runs C# straight from an XML file. On a server or a finance workstation, that capability is an attacker’s gift.

Scroll

MSBuild and InstallUtil ship with the .NET Framework and are signed by Microsoft. MSBuild can execute C# defined inline in a project file; InstallUtil runs code in an assembly’s uninstall routine. Both execute code without launching a conventional new binary, and both are absent from most application allowlists. On hosts where nobody builds software, any use is suspicious.

Signals at a Glance

SignalWhereATT&CK
MSBuild.exe on a host that has no developer tooling or roleSysmon 1, 4688T1127.001
MSBuild project file (.xml, .csproj, .proj) in Temp, Users or ProgramDataSysmon 1T1127.001
MSBuild or InstallUtil spawned by Office, a script host or a browserSysmon 1T1127.001
InstallUtil /U with /LogToConsole=false and an assembly from a writable pathSysmon 1T1218.004
csc.exe or vbc.exe started by MSBuild, then outbound network from MSBuildSysmon 1, 3T1127.001

MSBuild Inline Tasks

A malicious project file defines a CodeTaskFactory or RoslynCodeTaskFactory task with the payload embedded as C# source. MSBuild compiles it on the fly, which is why you see csc.exe or a Roslyn compiler spawned beneath it. Developers do this in build servers and IDEs; almost nobody does it from a user's Downloads folder.

// Microsoft Defender XDR (KQL) - MSBuild outside expected developer context
let devParents = dynamic(["devenv.exe", "msbuild.exe", "vsbuild.exe", "dotnet.exe",
                          "jenkins.exe", "agent.worker.exe", "teamcity-agent.exe"]);
DeviceProcessEvents
| where FileName =~ "msbuild.exe" or InternalFileName =~ "MSBuild.exe"
| where not(InitiatingProcessFileName in~ (devParents))
| where ProcessCommandLine matches regex @"(?i)\.(xml|csproj|proj|targets|tmp)\b"
   or FolderPath !startswith @"C:\Program Files"
   or InitiatingProcessFileName in~ ("winword.exe","excel.exe","outlook.exe","wscript.exe","cscript.exe","cmd.exe","powershell.exe")
| project Timestamp, DeviceName, AccountName, InitiatingProcessFileName,
          ProcessCommandLine, FolderPath
// tune/validate: scope to non-developer device groups first to cut noise.

InstallUtil and the Compiler Chain

InstallUtil is rarer still. Legitimate use is installing a .NET service with a log file on a build or admin host. Malware uses the uninstall switch with logging suppressed to run its payload quietly:

title: InstallUtil Executing Assembly from Writable Path
logsource:
  product: windows
  category: process_creation
detection:
  selection:
    Image|endswith: '\InstallUtil.exe'
  switches:
    CommandLine|contains|all:
      - '/U'
      - '/LogToConsole=false'
  writable:
    CommandLine|contains:
      - '\Users\'
      - '\Temp\'
      - '\ProgramData\'
      - '\AppData\'
  condition: selection and (switches or writable)
level: high
# tune/validate: allow your known service-installation pipeline.
Vetted sources

Use LOLBAS entries for MSBuild and InstallUtil, the SigmaHQ rules for both, Elastic’s trusted developer utility detections, MITRE ATT&CK T1127.001 and T1218.004, and the Atomic Red Team tests for lab validation. Baseline your own environment — developers, CI agents and build servers use these tools heavily and should be a separate device group.

Build Detections That Fire

Mjolnir Security helps blue teams turn threat intelligence into high-fidelity detections across endpoint, network, identity and cloud telemetry.

Detection EngineeringManaged Detection & ResponseThreat HuntingIncident ResponsePurple Teaming
  • Detection Engineering We build and tune detections mapped to ATT&CK from your own telemetry.
  • Threat Hunting as a Service Hypothesis-driven hunts for the behaviours on this page.
  • 24/7 Incident Response Containment when a detection fires. Call +1 833 403 5875.
Written by: Mjolnir Threat Research (MTAC)  |  Published: October 12, 2026  |  Last reviewed: October 12, 2026