Microsoft Build Engine Started by an Office Application

An instance of MSBuild, the Microsoft Build Engine, was started by Excel or Word. This is unusual behavior for the Build Engine and could have been caused by an Excel or Word document executing a malicious script payload.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/03/25"
  3integration = ["endpoint", "windows"]
  4maturity = "production"
  5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
  6min_stack_version = "8.3.0"
  7updated_date = "2024/03/28"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12An instance of MSBuild, the Microsoft Build Engine, was started by Excel or Word. This is unusual behavior for the Build
 13Engine and could have been caused by an Excel or Word document executing a malicious script payload.
 14"""
 15false_positives = [
 16    """
 17    The Build Engine is commonly used by Windows developers but use by non-engineers is unusual. It is quite unusual for
 18    this program to be started by an Office application like Word or Excel.
 19    """,
 20]
 21from = "now-9m"
 22index = ["winlogbeat-*", "logs-endpoint.events.process-*", "logs-windows.*", "endgame-*", "logs-system.security*"]
 23language = "eql"
 24license = "Elastic License v2"
 25name = "Microsoft Build Engine Started by an Office Application"
 26note = """## Triage and analysis
 27
 28### Investigating Microsoft Build Engine Started by an Office Application
 29
 30Microsoft Office (MS Office) is a suite of applications designed to help with productivity and completing common tasks on a computer. You can create and edit documents containing text and images, work with data in spreadsheets and databases, and create presentations and posters. As it is some of the most-used software across companies, MS Office is frequently targeted for initial access. It also has a wide variety of capabilities that attackers can take advantage of.
 31
 32The Microsoft Build Engine is a platform for building applications. This engine, also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software, and can be abused to proxy execution of code.
 33
 34This rule looks for the `Msbuild.exe` utility spawned by MS Office programs. This is generally the result of the execution of malicious documents.
 35
 36#### Possible investigation steps
 37
 38- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
 39- Investigate abnormal behaviors observed by the subject process, such as network connections, registry or file modifications, and any spawned child processes.
 40- Investigate other alerts associated with the user/host during the past 48 hours.
 41- Retrieve MS Office documents received and opened by the user that could cause this behavior. Common locations include, but are not limited to, the Downloads and Document folders and the folder configured at the email client.
 42- Determine if the collected files are malicious:
 43  - Use a private sandboxed malware analysis system to perform analysis.
 44    - Observe and collect information about the following activities:
 45      - Attempts to contact external domains and addresses.
 46      - File and registry access, modification, and creation activities.
 47      - Service creation and launch activities.
 48      - Scheduled task creation.
 49  - Use the PowerShell Get-FileHash cmdlet to get the files' SHA-256 hash values.
 50    - Search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
 51
 52### False positive analysis
 53
 54- This activity is unlikely to happen legitimately. Benign true positives (B-TPs) can be added as exceptions if necessary.
 55
 56### Response and remediation
 57
 58- Initiate the incident response process based on the outcome of the triage.
 59- Isolate the involved host to prevent further post-compromise behavior.
 60- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
 61- If the triage identified malware, search the environment for additional compromised hosts.
 62  - Implement temporary network rules, procedures, and segmentation to contain the malware.
 63  - Stop suspicious processes.
 64  - Immediately block the identified indicators of compromise (IoCs).
 65  - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
 66- Remove and block malicious artifacts identified during triage.
 67- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 68- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 69  - If the malicious file was delivered via phishing:
 70    - Block the email sender from sending future emails.
 71    - Block the malicious web pages.
 72    - Remove emails from the sender from mailboxes.
 73    - Consider improvements to the security awareness program.
 74- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
 75"""
 76references = ["https://blog.talosintelligence.com/2020/02/building-bypass-with-msbuild.html"]
 77risk_score = 73
 78rule_id = "c5dc3223-13a2-44a2-946c-e9dc0aa0449c"
 79setup = """## Setup
 80
 81If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2,
 82events will not define `event.ingested` and default fallback for EQL rules was not added until version 8.2.
 83Hence for this rule to work effectively, users will need to add a custom ingest pipeline to populate
 84`event.ingested` to @timestamp.
 85For more details on adding a custom ingest pipeline refer - https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html
 86"""
 87severity = "high"
 88tags = [
 89    "Domain: Endpoint",
 90    "OS: Windows",
 91    "Use Case: Threat Detection",
 92    "Tactic: Defense Evasion",
 93    "Tactic: Execution",
 94    "Resources: Investigation Guide",
 95    "Data Source: Elastic Endgame",
 96    "Data Source: Elastic Defend"
 97]
 98timestamp_override = "event.ingested"
 99type = "eql"
100
101query = '''
102process where host.os.type == "windows" and event.type == "start" and
103  process.name : "MSBuild.exe" and
104  process.parent.name : ("eqnedt32.exe",
105                         "excel.exe",
106                         "fltldr.exe",
107                         "msaccess.exe",
108                         "mspub.exe",
109                         "outlook.exe",
110                         "powerpnt.exe",
111                         "winword.exe" )
112'''
113
114
115[[rule.threat]]
116framework = "MITRE ATT&CK"
117[[rule.threat.technique]]
118id = "T1127"
119name = "Trusted Developer Utilities Proxy Execution"
120reference = "https://attack.mitre.org/techniques/T1127/"
121[[rule.threat.technique.subtechnique]]
122id = "T1127.001"
123name = "MSBuild"
124reference = "https://attack.mitre.org/techniques/T1127/001/"
125
126
127
128[rule.threat.tactic]
129id = "TA0005"
130name = "Defense Evasion"
131reference = "https://attack.mitre.org/tactics/TA0005/"
132[[rule.threat]]
133framework = "MITRE ATT&CK"
134
135[rule.threat.tactic]
136id = "TA0002"
137name = "Execution"
138reference = "https://attack.mitre.org/tactics/TA0002/"

Triage and analysis

Investigating Microsoft Build Engine Started by an Office Application

Microsoft Office (MS Office) is a suite of applications designed to help with productivity and completing common tasks on a computer. You can create and edit documents containing text and images, work with data in spreadsheets and databases, and create presentations and posters. As it is some of the most-used software across companies, MS Office is frequently targeted for initial access. It also has a wide variety of capabilities that attackers can take advantage of.

The Microsoft Build Engine is a platform for building applications. This engine, also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software, and can be abused to proxy execution of code.

This rule looks for the Msbuild.exe utility spawned by MS Office programs. This is generally the result of the execution of malicious documents.

Possible investigation steps

  • Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
  • Investigate abnormal behaviors observed by the subject process, such as network connections, registry or file modifications, and any spawned child processes.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Retrieve MS Office documents received and opened by the user that could cause this behavior. Common locations include, but are not limited to, the Downloads and Document folders and the folder configured at the email client.
  • Determine if the collected files are malicious:
    • Use a private sandboxed malware analysis system to perform analysis.
      • Observe and collect information about the following activities:
        • Attempts to contact external domains and addresses.
        • File and registry access, modification, and creation activities.
        • Service creation and launch activities.
        • Scheduled task creation.
    • Use the PowerShell Get-FileHash cmdlet to get the files' SHA-256 hash values.
      • Search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.

False positive analysis

  • This activity is unlikely to happen legitimately. Benign true positives (B-TPs) can be added as exceptions if necessary.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Isolate the involved host to prevent further post-compromise behavior.
  • Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
  • If the triage identified malware, search the environment for additional compromised hosts.
    • Implement temporary network rules, procedures, and segmentation to contain the malware.
    • Stop suspicious processes.
    • Immediately block the identified indicators of compromise (IoCs).
    • Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
  • Remove and block malicious artifacts identified during triage.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
    • If the malicious file was delivered via phishing:
      • Block the email sender from sending future emails.
      • Block the malicious web pages.
      • Remove emails from the sender from mailboxes.
      • Consider improvements to the security awareness program.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

References

Related rules

to-top