Detection rules › Elastic

Potential Injection from a LUA Script

Source
github.com/elastic/protections-artifacts

Identifies potential code injection from a LUA script interpreter. This may indicate an attempt to evade defenses.

MITRE ATT&CK coverage

TacticTechniques
Stealth

Rule body

[rule]
description = "Identifies potential code injection from a LUA script interpreter. This may indicate an attempt to evade defenses."
id = "88c2aeed-e5c1-4e0d-98d4-e22ff972e55b"
license = "Elastic License v2"
name = "Potential Injection from a LUA Script"
os_list = ["windows"]
version = "1.0.10"

query = '''
api where
  process.Ext.api.behaviors in ("shellcode", "allocate_shellcode", "execute_shellcode", "unbacked_rwx") and
  process.thread.Ext.call_stack_summary like ("*|luacom.dll*", "*|lua?.?.dll*", "*|lua??.dll*") and
  not process.executable :
               ("?:\\Windows\\System32\\cmd.exe",
                "C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe",
                "?:\\Program Files\\dotnet\\dotnet.exe",
                "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Balatro\\Balatro.exe",
                "C:\\Program Files (x86)\\ILLiad\\ILLiadClient.exe") and
  not process.thread.Ext.call_stack_final_user_module.protection_provenance like ("kernel", "Kernel|*") and
  not process.thread.Ext.call_stack_final_user_module.name in ("Kernel", "Unknown") and
  not process.thread.Ext.call_stack_final_user_module.hash.sha256 in
                                             ("423bde5692d39b68e38292439962804537e673aebf946c1cc12dcf4f34712939",
                                              "3b3558c408c57be332c9595624f6d49413fe0dd43d3d5fa4626041851f77216a") and
  not _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info: "c:\\program files\\wireshark\\lua??.dll!*") and
  not (process.code_signature.trusted == true and process.code_signature.subject_name == "COJALI SL")
'''

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.thread.Ext.call_stack_summary like ("*|luacom.dll*", "*|lua?.?.dll*", "*|lua??.dll*") and
  not process.executable :
               ("?:\\Windows\\System32\\cmd.exe",
                "C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe",
                "?:\\Program Files\\dotnet\\dotnet.exe",
                "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Balatro\\Balatro.exe",
                "C:\\Program Files (x86)\\ILLiad\\ILLiadClient.exe") and
  not process.thread.Ext.call_stack_final_user_module.protection_provenance like ("kernel", "Kernel|*") and
  not process.thread.Ext.call_stack_final_user_module.name in ("Kernel", "Unknown") and
  not process.thread.Ext.call_stack_final_user_module.hash.sha256 in
                                             ("423bde5692d39b68e38292439962804537e673aebf946c1cc12dcf4f34712939",
                                              "3b3558c408c57be332c9595624f6d49413fe0dd43d3d5fa4626041851f77216a") and
  not _arraysearch(process.thread.Ext.call_stack, $entry, $entry.symbol_info: "c:\\program files\\wireshark\\lua??.dll!*") and
  not (process.code_signature.trusted == true and process.code_signature.subject_name == "COJALI SL")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.code_signature.subject_nameeqCOJALI SLexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"COJALI SL"
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
process.thread.Ext.call_stackarray_any(no value, null check)excludes:process.thread.Ext.call_stack
process.executableeq?:\Windows\System32\cmd.exe, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe, ?:\Program Files\dotnet\dotnet.exe, C:\Program Files (x86)\Steam\steamapps\common\Balatro\Balatro.exe, C:\Program Files (x86)\ILLiad\ILLiadClient.exeexcludes:process.executable
process.thread.Ext.call_stack_final_user_module.hash.sha256in3b3558c408c57be332c9595624f6d49413fe0dd43d3d5fa4626041851f77216a, 423bde5692d39b68e38292439962804537e673aebf946c1cc12dcf4f34712939excludes:process.thread.Ext.call_stack_final_user_module.hash.sha256 field:"process.thread.Ext.call_stack_final_user_module.hash.sha256" value:"3b3558c408c57be332c9595624f6d49413fe0dd43d3d5fa4626041851f77216a" field:"process.thread.Ext.call_stack_final_user_module.hash.sha256" value:"423bde5692d39b68e38292439962804537e673aebf946c1cc12dcf4f34712939"
process.thread.Ext.call_stack_final_user_module.nameinKernel, Unknownexcludes:process.thread.Ext.call_stack_final_user_module.name field:"process.thread.Ext.call_stack_final_user_module.name" value:"Kernel" field:"process.thread.Ext.call_stack_final_user_module.name" value:"Unknown"
process.thread.Ext.call_stack_final_user_module.protection_provenancewildcardkernel, Kernel|*excludes:process.thread.Ext.call_stack_final_user_module.protection_provenance field:"process.thread.Ext.call_stack_final_user_module.protection_provenance" value:"kernel" field:"process.thread.Ext.call_stack_final_user_module.protection_provenance" value:"Kernel|*"

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.thread.Ext.call_stack_summarywildcard
  • *|lua?.?.dll*
  • *|lua??.dll*
  • *|luacom.dll*
field:"process.thread.Ext.call_stack_summary" kind:wildcard