Detection rules › Elastic

Potential Privilege Escalation via Missing DLL

Source
github.com/elastic/protections-artifacts

Identifies the loading of a non Microsoft signed DLL that is missing on a default Windows installation (phantom DLL) or one that can be loaded from a different location by a native Windows process. This may be abused to persist or elevate privileges via privileged file write vulnerabilities.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the loading of a non Microsoft signed DLL that is missing on a default Windows installation (phantom DLL) or
one that can be loaded from a different location by a native Windows process. This may be abused to persist or elevate
privileges via privileged file write vulnerabilities.
"""
id = "a2a3d803-5c25-43cc-84b9-a4ae2a4dab27"
license = "Elastic License v2"
name = "Potential Privilege Escalation via Missing DLL"
os_list = ["windows"]
reference = [
    "http://remoteawesomethoughts.blogspot.com/2019/05/windows-10-task-schedulerservice.html",
    "http://waleedassar.blogspot.com/2013/01/wow64logdll.html",
    "https://github.com/rapid7/metasploit-framework/blob/5863ff7e357af1634f5b370e811d647a9c999158/modules/exploits/windows/local/cve_2020_17136.rb#L192",
    "https://googleprojectzero.blogspot.com/2018/04/windows-exploitation-tricks-exploiting.html",
    "https://itm4n.github.io/windows-dll-hijacking-clarified/",
    "https://shellz.club/edgegdi-dll-for-persistence-and-lateral-movement/",
    "https://windows-internals.com/faxing-your-way-to-system/",
    "https://www.elastic.co/security-labs/Hunting-for-Suspicious-Windows-Libraries-for-Execution-and-Evasion",
    "https://www.elastic.co/security-labs/invisible-miners-unveiling-ghostengine",
]
version = "1.0.41"

query = '''
library where
   user.id : "S-1-5-18" and (dll.code_signature.trusted == false or dll.code_signature.exists == false) and 
   (dll.Ext.relative_file_creation_time <= 172800 or dll.Ext.relative_file_name_modify_time <= 172800) and 
     (
       dll.name :
         ("wlbsctrl.dll",
          "WptsExtensions.dll",
          "Tsmsisrv.dll",
          "TSVIPSrv.dll",
          "Msfte.dll",
          "wow64log.dll",
          "WindowsCoreDeviceInfo.dll",
          "phoneinfo.dll",
          "EdgeGdi.dll",
          "cdpsgshims.dll",
          "diagtrack_win.dll",
          "wlanhlp.dll",
          "healthapi.dll",
          "prntvpt.dll",
          "SprintCSP.dll") or
       dll.path : ("?:\\Windows\\System32\\Ualapi.dll",
                   "?:\\Windows\\SysWOW64\\Ualapi.dll",
                   "?:\\Windows\\System\\Ualapi.dll",
                   "?:\\Windows\\Ualapi.dll",
                   "?:\\Windows\\System32\\oci.dll",
                   "?:\\Windows\\System32\\spool\\drivers\\x64\\PrintConfig.dll",
                   "?:\\windows\\Ualapi.dll",
                   "?:\\windows\\wbemcomn.dll",
                   "?:\\Windows\\oci.dll",
                   "?:\\windows\\System32\\Wbem\\Ualapi.dll",
                   "?:\\windows\\System32\\WindowsPowerShell\\v1.0\\wbemcomn.dll",
                   "?:\\windows\\System32\\WindowsPowerShell\\v1.0\\Ualapi.dll",
                   "?:\\windows\\System32\\WindowsPowerShell\\v1.0\\oci.dll",
                   "?:\\Python??\\wbemcomn.dll",
                   "?:\\Python??\\Ualapi.dll",
                   "?:\\Python??\\oci.dll",
                   "?:\\windows\\System32\\OpenSSH\\wbemcomn.dll",
                   "?:\\windows\\System32\\OpenSSH\\oci.dll",
                   "?:\\windows\\System32\\OpenSSH\\Ualapi.dll", 
                   "?:\\Windows\\System32\\wbem\\wbemcomn.dll", 
                   "?:\\Windows\\SysWOW64\\wbem\\wbemcomn.dll")
     ) and
     not dll.path : 
               ("?:\\Windows\\System32\\prntvpt.dll", 
                "?:\\Windows\\System32\\wlanhlp.dll", 
                "?:\\Windows\\SysWOW64\\prntvpt.dll", 
                "?:\\Windows\\WinSxS\\*.dll") and 
     not (dll.pe.imphash : "a9ab204cf2b4a1903b3fba3c920bd357" and dll.name : "Ualapi.dll")
'''

min_endpoint_version = "8.4.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1574"
name = "Hijack Execution Flow"
reference = "https://attack.mitre.org/techniques/T1574/"
[[threat.technique.subtechnique]]
id = "T1574.001"
name = "DLL"
reference = "https://attack.mitre.org/techniques/T1574/001/"



[threat.tactic]
id = "TA0004"
name = "Privilege Escalation"
reference = "https://attack.mitre.org/tactics/TA0004/"

[internal]
min_endpoint_version = "8.4.0"

Stages and Predicates

Stage 1: library

library where
   user.id : "S-1-5-18" and (dll.code_signature.trusted == false or dll.code_signature.exists == false) and 
   (dll.Ext.relative_file_creation_time <= 172800 or dll.Ext.relative_file_name_modify_time <= 172800) and 
     (
       dll.name :
         ("wlbsctrl.dll",
          "WptsExtensions.dll",
          "Tsmsisrv.dll",
          "TSVIPSrv.dll",
          "Msfte.dll",
          "wow64log.dll",
          "WindowsCoreDeviceInfo.dll",
          "phoneinfo.dll",
          "EdgeGdi.dll",
          "cdpsgshims.dll",
          "diagtrack_win.dll",
          "wlanhlp.dll",
          "healthapi.dll",
          "prntvpt.dll",
          "SprintCSP.dll") or
       dll.path : ("?:\\Windows\\System32\\Ualapi.dll",
                   "?:\\Windows\\SysWOW64\\Ualapi.dll",
                   "?:\\Windows\\System\\Ualapi.dll",
                   "?:\\Windows\\Ualapi.dll",
                   "?:\\Windows\\System32\\oci.dll",
                   "?:\\Windows\\System32\\spool\\drivers\\x64\\PrintConfig.dll",
                   "?:\\windows\\Ualapi.dll",
                   "?:\\windows\\wbemcomn.dll",
                   "?:\\Windows\\oci.dll",
                   "?:\\windows\\System32\\Wbem\\Ualapi.dll",
                   "?:\\windows\\System32\\WindowsPowerShell\\v1.0\\wbemcomn.dll",
                   "?:\\windows\\System32\\WindowsPowerShell\\v1.0\\Ualapi.dll",
                   "?:\\windows\\System32\\WindowsPowerShell\\v1.0\\oci.dll",
                   "?:\\Python??\\wbemcomn.dll",
                   "?:\\Python??\\Ualapi.dll",
                   "?:\\Python??\\oci.dll",
                   "?:\\windows\\System32\\OpenSSH\\wbemcomn.dll",
                   "?:\\windows\\System32\\OpenSSH\\oci.dll",
                   "?:\\windows\\System32\\OpenSSH\\Ualapi.dll", 
                   "?:\\Windows\\System32\\wbem\\wbemcomn.dll", 
                   "?:\\Windows\\SysWOW64\\wbem\\wbemcomn.dll")
     ) and
     not dll.path : 
               ("?:\\Windows\\System32\\prntvpt.dll", 
                "?:\\Windows\\System32\\wlanhlp.dll", 
                "?:\\Windows\\SysWOW64\\prntvpt.dll", 
                "?:\\Windows\\WinSxS\\*.dll") and 
     not (dll.pe.imphash : "a9ab204cf2b4a1903b3fba3c920bd357" and dll.name : "Ualapi.dll")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
dll.nameeqUalapi.dllexcludes:dll.name field:"dll.name" value:"Ualapi.dll"
dll.pe.imphasheqa9ab204cf2b4a1903b3fba3c920bd357excludes:dll.pe.imphash field:"dll.pe.imphash" value:"a9ab204cf2b4a1903b3fba3c920bd357"
dll.pathwildcard?:\Windows\System32\prntvpt.dll, ?:\Windows\System32\wlanhlp.dll, ?:\Windows\SysWOW64\prntvpt.dll, ?:\Windows\WinSxS\*.dllexcludes:dll.path

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
dll.Ext.relative_file_creation_timele
  • 172800 transforms: number
field:"dll.Ext.relative_file_creation_time" kind:le value:"172800"
dll.Ext.relative_file_name_modify_timele
  • 172800 transforms: number
field:"dll.Ext.relative_file_name_modify_time" kind:le value:"172800"
dll.code_signature.existseq
  • false transforms: boolean corpus 22 (elastic 22)
field:"dll.code_signature.exists" kind:eq value:"false"
dll.code_signature.trustedeq
  • false transforms: boolean corpus 21 (elastic 21)
field:"dll.code_signature.trusted" kind:eq value:"false"
dll.namewildcard
  • EdgeGdi.dll corpus 2 (elastic 2)
  • Msfte.dll corpus 2 (elastic 2)
  • SprintCSP.dll
  • TSVIPSrv.dll corpus 2 (elastic 2)
  • Tsmsisrv.dll corpus 2 (elastic 2)
  • WindowsCoreDeviceInfo.dll corpus 2 (elastic 2)
  • WptsExtensions.dll corpus 2 (elastic 2)
  • cdpsgshims.dll corpus 2 (elastic 2)
  • diagtrack_win.dll corpus 2 (elastic 2)
  • healthapi.dll
  • phoneinfo.dll corpus 2 (elastic 2)
  • prntvpt.dll corpus 2 (elastic 2)
  • wlanhlp.dll corpus 3 (elastic 3)
  • wlbsctrl.dll corpus 2 (elastic 2)
  • wow64log.dll corpus 3 (elastic 3)
field:"dll.name" kind:wildcard
dll.pathwildcard
  • ?:\Python??\Ualapi.dll
  • ?:\Python??\oci.dll
  • ?:\Python??\wbemcomn.dll
  • ?:\Windows\SysWOW64\Ualapi.dll
  • ?:\Windows\SysWOW64\wbem\wbemcomn.dll
  • ?:\Windows\System32\Ualapi.dll
  • ?:\Windows\System32\oci.dll
  • ?:\Windows\System32\spool\drivers\x64\PrintConfig.dll
  • ?:\Windows\System32\wbem\wbemcomn.dll
  • ?:\Windows\System\Ualapi.dll
  • ?:\Windows\Ualapi.dll
  • ?:\Windows\oci.dll
  • ?:\windows\System32\OpenSSH\Ualapi.dll
  • ?:\windows\System32\OpenSSH\oci.dll
  • ?:\windows\System32\OpenSSH\wbemcomn.dll
  • ?:\windows\System32\Wbem\Ualapi.dll
  • ?:\windows\System32\WindowsPowerShell\v1.0\Ualapi.dll
  • ?:\windows\System32\WindowsPowerShell\v1.0\oci.dll
  • ?:\windows\System32\WindowsPowerShell\v1.0\wbemcomn.dll
  • ?:\windows\Ualapi.dll
  • ?:\windows\wbemcomn.dll
field:"ImageLoaded" kind:wildcard
user.idwildcard
  • S-1-5-18 corpus 13 (elastic 13)
field:"user.id" kind:wildcard value:"S-1-5-18"