Detection rules › Elastic

Suspicious Execution from MSSQL Service

Source
github.com/elastic/protections-artifacts

Identifies the execution of suspicious processes from the Windows MSSQL service, this may indicate the use of MSSQL stored procedures such as xp_cmdshell or the exploitation of SQL injection vulnerabilities to execute malicious commands on the host Operating System.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the execution of suspicious processes from the Windows MSSQL service, this may indicate the use of MSSQL
stored procedures such as xp_cmdshell or the exploitation of SQL injection vulnerabilities to execute malicious commands
on the host Operating System.
"""
id = "547636af-cad2-4be0-a74e-613c7bb86664"
license = "Elastic License v2"
name = "Suspicious Execution from MSSQL Service"
os_list = ["windows"]
version = "1.0.29"

query = '''
process where event.action == "start" and
(
  /* registry or xp_cmdshell stored procedures */
 (process.parent.name : "sqlservr.exe" and
  process.pe.original_file_name in ("cmd.exe", "PowerShell.EXE", "reg.exe")) or

  /* descendant of cmd or powershell */
  (descendant of [process where event.action == "start" and process.pe.original_file_name in ("cmd.exe", "PowerShell.EXE") and
   process.parent.name : "sqlservr.exe"] and not process.executable : "?:\\Windows\\System32\\conhost.exe") or

   /* unsigned child of sqlserv */
  (process.parent.name : "sqlservr.exe" and process.code_signature.trusted != true and
   not process.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe") and
   process.code_signature.status != "errorChaining" and
   not process.hash.sha256 : "1a9adfd83a88d80377d9060c7e2857964bf24974eae13447678cedca7da3dba8") or

   (process.parent.name : "sqlservr.exe" and (process.name : "vpnbridge.exe" or process.pe.original_file_name : "vpnbridge.exe")) or

   (process.parent.name : "sqlservr.exe" and
    (process.name : "certutil.exe" or process.pe.original_file_name == "CertUtil.exe") and process.args : "-urlcache") or

   (process.parent.name : "sqlservr.exe" and
    (process.name : "bitsadmin.exe" or process.pe.original_file_name : "bitsadmin.exe") and
    process.command_line : ("*download*", "*transfer*", "*create*", "*addfile*", "*SetNotifyCmdLine*"))
) and
not process.executable :
              ("\\Device\\HarddiskVolume?\\MSSQL12.ITSM\\MSSQL\\Binn\\DatabaseMail.exe",
               "\\Device\\HarddiskVolume?\\MSSQL13.GP\\MSSQL\\Binn\\DatabaseMail.exe",
               "\\Device\\HarddiskVolume?\\MSSQL13.MSSQLSERVER\\MSSQL\\Binn\\DatabaseMail.exe",
               "S:\\MSSQL\\MSSQL13.MSSQLSERVER\\MSSQL\\Binn\\slssqlmaint.exe")
'''

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

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.001"
name = "PowerShell"
reference = "https://attack.mitre.org/techniques/T1059/001/"

[[threat.technique.subtechnique]]
id = "T1059.003"
name = "Windows Command Shell"
reference = "https://attack.mitre.org/techniques/T1059/003/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Stage 1: process

process where event.action == "start" and
(
 (process.parent.name : "sqlservr.exe" and
  process.pe.original_file_name in ("cmd.exe", "PowerShell.EXE", "reg.exe")) or
  (descendant of [process where event.action == "start" and process.pe.original_file_name in ("cmd.exe", "PowerShell.EXE") and
   process.parent.name : "sqlservr.exe"] and not process.executable : "?:\\Windows\\System32\\conhost.exe") or
  (process.parent.name : "sqlservr.exe" and process.code_signature.trusted != true and
   not process.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe") and
   process.code_signature.status != "errorChaining" and
   not process.hash.sha256 : "1a9adfd83a88d80377d9060c7e2857964bf24974eae13447678cedca7da3dba8") or
   (process.parent.name : "sqlservr.exe" and (process.name : "vpnbridge.exe" or process.pe.original_file_name : "vpnbridge.exe")) or
   (process.parent.name : "sqlservr.exe" and
    (process.name : "certutil.exe" or process.pe.original_file_name == "CertUtil.exe") and process.args : "-urlcache") or
   (process.parent.name : "sqlservr.exe" and
    (process.name : "bitsadmin.exe" or process.pe.original_file_name : "bitsadmin.exe") and
    process.command_line : ("*download*", "*transfer*", "*create*", "*addfile*", "*SetNotifyCmdLine*"))
) and
not process.executable :
              ("\\Device\\HarddiskVolume?\\MSSQL12.ITSM\\MSSQL\\Binn\\DatabaseMail.exe",
               "\\Device\\HarddiskVolume?\\MSSQL13.GP\\MSSQL\\Binn\\DatabaseMail.exe",
               "\\Device\\HarddiskVolume?\\MSSQL13.MSSQLSERVER\\MSSQL\\Binn\\DatabaseMail.exe",
               "S:\\MSSQL\\MSSQL13.MSSQLSERVER\\MSSQL\\Binn\\slssqlmaint.exe")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.executableeq\Device\HarddiskVolume?\MSSQL12.ITSM\MSSQL\Binn\DatabaseMail.exe, \Device\HarddiskVolume?\MSSQL13.GP\MSSQL\Binn\DatabaseMail.exe, \Device\HarddiskVolume?\MSSQL13.MSSQLSERVER\MSSQL\Binn\DatabaseMail.exe, S:\MSSQL\MSSQL13.MSSQLSERVER\MSSQL\Binn\slssqlmaint.exeexcludes:process.executable

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
process.argswildcard
  • -urlcache corpus 3 (elastic 3)
field:"process.args" kind:wildcard value:"-urlcache"
process.code_signature.statusne
  • errorChaining
field:"SignatureStatus" kind:ne value:"errorChaining"
process.code_signature.trustedne
  • true transforms: boolean corpus 8 (elastic 8)
field:"process.code_signature.trusted" kind:ne value:"true"
process.command_linewildcard
  • *SetNotifyCmdLine* corpus 2 (elastic 2)
  • *addfile* corpus 2 (elastic 2)
  • *create* corpus 29 (sigma 17, splunk 7, elastic 5)
  • *download* corpus 4 (elastic 3, sigma 1)
  • *transfer* corpus 3 (elastic 3)
field:"CommandLine" kind:wildcard
process.namewildcard
  • bitsadmin.exe corpus 23 (elastic 21, splunk 2)
  • certutil.exe corpus 44 (elastic 38, splunk 6)
  • vpnbridge.exe
field:"process_name" kind:wildcard
process.parent.namewildcard
  • sqlservr.exe corpus 3 (elastic 2, splunk 1)
field:"parent_process_name" kind:wildcard value:"sqlservr.exe"
process.pe.original_file_nameeq
  • CertUtil.exe corpus 30 (sigma 14, elastic 10, splunk 6)
field:"OriginalFileName" kind:eq value:"CertUtil.exe"
process.pe.original_file_namein
  • PowerShell.EXE corpus 138 (sigma 84, splunk 30, elastic 24)
  • cmd.exe corpus 81 (sigma 43, elastic 21, splunk 17)
  • reg.exe corpus 43 (sigma 32, splunk 8, elastic 3)
field:"OriginalFileName" kind:in
process.pe.original_file_namewildcard
  • bitsadmin.exe corpus 20 (sigma 9, elastic 8, splunk 2, kusto 1)
  • vpnbridge.exe
field:"OriginalFileName" kind:wildcard