MS Office Macro Security Registry Modifications

Microsoft Office Products offer options for users and developers to control the security settings for running and using Macros. Adversaries may abuse these security settings to modify the default behavior of the Office Application to trust future macros and/or disable security warnings, which could increase their chances of establishing persistence.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2022/01/12"
  3integration = ["windows", "m365_defender", "sentinel_one_cloud_funnel"]
  4maturity = "production"
  5updated_date = "2024/10/15"
  6min_stack_version = "8.14.0"
  7min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Microsoft Office Products offer options for users and developers to control the security settings for running and using
 13Macros. Adversaries may abuse these security settings to modify the default behavior of the Office Application to trust
 14future macros and/or disable security warnings, which could increase their chances of establishing persistence.
 15"""
 16from = "now-9m"
 17index = ["winlogbeat-*", "logs-windows.sysmon_operational-*", "endgame-*", "logs-m365_defender.event-*", "logs-sentinel_one_cloud_funnel.*"]
 18language = "eql"
 19license = "Elastic License v2"
 20name = "MS Office Macro Security Registry Modifications"
 21note = """## Triage and analysis
 22
 23### Investigating MS Office Macro Security Registry Modifications
 24
 25Macros are small programs that are used to automate repetitive tasks in Microsoft Office applications. Historically, macros have been used for a variety of reasons -- from automating part of a job, to building entire processes and data flows. Macros are written in Visual Basic for Applications (VBA) and are saved as part of Microsoft Office files.
 26
 27Macros are often created for legitimate reasons, but they can also be written by attackers to gain access, harm a system, or bypass other security controls such as application allow listing. In fact, exploitation from malicious macros is one of the top ways that organizations are compromised today. These attacks are often conducted through phishing or spear phishing campaigns.
 28
 29Attackers can convince victims to modify Microsoft Office security settings, so their macros are trusted by default and no warnings are displayed when they are executed. These settings include:
 30
 31- *Trust access to the VBA project object model* - When enabled, Microsoft Office will trust all macros and run any code without showing a security warning or requiring user permission.
 32- *VbaWarnings* - When set to 1, Microsoft Office will trust all macros and run any code without showing a security warning or requiring user permission.
 33
 34This rule looks for registry changes affecting the conditions above.
 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- Identify the user account that performed the action and whether it should perform this kind of action.
 40- Contact the user and check if the change was done manually.
 41- Verify whether malicious macros were executed after the registry change.
 42- Investigate other alerts associated with the user/host during the past 48 hours.
 43- Retrieve recently executed Office documents and determine if they are malicious:
 44  - Use a private sandboxed malware analysis system to perform analysis.
 45    - Observe and collect information about the following activities:
 46      - Attempts to contact external domains and addresses.
 47      - File and registry access, modification, and creation activities.
 48      - Service creation and launch activities.
 49      - Scheduled task creation.
 50  - Use the PowerShell Get-FileHash cmdlet to get the files' SHA-256 hash values.
 51    - Search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
 52
 53### False positive analysis
 54
 55- This activity should not happen legitimately. The security team should address any potential benign true positive (B-TP), as this configuration can put the user and the domain at risk.
 56
 57### Response and remediation
 58
 59- Initiate the incident response process based on the outcome of the triage.
 60- Reset the registry key value.
 61- Isolate the involved host to prevent further post-compromise behavior.
 62- 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.
 63- Explore using GPOs to manage security settings for Microsoft Office macros.
 64- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 65- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 66- 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).
 67"""
 68risk_score = 47
 69rule_id = "feeed87c-5e95-4339-aef1-47fd79bcfbe3"
 70severity = "medium"
 71tags = [
 72    "Domain: Endpoint",
 73    "OS: Windows",
 74    "Use Case: Threat Detection",
 75    "Tactic: Defense Evasion",
 76    "Resources: Investigation Guide",
 77    "Data Source: Elastic Endgame",
 78    "Data Source: Sysmon",
 79    "Data Source: Microsoft Defender for Endpoint",
 80    "Data Source: SentinelOne",
 81]
 82timestamp_override = "event.ingested"
 83type = "eql"
 84
 85query = '''
 86registry where host.os.type == "windows" and event.type == "change" and registry.value : ("AccessVBOM", "VbaWarnings") and
 87    registry.path : (
 88        /* Sysmon */
 89        "HKU\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
 90        "HKU\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings",
 91        "HKU\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
 92        "HKU\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings",
 93        /* MDE */
 94        "HKCU\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
 95        "HKCU\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings",
 96        "HKCU\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
 97        "HKCU\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings",
 98        /* Endgame */
 99        "\\REGISTRY\\USER\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
100        "\\REGISTRY\\USER\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings",
101        "\\REGISTRY\\USER\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
102        "\\REGISTRY\\USER\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings",
103        /* SentinelOne */
104        "USER\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
105        "USER\\S-1-5-21-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings",
106        "USER\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\AccessVBOM",
107        "USER\\S-1-12-1-*\\SOFTWARE\\Microsoft\\Office\\*\\Security\\VbaWarnings"
108        ) and
109    registry.data.strings : ("0x00000001", "1")
110'''
111
112
113[[rule.threat]]
114framework = "MITRE ATT&CK"
115[[rule.threat.technique]]
116id = "T1112"
117name = "Modify Registry"
118reference = "https://attack.mitre.org/techniques/T1112/"
119
120
121[rule.threat.tactic]
122id = "TA0005"
123name = "Defense Evasion"
124reference = "https://attack.mitre.org/tactics/TA0005/"
125[[rule.threat]]
126framework = "MITRE ATT&CK"
127[[rule.threat.technique]]
128id = "T1204"
129name = "User Execution"
130reference = "https://attack.mitre.org/techniques/T1204/"
131[[rule.threat.technique.subtechnique]]
132id = "T1204.002"
133name = "Malicious File"
134reference = "https://attack.mitre.org/techniques/T1204/002/"
135
136
137
138[rule.threat.tactic]
139id = "TA0002"
140name = "Execution"
141reference = "https://attack.mitre.org/tactics/TA0002/"

Triage and analysis

Investigating MS Office Macro Security Registry Modifications

Macros are small programs that are used to automate repetitive tasks in Microsoft Office applications. Historically, macros have been used for a variety of reasons -- from automating part of a job, to building entire processes and data flows. Macros are written in Visual Basic for Applications (VBA) and are saved as part of Microsoft Office files.

Macros are often created for legitimate reasons, but they can also be written by attackers to gain access, harm a system, or bypass other security controls such as application allow listing. In fact, exploitation from malicious macros is one of the top ways that organizations are compromised today. These attacks are often conducted through phishing or spear phishing campaigns.

Attackers can convince victims to modify Microsoft Office security settings, so their macros are trusted by default and no warnings are displayed when they are executed. These settings include:

  • Trust access to the VBA project object model - When enabled, Microsoft Office will trust all macros and run any code without showing a security warning or requiring user permission.
  • VbaWarnings - When set to 1, Microsoft Office will trust all macros and run any code without showing a security warning or requiring user permission.

This rule looks for registry changes affecting the conditions above.

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.
  • Identify the user account that performed the action and whether it should perform this kind of action.
  • Contact the user and check if the change was done manually.
  • Verify whether malicious macros were executed after the registry change.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Retrieve recently executed Office documents and determine if they 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 should not happen legitimately. The security team should address any potential benign true positive (B-TP), as this configuration can put the user and the domain at risk.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Reset the registry key value.
  • 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.
  • Explore using GPOs to manage security settings for Microsoft Office macros.
  • 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.
  • 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).

Related rules

to-top