Detection rules › Elastic

Potential Evasion via Invalid Code Signature

Source
github.com/elastic/protections-artifacts

Identifies an attempt to load a network module from unbacked memory or perform suspicious Windows API calls by an executable with erroneous code signature. Malware may append malicious code to benign signed binaries or use invalid code signature to bypass certain security controls.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies an attempt to load a network module from unbacked memory or perform suspicious Windows API calls by an
executable with erroneous code signature. Malware may append malicious code to benign signed binaries or use invalid
code signature to bypass certain security controls.
"""
id = "f3f769b9-0695-49ed-ab6e-c8f199a7d2c8"
license = "Elastic License v2"
name = "Potential Evasion via Invalid Code Signature"
os_list = ["windows"]
reference = ["https://www.elastic.co/security-labs/doubling-down-etw-callstacks"]
version = "1.0.20"

query = '''
any where
 process.executable != null and process.code_signature.status == "errorBadDigest" and   
 (
  (event.category == "api" and event.category == "intrusion_detection" and 
   process.Ext.api.behaviors in ("shellcode", "allocate_shellcode", "execute_shellcode") and
   not process.Ext.api.name in ("SetWindowsHookEx", "IoCreateDevice") and
   process.thread.Ext.call_stack_final_user_module.name != null and
   not process.thread.Ext.call_stack_final_user_module.name in ("Kernel", "Unknown", "Undetermined") and
   not process.thread.Ext.call_stack_final_user_module.protection_provenance like ("Kernel", "Kernel|*")) or

  (event.category == "library" and dll.name in~ ("ws2_32.dll", "wininet.dll", "winhttp.dll") and
   process.thread.Ext.call_stack_summary like
            ("*kernelbase.dll|Unbacked*", "*ntdll.dll|Unbacked*", "*wininet.dll|Unbacked*",
             "*dnsapi.dll|Unbacked*", "*ws2_32.dll|Unbacked*", "*iphlpapi.dll|Unbacked*",
             "*winhttp.dll|Unbacked*", "Unbacked|*"))
 ) and
 not process.executable : ("?:\\Program Files\\*", "?:\\Program Files (x86)\\*") and 
 not (process.executable : "D:\\d3\\view\\viewapp.exe" and process.code_signature.subject_name == "d.velop AG") and
 not (process.executable : "D:\\*\\AuditExplorer.exe" and process.code_signature.subject_name == "Eclipse.org Foundation, Inc.") and
 not (dll.name == "ws2_32.dll" and process.code_signature.subject_name in ("Azul Systems, Inc.", "Ghisler Software GmbH", "Cellebrite DI LTD", "Pagebites, Inc.")) and
 not (process.Ext.api.name in ("NtQueueApcThread", "OpenProcess", "ResumeThread") and process.code_signature.subject_name in ("Azul Systems, Inc.", "Eclipse.org Foundation, Inc.")) and
 not (process.executable : "C:\\AutoVue_Client\\jre\\bin\\javaw.exe" and process.code_signature.subject_name == "Oracle America, Inc.") and
 not (process.executable : ("?:\\Users\\*\\AppData\\Local\\Turbo.net\\Sandbox\\GEARView\\*\\GEARViewBasic.exe",
                             "\\\\?\\Volume{*}\\VMS_PortableClient_x64\\local\\stubexe\\*\\VMS_Client.exe") and
      process.code_signature.subject_name == "Code Systems Corporation") and
 not process.executable : 
             ("?:\\Users\\*\\AppData\\Local\\Microsoft\\Teams\\current\\Teams.exe", 
              "?:\\Program Files (x86)\\Teams Installer\\Teams.exe", 
              "?:\\Program Files\\Microsoft Mouse and Keyboard Center\\CEIP.exe", 
              "?:\\Program Files (x86)\\Microsoft Mouse and Keyboard Center\\CEIP.exe",
              "C:\\Informatica\\10.5.1\\clients\\DeveloperClient\\developerCore.exe",
              "C:\\Users\\*\\AppData\\Roaming\\Spotify\\Spotify.exe") and
 not (process.executable : "D:\\SteamLibrary\\steamapps\\common\\*" and
      process.parent.executable : "C:\\Program Files (x86)\\Steam\\steam.exe") and
 not _arraysearch(process.thread.Ext.call_stack, $entry,
                     $entry.symbol_info : ("?:\\Program Files\\*.dll*",
                                           "?:\\Program Files (x86)\\*.dll*",
                                           "?:\\windows\\system32\\*\\tmmon*.dll*",
                                           "?:\\Windows\\SysWOW64\\esensordbi.dll*",
                                           "?:\\Windows\\System32\\esensordbi.dll*",
                                           "?:\\Windows\\System32\\umppc*.dll*",
                                           "?:\\Windows\\FireEye\\AppMonitorDll*.dll*",
                                           "?:\\Windows\\apppatch\\AppPatch*\\exploitblocker.dll*",
                                           "?:\\windows\\system32\\hmpalert.dll!*")) and
 not process.thread.Ext.call_stack_final_user_module.hash.sha256 in
                                               ("234360be58be376a77169fcc447cf8cbcba959f5c1db256ea2a50eeb92e65f44",
                                                "fcdde72cfb1b2ff1bf953b2ded03b74c7d7273fa7dcef282a594c2819b2c497c",
                                                "f5071fb08095973d5499e50e6ac176a1bdc33d774ea61e0e3c82605d468e0045",
                                                "0a32e883d669a5b9bbb7aecc1cee31623aa69950ca9e3fce9d5270caa6ae0f39")
'''

min_endpoint_version = "8.10.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 = "T1036"
name = "Masquerading"
reference = "https://attack.mitre.org/techniques/T1036/"

[[threat.technique]]
id = "T1055"
name = "Process Injection"
reference = "https://attack.mitre.org/techniques/T1055/"


[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

[internal]
min_endpoint_version = "8.10.0"

Stages and Predicates

Stage 1: any

any where
 process.executable != null and process.code_signature.status == "errorBadDigest" and   
 (
  (event.category == "api" and event.category == "intrusion_detection" and 
   process.Ext.api.behaviors in ("shellcode", "allocate_shellcode", "execute_shellcode") and
   not process.Ext.api.name in ("SetWindowsHookEx", "IoCreateDevice") and
   process.thread.Ext.call_stack_final_user_module.name != null and
   not process.thread.Ext.call_stack_final_user_module.name in ("Kernel", "Unknown", "Undetermined") and
   not process.thread.Ext.call_stack_final_user_module.protection_provenance like ("Kernel", "Kernel|*")) or

  (event.category == "library" and dll.name in~ ("ws2_32.dll", "wininet.dll", "winhttp.dll") and
   process.thread.Ext.call_stack_summary like
            ("*kernelbase.dll|Unbacked*", "*ntdll.dll|Unbacked*", "*wininet.dll|Unbacked*",
             "*dnsapi.dll|Unbacked*", "*ws2_32.dll|Unbacked*", "*iphlpapi.dll|Unbacked*",
             "*winhttp.dll|Unbacked*", "Unbacked|*"))
 ) and
 not process.executable : ("?:\\Program Files\\*", "?:\\Program Files (x86)\\*") and 
 not (process.executable : "D:\\d3\\view\\viewapp.exe" and process.code_signature.subject_name == "d.velop AG") and
 not (process.executable : "D:\\*\\AuditExplorer.exe" and process.code_signature.subject_name == "Eclipse.org Foundation, Inc.") and
 not (dll.name == "ws2_32.dll" and process.code_signature.subject_name in ("Azul Systems, Inc.", "Ghisler Software GmbH", "Cellebrite DI LTD", "Pagebites, Inc.")) and
 not (process.Ext.api.name in ("NtQueueApcThread", "OpenProcess", "ResumeThread") and process.code_signature.subject_name in ("Azul Systems, Inc.", "Eclipse.org Foundation, Inc.")) and
 not (process.executable : "C:\\AutoVue_Client\\jre\\bin\\javaw.exe" and process.code_signature.subject_name == "Oracle America, Inc.") and
 not (process.executable : ("?:\\Users\\*\\AppData\\Local\\Turbo.net\\Sandbox\\GEARView\\*\\GEARViewBasic.exe",
                             "\\\\?\\Volume{*}\\VMS_PortableClient_x64\\local\\stubexe\\*\\VMS_Client.exe") and
      process.code_signature.subject_name == "Code Systems Corporation") and
 not process.executable : 
             ("?:\\Users\\*\\AppData\\Local\\Microsoft\\Teams\\current\\Teams.exe", 
              "?:\\Program Files (x86)\\Teams Installer\\Teams.exe", 
              "?:\\Program Files\\Microsoft Mouse and Keyboard Center\\CEIP.exe", 
              "?:\\Program Files (x86)\\Microsoft Mouse and Keyboard Center\\CEIP.exe",
              "C:\\Informatica\\10.5.1\\clients\\DeveloperClient\\developerCore.exe",
              "C:\\Users\\*\\AppData\\Roaming\\Spotify\\Spotify.exe") and
 not (process.executable : "D:\\SteamLibrary\\steamapps\\common\\*" and
      process.parent.executable : "C:\\Program Files (x86)\\Steam\\steam.exe") and
 not _arraysearch(process.thread.Ext.call_stack, $entry,
                     $entry.symbol_info : ("?:\\Program Files\\*.dll*",
                                           "?:\\Program Files (x86)\\*.dll*",
                                           "?:\\windows\\system32\\*\\tmmon*.dll*",
                                           "?:\\Windows\\SysWOW64\\esensordbi.dll*",
                                           "?:\\Windows\\System32\\esensordbi.dll*",
                                           "?:\\Windows\\System32\\umppc*.dll*",
                                           "?:\\Windows\\FireEye\\AppMonitorDll*.dll*",
                                           "?:\\Windows\\apppatch\\AppPatch*\\exploitblocker.dll*",
                                           "?:\\windows\\system32\\hmpalert.dll!*")) and
 not process.thread.Ext.call_stack_final_user_module.hash.sha256 in
                                               ("234360be58be376a77169fcc447cf8cbcba959f5c1db256ea2a50eeb92e65f44",
                                                "fcdde72cfb1b2ff1bf953b2ded03b74c7d7273fa7dcef282a594c2819b2c497c",
                                                "f5071fb08095973d5499e50e6ac176a1bdc33d774ea61e0e3c82605d468e0045",
                                                "0a32e883d669a5b9bbb7aecc1cee31623aa69950ca9e3fce9d5270caa6ae0f39")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
dll.nameeqws2_32.dllexcludes:dll.name field:"dll.name" value:"ws2_32.dll"
process.code_signature.subject_nameinAzul Systems, Inc., Cellebrite DI LTD, Ghisler Software GmbH, Pagebites, Inc.excludes:process.code_signature.subject_name
process.Ext.api.nameinNtQueueApcThread, OpenProcess, ResumeThreadexcludes:process.Ext.api.name field:"process.Ext.api.name" value:"NtQueueApcThread" field:"process.Ext.api.name" value:"OpenProcess" field:"process.Ext.api.name" value:"ResumeThread"
process.code_signature.subject_nameinAzul Systems, Inc., Eclipse.org Foundation, Inc.excludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Azul Systems, Inc." field:"process.code_signature.subject_name" value:"Eclipse.org Foundation, Inc."
process.code_signature.subject_nameeqCode Systems Corporationexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Code Systems Corporation"
process.executablewildcard?:\Users\*\AppData\Local\Turbo.net\Sandbox\GEARView\*\GEARViewBasic.exe, \\?\Volume{*}\VMS_PortableClient_x64\local\stubexe\*\VMS_Client.exeexcludes:process.executable field:"process.executable" value:"?:\Users\*\AppData\Local\Turbo.net\Sandbox\GEARView\*\GEARViewBasic.exe" field:"process.executable" value:"\\?\Volume{*}\VMS_PortableClient_x64\local\stubexe\*\VMS_Client.exe"
process.code_signature.subject_nameeqEclipse.org Foundation, Inc.excludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Eclipse.org Foundation, Inc."
process.executablewildcardD:\*\AuditExplorer.exeexcludes:process.executable field:"process.executable" value:"D:\*\AuditExplorer.exe"
process.code_signature.subject_nameeqOracle America, Inc.excludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Oracle America, Inc."
process.executableeqC:\AutoVue_Client\jre\bin\javaw.exeexcludes:process.executable field:"process.executable" value:"C:\AutoVue_Client\jre\bin\javaw.exe"
process.code_signature.subject_nameeqd.velop AGexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"d.velop AG"
process.executableeqD:\d3\view\viewapp.exeexcludes:process.executable field:"process.executable" value:"D:\d3\view\viewapp.exe"
process.executablestarts_withD:\SteamLibrary\steamapps\common\excludes:process.executable field:"process.executable" value:"D:\SteamLibrary\steamapps\common\"
process.parent.executableeqC:\Program Files (x86)\Steam\steam.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\Program Files (x86)\Steam\steam.exe"
process.thread.Ext.call_stackarray_any(no value, null check)excludes:process.thread.Ext.call_stack
process.executablestarts_with?:\Program Files\, ?:\Program Files (x86)\excludes:process.executable field:"process.executable" value:"?:\Program Files\" field:"process.executable" value:"?:\Program Files (x86)\"
process.executablewildcard?:\Users\*\AppData\Local\Microsoft\Teams\current\Teams.exe, ?:\Program Files (x86)\Teams Installer\Teams.exe, ?:\Program Files\Microsoft Mouse and Keyboard Center\CEIP.exe, ?:\Program Files (x86)\Microsoft Mouse and Keyboard Center\CEIP.exe, C:\Informatica\10.5.1\clients\DeveloperClient\developerCore.exe, C:\Users\*\AppData\Roaming\Spotify\Spotify.exeexcludes:process.executable
process.thread.Ext.call_stack_final_user_module.hash.sha256in0a32e883d669a5b9bbb7aecc1cee31623aa69950ca9e3fce9d5270caa6ae0f39, 234360be58be376a77169fcc447cf8cbcba959f5c1db256ea2a50eeb92e65f44, f5071fb08095973d5499e50e6ac176a1bdc33d774ea61e0e3c82605d468e0045, fcdde72cfb1b2ff1bf953b2ded03b74c7d7273fa7dcef282a594c2819b2c497cexcludes:process.thread.Ext.call_stack_final_user_module.hash.sha256

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
dll.namein
  • winhttp.dll corpus 16 (elastic 16)
  • wininet.dll corpus 18 (elastic 18)
  • ws2_32.dll corpus 20 (elastic 20)
field:"dll.name" kind:in
event.categoryeq
  • api corpus 5 (elastic 5)
  • intrusion_detection corpus 2 (elastic 2)
  • library corpus 22 (elastic 22)
field:"event.category" kind:eq
process.Ext.api.behaviorsin
  • allocate_shellcode corpus 9 (elastic 9)
  • execute_shellcode corpus 3 (elastic 3)
  • shellcode corpus 2 (elastic 2)
field:"process.Ext.api.behaviors" kind:in
process.code_signature.statuseq
  • errorBadDigest corpus 2 (elastic 2)
field:"SignatureStatus" kind:eq value:"errorBadDigest"
process.executableis_not_null
  • (no value, null check)
field:"Image" kind:is_not_null
process.thread.Ext.call_stack_final_user_module.nameis_not_null
  • (no value, null check)
field:"process.thread.Ext.call_stack_final_user_module.name" kind:is_not_null
process.thread.Ext.call_stack_summarywildcard
  • *dnsapi.dll|Unbacked*
  • *iphlpapi.dll|Unbacked*
  • *kernelbase.dll|Unbacked*
  • *ntdll.dll|Unbacked*
  • *winhttp.dll|Unbacked*
  • *wininet.dll|Unbacked*
  • *ws2_32.dll|Unbacked*
  • Unbacked|*
field:"process.thread.Ext.call_stack_summary" kind:wildcard