Untrusted Driver Loaded

Identifies attempt to load an untrusted driver. Adversaries may modify code signing policies to enable execution of unsigned or self-signed code.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2023/01/27"
  3integration = ["endpoint"]
  4maturity = "production"
  5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
  6min_stack_version = "8.3.0"
  7updated_date = "2024/04/15"
  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, issuer_name, manufacturer, service, signed, subject_name FROM drivers JOIN authenticode ON drivers.image = authenticode.path JOIN hash ON drivers.image = hash.path WHERE NOT (provider == "Microsoft" AND signed == "1")
 14"""
 15
 16[[transform.osquery]]
 17label = "Osquery - Retrieve All Unsigned Drivers with Virustotal Link"
 18query = """
 19SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, class, description, directory, image, issuer_name, manufacturer, service, signed, subject_name FROM drivers JOIN authenticode ON drivers.image = authenticode.path JOIN hash ON drivers.image = hash.path WHERE signed == "0"
 20"""
 21
 22[rule]
 23author = ["Elastic"]
 24description = """
 25Identifies attempt to load an untrusted driver. Adversaries may modify code signing policies to enable execution of unsigned or self-signed code.
 26"""
 27from = "now-9m"
 28index = ["logs-endpoint.events.library-*"]
 29language = "eql"
 30license = "Elastic License v2"
 31name = "Untrusted Driver Loaded"
 32note = """## Triage and analysis
 33
 34### Investigating Untrusted Driver Loaded
 35
 36Microsoft 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. 
 37
 38This 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.
 39
 40This rule identifies an attempt to load an untrusted driver, which effectively means that DSE was disabled or bypassed. This can indicate that the system was compromised.
 41
 42> **Note**:
 43> 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.
 44
 45#### Possible investigation steps
 46
 47- Examine the driver loaded to identify potentially suspicious characteristics. The following actions can help you gain context:
 48  - Identify the path that the driver was loaded from. If you're using Elastic Defend, path information can be found in the `dll.path` field.
 49  - Examine the file creation and modification timestamps:
 50    - On Elastic Defend, those can be found in the `dll.Ext.relative_file_creation_time` and `dll.Ext.relative_file_name_modify_time` fields. The values are in seconds.
 51    - Search for file creation events sharing the same file name as the `dll.name` field and identify the process responsible for the operation.
 52      - Investigate any other abnormal behavior by the subject process, such as network connections, registry or file modifications, and any spawned child processes.
 53  - Use the driver SHA-256 (`dll.hash.sha256` field) hash value to search for the existence and reputation in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
 54- Investigate other alerts associated with the user/host during the past 48 hours.
 55- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
 56- Use Osquery to investigate the drivers loaded into the system.
 57  - $osquery_0
 58  - $osquery_1
 59- Identify the driver's `Device Name` and `Service Name`.
 60- Check for alerts from the rules specified in the `Related Rules` section.
 61
 62### False positive analysis
 63
 64- 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.
 65
 66### Related Rules
 67
 68- First Time Seen Driver Loaded - df0fd41e-5590-4965-ad5e-cd079ec22fa9
 69- Code Signing Policy Modification Through Registry - da7733b1-fe08-487e-b536-0a04c6d8b0cd
 70- Code Signing Policy Modification Through Built-in tools - b43570de-a908-4f7f-8bdb-b2df6ffd8c80
 71
 72### Response and remediation
 73
 74- Initiate the incident response process based on the outcome of the triage.
 75- Isolate the involved host to prevent further post-compromise behavior.
 76- 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.)
 77- 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.
 78  - This can be done via PowerShell `Remove-Service` cmdlet.
 79- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 80- If the triage identified malware, search the environment for additional compromised hosts.
 81  - Implement temporary network rules, procedures, and segmentation to contain the malware.
 82  - Stop suspicious processes.
 83  - Immediately block the identified indicators of compromise (IoCs).
 84  - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
 85- Remove and block malicious artifacts identified during triage.
 86- Ensure that the Driver Signature Enforcement is enabled on the system.
 87- 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.
 88- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 89- 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).
 90"""
 91references = [
 92  "https://github.com/hfiref0x/TDL",
 93  "https://docs.microsoft.com/en-us/previous-versions/windows/hardware/design/dn653559(v=vs.85)?redirectedfrom=MSDN"
 94]
 95risk_score = 73
 96rule_id = "d8ab1ec1-feeb-48b9-89e7-c12e189448aa"
 97severity = "high"
 98tags = ["Domain: Endpoint", "OS: Windows", "Use Case: Threat Detection", "Tactic: Defense Evasion", "Resources: Investigation Guide", "Data Source: Elastic Defend"]
 99timestamp_override = "event.ingested"
100type = "eql"
101
102query = '''
103driver where host.os.type == "windows" and process.pid == 4 and
104  dll.code_signature.trusted != true and 
105  not dll.code_signature.status : ("errorExpired", "errorRevoked", "errorCode_endpoint:*")
106'''
107
108
109[[rule.threat]]
110framework = "MITRE ATT&CK"
111[[rule.threat.technique]]
112id = "T1036"
113name = "Masquerading"
114reference = "https://attack.mitre.org/techniques/T1036/"
115
116[[rule.threat.technique.subtechnique]]
117id = "T1036.001"
118name = "Invalid Code Signature"
119reference = "https://attack.mitre.org/techniques/T1036/001/"
120
121[rule.threat.tactic]
122id = "TA0005"
123name = "Defense Evasion"
124reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and analysis

Investigating Untrusted Driver Loaded

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 an attempt to load an untrusted driver, which effectively means that DSE was disabled or bypassed. This can indicate that the system was compromised.

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

  • Examine the driver loaded to identify potentially suspicious characteristics. The following actions can help you gain context:
    • Identify the path that the driver was loaded from. If you're using Elastic Defend, path information can be found in the dll.path field.
    • Examine the file creation and modification timestamps:
      • On Elastic Defend, those can be found in the dll.Ext.relative_file_creation_time and dll.Ext.relative_file_name_modify_time fields. The values are in seconds.
      • Search for file creation events sharing the same file name as the dll.name field and identify the process responsible for the operation.
        • Investigate any other abnormal behavior by the subject process, such as network connections, registry or file modifications, and any spawned child processes.
    • Use the driver SHA-256 (dll.hash.sha256 field) hash value to search for the existence and reputation in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
  • Use Osquery to investigate the drivers loaded into the system.
    • $osquery_0
    • $osquery_1
  • Identify the driver's Device Name and Service 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.
  • First Time Seen Driver Loaded - df0fd41e-5590-4965-ad5e-cd079ec22fa9
  • Code Signing Policy Modification Through Registry - da7733b1-fe08-487e-b536-0a04c6d8b0cd
  • 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.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • 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.
  • 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).

References

Related rules

to-top