Modification of AmsiEnable Registry Key

Identifies modifications of the AmsiEnable registry key to 0, which disables the Antimalware Scan Interface (AMSI). An adversary can modify this key to disable AMSI protections.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2021/06/01"
  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 = """
 12Identifies modifications of the AmsiEnable registry key to 0, which disables the Antimalware Scan Interface (AMSI). An
 13adversary can modify this key to disable AMSI protections.
 14"""
 15from = "now-9m"
 16index = ["winlogbeat-*", "logs-endpoint.events.registry-*", "logs-windows.sysmon_operational-*", "endgame-*"]
 17language = "eql"
 18license = "Elastic License v2"
 19name = "Modification of AmsiEnable Registry Key"
 20note = """## Triage and analysis
 21
 22### Investigating Modification of AmsiEnable Registry Key
 23
 24The Windows Antimalware Scan Interface (AMSI) is a versatile interface standard that allows your applications and services to integrate with any antimalware product on a machine. AMSI integrates with multiple Windows components, ranging from User Account Control (UAC) to VBA macros and PowerShell.
 25
 26Since AMSI is widely used across security products for increased visibility, attackers can disable it to evade detections that rely on it.
 27
 28This rule monitors the modifications to the Software\\Microsoft\\Windows Script\\Settings\\AmsiEnable registry key.
 29
 30#### Possible investigation steps
 31
 32- Identify the user account that performed the action and whether it should perform this kind of action.
 33- 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.
 34- Investigate other alerts associated with the user/host during the past 48 hours.
 35- Investigate the execution of scripts and macros after the registry modification.
 36- Retrieve scripts or Microsoft Office files and determine if they are malicious:
 37  - Use a private sandboxed malware analysis system to perform analysis.
 38    - Observe and collect information about the following activities:
 39      - Attempts to contact external domains and addresses.
 40      - File and registry access, modification, and creation activities.
 41      - Service creation and launch activities.
 42      - Scheduled task creation.
 43  - Use the PowerShell Get-FileHash cmdlet to get the files' SHA-256 hash values.
 44    - Search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
 45- Use process name, command line, and file hash to search for occurrences on other hosts.
 46
 47### False positive analysis
 48
 49- This modification should not happen legitimately. Any potential benign true positive (B-TP) should be mapped and monitored by the security team as these modifications expose the host to malware infections.
 50
 51### Related rules
 52
 53- Microsoft Windows Defender Tampering - fe794edd-487f-4a90-b285-3ee54f2af2d3
 54
 55### Response and remediation
 56
 57- Initiate the incident response process based on the outcome of the triage.
 58- Isolate the involved hosts to prevent further post-compromise behavior.
 59- If the triage identified malware, search the environment for additional compromised hosts.
 60  - Implement temporary network rules, procedures, and segmentation to contain the malware.
 61  - Stop suspicious processes.
 62  - Immediately block the identified indicators of compromise (IoCs).
 63  - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
 64- Remove and block malicious artifacts identified during triage.
 65- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 66- Delete or set the key to its default value.
 67- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 68- 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).
 69"""
 70references = [
 71    "https://hackinparis.com/data/slides/2019/talks/HIP2019-Dominic_Chell-Cracking_The_Perimeter_With_Sharpshooter.pdf",
 72    "https://docs.microsoft.com/en-us/windows/win32/amsi/antimalware-scan-interface-portal",
 73]
 74risk_score = 73
 75rule_id = "f874315d-5188-4b4a-8521-d1c73093a7e4"
 76setup = """## Setup
 77
 78If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2,
 79events will not define `event.ingested` and default fallback for EQL rules was not added until version 8.2.
 80Hence for this rule to work effectively, users will need to add a custom ingest pipeline to populate
 81`event.ingested` to @timestamp.
 82For more details on adding a custom ingest pipeline refer - https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html
 83"""
 84severity = "high"
 85tags = [
 86    "Domain: Endpoint",
 87    "OS: Windows",
 88    "Use Case: Threat Detection",
 89    "Tactic: Defense Evasion",
 90    "Resources: Investigation Guide",
 91    "Data Source: Elastic Endgame",
 92    "Data Source: Elastic Defend",
 93    "Data Source: Sysmon"
 94]
 95timestamp_override = "event.ingested"
 96type = "eql"
 97
 98query = '''
 99registry where host.os.type == "windows" and event.type in ("creation", "change") and
100  registry.path : (
101    "HKEY_USERS\\*\\Software\\Microsoft\\Windows Script\\Settings\\AmsiEnable",
102    "HKU\\*\\Software\\Microsoft\\Windows Script\\Settings\\AmsiEnable",
103    "\\REGISTRY\\USER\\*\\Software\\Microsoft\\Windows Script\\Settings\\AmsiEnable"
104  ) and
105  registry.data.strings: ("0", "0x00000000")
106'''
107
108
109[[rule.threat]]
110framework = "MITRE ATT&CK"
111[[rule.threat.technique]]
112id = "T1562"
113name = "Impair Defenses"
114reference = "https://attack.mitre.org/techniques/T1562/"
115[[rule.threat.technique.subtechnique]]
116id = "T1562.001"
117name = "Disable or Modify Tools"
118reference = "https://attack.mitre.org/techniques/T1562/001/"
119
120[[rule.threat.technique]]
121id = "T1112"
122name = "Modify Registry"
123reference = "https://attack.mitre.org/techniques/T1112/"
124
125
126[rule.threat.tactic]
127id = "TA0005"
128name = "Defense Evasion"
129reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and analysis

Investigating Modification of AmsiEnable Registry Key

The Windows Antimalware Scan Interface (AMSI) is a versatile interface standard that allows your applications and services to integrate with any antimalware product on a machine. AMSI integrates with multiple Windows components, ranging from User Account Control (UAC) to VBA macros and PowerShell.

Since AMSI is widely used across security products for increased visibility, attackers can disable it to evade detections that rely on it.

This rule monitors the modifications to the Software\Microsoft\Windows Script\Settings\AmsiEnable registry key.

Possible investigation steps

  • Identify the user account that performed the action and whether it should perform this kind of action.
  • 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 other alerts associated with the user/host during the past 48 hours.
  • Investigate the execution of scripts and macros after the registry modification.
  • Retrieve scripts or Microsoft Office files 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.
  • Use process name, command line, and file hash to search for occurrences on other hosts.

False positive analysis

  • This modification should not happen legitimately. Any potential benign true positive (B-TP) should be mapped and monitored by the security team as these modifications expose the host to malware infections.
  • Microsoft Windows Defender Tampering - fe794edd-487f-4a90-b285-3ee54f2af2d3

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Isolate the involved hosts to prevent further post-compromise behavior.
  • 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.
  • Delete or set the key to its default value.
  • 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).

References

Related rules

to-top