Code Signing Policy Modification Through Registry
Identifies attempts to disable the code signing policy through the registry. Code signing provides authenticity on a program, and grants the user with the ability to check whether the program has been tampered with. By allowing the execution of unsigned or self-signed code, threat actors can craft and execute malicious code.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2023/01/31"
3integration = ["endpoint", "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[transform]
10[[transform.osquery]]
11label = "Osquery - Retrieve All Non-Microsoft Drivers with Virustotal Link"
12query = """
13SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, class, description, directory, image,
14issuer_name, manufacturer, service, signed, subject_name FROM drivers JOIN authenticode ON drivers.image =
15authenticode.path JOIN hash ON drivers.image = hash.path WHERE NOT (provider == "Microsoft" AND signed == "1")
16"""
17
18[[transform.osquery]]
19label = "Osquery - Retrieve All Unsigned Drivers with Virustotal Link"
20query = """
21SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, class, description, directory, image,
22issuer_name, manufacturer, service, signed, subject_name FROM drivers JOIN authenticode ON drivers.image =
23authenticode.path JOIN hash ON drivers.image = hash.path WHERE signed == "0"
24"""
25
26
27[rule]
28author = ["Elastic"]
29description = """
30Identifies attempts to disable the code signing policy through the registry. Code signing provides authenticity on a
31program, and grants the user with the ability to check whether the program has been tampered with. By allowing the
32execution of unsigned or self-signed code, threat actors can craft and execute malicious code.
33"""
34from = "now-9m"
35index = ["winlogbeat-*", "logs-endpoint.events.registry-*", "logs-windows.sysmon_operational-*", "endgame-*", "logs-m365_defender.event-*", "logs-sentinel_one_cloud_funnel.*"]
36language = "eql"
37license = "Elastic License v2"
38name = "Code Signing Policy Modification Through Registry"
39note = """## Triage and analysis
40
41### Investigating Code Signing Policy Modification Through Registry
42
43Microsoft created the Windows Driver Signature Enforcement (DSE) security feature to prevent drivers with invalid signatures from loading and executing into the kernel (ring 0). DSE aims to protect systems by blocking attackers from loading malicious drivers on targets.
44
45This protection is essential for maintaining system security. However, attackers or administrators can disable DSE and load untrusted drivers, which can put the system at risk. Therefore, it's important to keep this feature enabled and only load drivers from trusted sources to ensure system integrity and security.
46
47This rule identifies registry modifications that can disable DSE.
48
49> **Note**:
50> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/master/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
51
52#### Possible investigation steps
53
54- Identify the user account that performed the action and whether it should perform this kind of action.
55- 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.
56- Investigate other alerts associated with the user/host during the past 48 hours.
57- Use Osquery and endpoint driver events (`event.category = "driver"`) to investigate if suspicious drivers were loaded into the system after the registry was modified.
58 - $osquery_0
59 - $osquery_1
60- Identify the driver's `Device Name` and `Service Name`.
61- Check for alerts from the rules specified in the `Related Rules` section.
62
63### False positive analysis
64
65- 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.
66
67### Related Rules
68
69- First Time Seen Driver Loaded - df0fd41e-5590-4965-ad5e-cd079ec22fa9
70- Untrusted Driver Loaded - d8ab1ec1-feeb-48b9-89e7-c12e189448aa
71- Code Signing Policy Modification Through Built-in tools - b43570de-a908-4f7f-8bdb-b2df6ffd8c80
72
73### Response and remediation
74
75- Initiate the incident response process based on the outcome of the triage.
76- Isolate the involved host to prevent further post-compromise behavior.
77- Disable and uninstall all suspicious drivers found in the system. This can be done via Device Manager. (Note that this step may require you to boot the system into Safe Mode.)
78- Remove the related services and registry keys found in the system. Note that the service will probably not stop if the driver is still installed.
79 - This can be done via PowerShell `Remove-Service` cmdlet.
80- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
81- Remove and block malicious artifacts identified during triage.
82- Ensure that the Driver Signature Enforcement is enabled on the system.
83- 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.
84- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
85- 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).
86"""
87risk_score = 47
88rule_id = "da7733b1-fe08-487e-b536-0a04c6d8b0cd"
89severity = "medium"
90tags = [
91 "Domain: Endpoint",
92 "OS: Windows",
93 "Use Case: Threat Detection",
94 "Tactic: Defense Evasion",
95 "Data Source: Elastic Endgame",
96 "Resources: Investigation Guide",
97 "Data Source: Elastic Defend",
98 "Data Source: Sysmon",
99 "Data Source: Microsoft Defender for Endpoint",
100 "Data Source: SentinelOne",
101]
102timestamp_override = "event.ingested"
103type = "eql"
104
105query = '''
106registry where host.os.type == "windows" and event.type == "change" and
107 registry.value: "BehaviorOnFailedVerify" and registry.data.strings : ("0", "0x00000000", "1", "0x00000001")
108
109 /*
110 Full registry key path omitted due to data source variations:
111 "HKEY_USERS\\*\\Software\\Policies\\Microsoft\\Windows NT\\Driver Signing\\BehaviorOnFailedVerify"
112 */
113'''
114
115
116[[rule.threat]]
117framework = "MITRE ATT&CK"
118[[rule.threat.technique]]
119id = "T1112"
120name = "Modify Registry"
121reference = "https://attack.mitre.org/techniques/T1112/"
122
123[[rule.threat.technique]]
124id = "T1553"
125name = "Subvert Trust Controls"
126reference = "https://attack.mitre.org/techniques/T1553/"
127[[rule.threat.technique.subtechnique]]
128id = "T1553.006"
129name = "Code Signing Policy Modification"
130reference = "https://attack.mitre.org/techniques/T1553/006/"
131
132
133
134[rule.threat.tactic]
135id = "TA0005"
136name = "Defense Evasion"
137reference = "https://attack.mitre.org/tactics/TA0005/"
Triage and analysis
Investigating Code Signing Policy Modification Through Registry
Microsoft created the Windows Driver Signature Enforcement (DSE) security feature to prevent drivers with invalid signatures from loading and executing into the kernel (ring 0). DSE aims to protect systems by blocking attackers from loading malicious drivers on targets.
This protection is essential for maintaining system security. However, attackers or administrators can disable DSE and load untrusted drivers, which can put the system at risk. Therefore, it's important to keep this feature enabled and only load drivers from trusted sources to ensure system integrity and security.
This rule identifies registry modifications that can disable DSE.
Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
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.
- Use Osquery and endpoint driver events (
event.category = "driver"
) to investigate if suspicious drivers were loaded into the system after the registry was modified.- $osquery_0
- $osquery_1
- Identify the driver's
Device Name
andService Name
. - Check for alerts from the rules specified in the
Related Rules
section.
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.
Related Rules
- First Time Seen Driver Loaded - df0fd41e-5590-4965-ad5e-cd079ec22fa9
- Untrusted Driver Loaded - d8ab1ec1-feeb-48b9-89e7-c12e189448aa
- Code Signing Policy Modification Through Built-in tools - b43570de-a908-4f7f-8bdb-b2df6ffd8c80
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.
- Disable and uninstall all suspicious drivers found in the system. This can be done via Device Manager. (Note that this step may require you to boot the system into Safe Mode.)
- Remove the related services and registry keys found in the system. Note that the service will probably not stop if the driver is still installed.
- This can be done via PowerShell
Remove-Service
cmdlet.
- This can be done via PowerShell
- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
- Remove and block malicious artifacts identified during triage.
- Ensure that the Driver Signature Enforcement is enabled on the system.
- 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.
- 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
- Conhost Spawned By Suspicious Parent Process
- Creation or Modification of Root Certificate
- Execution from Unusual Directory - Command Line
- Microsoft Windows Defender Tampering
- Modification of AmsiEnable Registry Key