Detection rules › Elastic

Potential Shellcode Injection via Node.js

Source
github.com/elastic/protections-artifacts

Identifies shellcode injection from a Node.js application. This may indicate an attempt to evade defenses.

MITRE ATT&CK coverage

TacticTechniques
Stealth

Rule body

[rule]
description = "Identifies shellcode injection from a Node.js application. This may indicate an attempt to evade defenses."
id = "c73a1b0d-bd00-4574-8e98-79c75e918eff"
license = "Elastic License v2"
name = "Potential Shellcode Injection via Node.js"
os_list = ["windows"]
version = "1.0.12"

query = '''
api where process.Ext.api.behaviors in ("shellcode", "allocate_shellcode", "execute_shellcode", "unbacked_rwx") and
 process.Ext.api.name in ("VirtualProtect", "VirtualProtectEx", "WriteProcessMemory", "VirtualAlloc", "VirtualAllocEx", "MapViewOfFile", "MapViewOfFile2") and
 process.executable != null and process.parent.executable != null and
 process.thread.Ext.call_stack_final_user_module.name like ("ffi_bindings.node",  "node.napi.*.node") and
 not (process.code_signature.trusted == true and
      process.code_signature.subject_name in ("Reolink Innovation Inc.", "Sky International AG", "Ferox Games B.V.", "Tobii AB", "Unify Software and Solutions GmbH & Co. KG", "8x8, Inc.", "Aruba S.p.A.")) and
  not process.executable : ("C:\\Program Files\\*.exe", "C:\\Program Files (x86)\\*.exe", "D:\\BioStar 2(x64)\\ta\\nodejs-win64\\node.exe") and
  not process.thread.Ext.call_stack_final_user_module.path like ("c:\\program files\\*", "C:\\program files (x86)\\*") and
  process.thread.Ext.call_stack_final_user_module.hash.sha256 != "ca19f3872ed38d98218cf696e477386d27ef1924547ba7aed61eacff32411092" and
  not (process.executable : "C:\\Windows\\Sys*\\cmd.exe" and
       process.parent.executable : ("C:\\ProgramData\\afesta\\GoSign-Desktop\\app-2.3.3\\GoSignDesktop.exe", "C:\\Program Files (x86)\\Bit4Id\\UKC\\UKC\\bin\\kchain.exe"))
'''

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 = "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: api

api where process.Ext.api.behaviors in ("shellcode", "allocate_shellcode", "execute_shellcode", "unbacked_rwx") and
 process.Ext.api.name in ("VirtualProtect", "VirtualProtectEx", "WriteProcessMemory", "VirtualAlloc", "VirtualAllocEx", "MapViewOfFile", "MapViewOfFile2") and
 process.executable != null and process.parent.executable != null and
 process.thread.Ext.call_stack_final_user_module.name like ("ffi_bindings.node",  "node.napi.*.node") and
 not (process.code_signature.trusted == true and
      process.code_signature.subject_name in ("Reolink Innovation Inc.", "Sky International AG", "Ferox Games B.V.", "Tobii AB", "Unify Software and Solutions GmbH & Co. KG", "8x8, Inc.", "Aruba S.p.A.")) and
  not process.executable : ("C:\\Program Files\\*.exe", "C:\\Program Files (x86)\\*.exe", "D:\\BioStar 2(x64)\\ta\\nodejs-win64\\node.exe") and
  not process.thread.Ext.call_stack_final_user_module.path like ("c:\\program files\\*", "C:\\program files (x86)\\*") and
  process.thread.Ext.call_stack_final_user_module.hash.sha256 != "ca19f3872ed38d98218cf696e477386d27ef1924547ba7aed61eacff32411092" and
  not (process.executable : "C:\\Windows\\Sys*\\cmd.exe" and
       process.parent.executable : ("C:\\ProgramData\\afesta\\GoSign-Desktop\\app-2.3.3\\GoSignDesktop.exe", "C:\\Program Files (x86)\\Bit4Id\\UKC\\UKC\\bin\\kchain.exe"))

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.code_signature.subject_namein8x8, Inc., Aruba S.p.A., Ferox Games B.V., Reolink Innovation Inc., Sky International AG, Tobii AB, Unify Software and Solutions GmbH & Co. KGexcludes:process.code_signature.subject_name
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
process.executablewildcardC:\Windows\Sys*\cmd.exeexcludes:process.executable field:"process.executable" value:"C:\Windows\Sys*\cmd.exe"
process.parent.executableeqC:\ProgramData\afesta\GoSign-Desktop\app-2.3.3\GoSignDesktop.exe, C:\Program Files (x86)\Bit4Id\UKC\UKC\bin\kchain.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\ProgramData\afesta\GoSign-Desktop\app-2.3.3\GoSignDesktop.exe" field:"process.parent.executable" value:"C:\Program Files (x86)\Bit4Id\UKC\UKC\bin\kchain.exe"
process.executablewildcardC:\Program Files\*.exe, C:\Program Files (x86)\*.exe, D:\BioStar 2(x64)\ta\nodejs-win64\node.exeexcludes:process.executable field:"process.executable" value:"C:\Program Files\*.exe" field:"process.executable" value:"C:\Program Files (x86)\*.exe" field:"process.executable" value:"D:\BioStar 2(x64)\ta\nodejs-win64\node.exe"
process.thread.Ext.call_stack_final_user_module.pathstarts_withc:\program files\, C:\program files (x86)\excludes:process.thread.Ext.call_stack_final_user_module.path field:"process.thread.Ext.call_stack_final_user_module.path" value:"c:\program files\" field:"process.thread.Ext.call_stack_final_user_module.path" value:"C:\program files (x86)\"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
process.Ext.api.behaviorsin
  • allocate_shellcode corpus 9 (elastic 9)
  • execute_shellcode corpus 3 (elastic 3)
  • shellcode corpus 2 (elastic 2)
  • unbacked_rwx
field:"process.Ext.api.behaviors" kind:in
process.Ext.api.namein
  • MapViewOfFile
  • MapViewOfFile2
  • VirtualAlloc corpus 4 (elastic 4)
  • VirtualAllocEx
  • VirtualProtect corpus 19 (elastic 19)
  • VirtualProtectEx
  • WriteProcessMemory corpus 14 (elastic 14)
field:"process.Ext.api.name" kind:in
process.executableis_not_null
  • (no value, null check)
field:"Image" kind:is_not_null
process.parent.executableis_not_null
  • (no value, null check)
field:"ParentImage" kind:is_not_null
process.thread.Ext.call_stack_final_user_module.hash.sha256ne
  • ca19f3872ed38d98218cf696e477386d27ef1924547ba7aed61eacff32411092
field:"process.thread.Ext.call_stack_final_user_module.hash.sha256" kind:ne value:"ca19f3872ed38d98218cf696e477386d27ef1924547ba7aed61eacff32411092"
process.thread.Ext.call_stack_final_user_module.namewildcard
  • ffi_bindings.node
  • node.napi.*.node
field:"process.thread.Ext.call_stack_final_user_module.name" kind:wildcard