Microsoft Build Engine Executed After Renaming
Attackers may rename the Microsoft Build Engine (MSBuild) executable to evade detection and proxy execution of malicious code.
Attackers may rename legitimate utilities, such as MSBuild, to evade detection, application allowlists, and other security protections. MSBuild, the Microsoft Build Engine, is a platform for building applications. Attackers can abuse MSBuild to proxy the execution of malicious code. The detection rule identifies instances where MSBuild is started after being renamed, indicating a potential attempt to evade detection. The rule focuses on identifying processes where the original file name is MSBuild.exe, but the process name is different, suggesting a renaming attempt.
Attack Chain
- An attacker gains initial access to a Windows system.
- The attacker renames the legitimate MSBuild.exe executable to a different name (e.g., evil.exe) to evade detection.
- The attacker executes the renamed MSBuild executable (evil.exe) with a malicious project file (.csproj or similar).
- MSBuild processes the project file, which contains commands or scripts to be executed.
- The malicious commands within the project file are executed by MSBuild, potentially downloading or executing further payloads.
- The attacker may use MSBuild to execute PowerShell commands or other scripting languages for lateral movement or further exploitation.
- MSBuild can be used to modify files, registry entries, or other system settings.
- The attacker achieves their final objective, such as data exfiltration or establishing persistence.
Impact
Successful exploitation can lead to arbitrary code execution, allowing attackers to install malware, steal sensitive information, or compromise the entire system. The renaming of MSBuild can bypass standard application allowlisting and detection mechanisms.
Recommendation
- Enable Sysmon process creation logging to capture the
ImageandOriginalFileNamefields. - Deploy the Sigma rule “Microsoft Build Engine Using an Alternate Name” to your SIEM and tune for your environment to detect renamed MSBuild executables based on process metadata and command-line arguments.
- Monitor process execution events for processes with
OriginalFileNameof “MSBuild.exe” and a differentprocess.name. - Implement application control policies to restrict the execution of renamed executables, specifically those with an
OriginalFileNameof “MSBuild.exe.”
Detection coverage 2
Microsoft Build Engine Using an Alternate Name
mediumDetects the execution of MSBuild.exe with a different process name, indicating potential masquerading.
MSBuild Spawned from Suspicious Process
lowDetects MSBuild.exe being spawned from a suspicious parent process (cmd.exe, powershell.exe, etc.).
Detection queries are kept inside the platform. Get full rules →