Detection rules › Elastic

Potential Privilege Escalation via Token Impersonation

Source
github.com/elastic/protections-artifacts

Identifies the creation of a process running as SYSTEM and impersonating a Windows core binary privileges. Adversaries may create a new process with a different token to escalate privileges and bypass access controls.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the creation of a process running as SYSTEM and impersonating a Windows core binary privileges. Adversaries
may create a new process with a different token to escalate privileges and bypass access controls.
"""
id = "46de65b8-b873-4ae7-988d-12dcdc6fa605"
license = "Elastic License v2"
name = "Potential Privilege Escalation via Token Impersonation"
os_list = ["windows"]
reference = [
    "https://lengjibo.github.io/token/",
    "https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createprocesswithtokenw",
]
version = "1.0.35"

query = '''
process where event.action == "start" and process.parent.executable != null and

 /* process creation via seclogon */
 process.parent.Ext.real.pid > 0 and

 /* CreateProcessWithToken and effective parent is a privileged MS native binary used as a target for token theft */
 user.id : "S-1-5-18"  and
 process.Ext.effective_parent.executable :
                ("?:\\Windows\\system32\\*.exe",
                 "?:\\Windows\\SysWOW64\\*.exe",
                 "?:\\Windows\\Microsoft.Net\\*.exe",
                 "?:\\Windows\\servicing\\TrustedInstaller.exe",
                 "?:\\Program Files\\Microsoft\\*.exe",
                 "?:\\Program Files (x86)\\Microsoft\\*.exe") and 
                 
 not (process.Ext.effective_parent.executable : "?:\\Windows\\System32\\Utilman.exe" and 
      process.parent.executable : "?:\\Windows\\System32\\Utilman.exe" and process.parent.args : "/debug") and 
      
 not (process.executable : ("?:\\Windows\\System32\\WerFault.exe", 
                            "?:\\Windows\\SysWOW64\\WerFault.exe", 
                            "?:\\Windows\\System32\\WerFaultSecure.exe",
                            "?:\\Windows\\SysWOW64\\WerFaultSecure.exe") and process.args : "-u" and process.args : "-p") and 
                            
 not process.parent.executable : "?:\\Windows\\System32\\AtBroker.exe" and
 not (process.executable : "?:\\Windows\\SoftwareDistribution\\Download\\Install\\securityhealthsetup.exe" and 
      process.parent.executable : "?:\\Windows\\SoftwareDistribution\\Download\\Install\\securityhealthsetup.exe") and 
 not (process.code_signature.subject_name :
                            ("philandro Software GmbH", "Freedom Scientific Inc.", "TeamViewer Germany GmbH",
                             "Projector.is, Inc.", "TeamViewer GmbH", "Cisco WebEx LLC", "TeamViewer", "PURSLANE",
                             "Tranquil I.T. Systems", "VOICEFIVE, INC.", "AnyDesk Software GmbH", "Zhou Huabing",
                             "Remote Utilities LLC", "Bayside Computer Systems Inc") and
      process.code_signature.trusted == true) and
 not (process.executable : "?:\\windows\\system32\\WerMgr.exe" and process.args : "-datacollectorcreate") and
 not process.executable : "?:\\Program Files (x86)\\Dolphin\\SnovaMag*\\dol_logon.exe" and
 not (process.executable : "?:\\Windows\\SoftwareDistribution\\Download\\Install\\securityhealthsetup.exe" and
      process.Ext.effective_parent.executable : "?:\\Windows\\servicing\\TrustedInstaller.exe" and
      process.code_signature.subject_name : "Microsoft Windows Publisher" and process.code_signature.trusted == true) and
 /* ansible exec_wrapper */
 not (process.name : "powershell.exe" and
      process.command_line :
              ("*AkAGUAeABlAGMAXwB3AHIAYQBwAHAAZQByAF8AcwB0AHIALgBTAHAAbABpAHQAKABAACgAIgBgADAAYAAwAGAAMABgADAAIgApA*",
               "*ABzAHAAbABpAHQAXwBwAGEAcgB0AHMAIAA9ACAAJABlAHgAZQBjAF8AdwByAGEAcABwAGUAcgBfAHMAdAByAC4AUwBwAGwAaQB0*",
               "*CgAgACAAIAAgAHQAcgBhAHAAIAB7AAoAIAAgACAAIAAgACAAIAAgACQAdwByAGEAcABwAGUAcgBfAHAAYQB0AGgAIAA9ACAAIgA*", 
               "*JABlAHgAZQBjAF8AdwByAGEAcABwAGUAcgBfAHMAdAByACAAPQAgAFsAUwB5AHMAdABlAG0ALgBDAG8AbgBzAG8AbABlAF0*")) and
 not (process.name : "powershell.exe" and
      process.parent.executable : "C:\\Windows\\system32\\wsmprovhost.exe" and
      process.command_line : "*CQAcwBwAGwAaQB0AF8AcABhAHIAdABzACAAPQAgACQAZQB3AC4AUwBwAGwAaQB0ACgAQAAoACIAYAAwAGAAMABgADAAYAAwACIAKQAsACAAMgAsA*") and
 not (process.executable : "?:\\WINDOWS\\system32\\osk.exe" and
      process.parent.executable : ("?:\\WINDOWS\\System32\\WinLogon.exe", "?:\\Windows\\System32\\LogonUI.exe")) and
 not process.hash.sha256 : ("1e07a7a91451303d5cdac0a1673d581f5f7198fcc08fc79e4332aba6400f55a8",
                            "f3607f433952cb23d9eb0fc5e31fd0c4079cad3133dc79d149022900d208876c") and
 not ((process.executable : "C:\\Windows\\SoftwareDistribution\\Download\\Install\\SecurityHealthSetup.exe" or process.pe.original_file_name == "SecurityHealthSetup.exe") and
      process.Ext.effective_parent.executable : "C:\\Windows\\servicing\\TrustedInstaller.exe" and
      process.code_signature.subject_name in ("Microsoft Corporation", "Microsoft Windows") and process.code_signature.trusted == true)
'''

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 = "T1134"
name = "Access Token Manipulation"
reference = "https://attack.mitre.org/techniques/T1134/"
[[threat.technique.subtechnique]]
id = "T1134.001"
name = "Token Impersonation/Theft"
reference = "https://attack.mitre.org/techniques/T1134/001/"

[[threat.technique.subtechnique]]
id = "T1134.002"
name = "Create Process with Token"
reference = "https://attack.mitre.org/techniques/T1134/002/"



[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: process

process where event.action == "start" and process.parent.executable != null and
 process.parent.Ext.real.pid > 0 and
 user.id : "S-1-5-18"  and
 process.Ext.effective_parent.executable :
                ("?:\\Windows\\system32\\*.exe",
                 "?:\\Windows\\SysWOW64\\*.exe",
                 "?:\\Windows\\Microsoft.Net\\*.exe",
                 "?:\\Windows\\servicing\\TrustedInstaller.exe",
                 "?:\\Program Files\\Microsoft\\*.exe",
                 "?:\\Program Files (x86)\\Microsoft\\*.exe") and
 not (process.Ext.effective_parent.executable : "?:\\Windows\\System32\\Utilman.exe" and
      process.parent.executable : "?:\\Windows\\System32\\Utilman.exe" and process.parent.args : "/debug") and
 not (process.executable : ("?:\\Windows\\System32\\WerFault.exe",
                            "?:\\Windows\\SysWOW64\\WerFault.exe",
                            "?:\\Windows\\System32\\WerFaultSecure.exe",
                            "?:\\Windows\\SysWOW64\\WerFaultSecure.exe") and process.args : "-u" and process.args : "-p") and
 not process.parent.executable : "?:\\Windows\\System32\\AtBroker.exe" and
 not (process.executable : "?:\\Windows\\SoftwareDistribution\\Download\\Install\\securityhealthsetup.exe" and
      process.parent.executable : "?:\\Windows\\SoftwareDistribution\\Download\\Install\\securityhealthsetup.exe") and
 not (process.code_signature.subject_name :
                            ("philandro Software GmbH", "Freedom Scientific Inc.", "TeamViewer Germany GmbH",
                             "Projector.is, Inc.", "TeamViewer GmbH", "Cisco WebEx LLC", "TeamViewer", "PURSLANE",
                             "Tranquil I.T. Systems", "VOICEFIVE, INC.", "AnyDesk Software GmbH", "Zhou Huabing",
                             "Remote Utilities LLC", "Bayside Computer Systems Inc") and
      process.code_signature.trusted == true) and
 not (process.executable : "?:\\windows\\system32\\WerMgr.exe" and process.args : "-datacollectorcreate") and
 not process.executable : "?:\\Program Files (x86)\\Dolphin\\SnovaMag*\\dol_logon.exe" and
 not (process.executable : "?:\\Windows\\SoftwareDistribution\\Download\\Install\\securityhealthsetup.exe" and
      process.Ext.effective_parent.executable : "?:\\Windows\\servicing\\TrustedInstaller.exe" and
      process.code_signature.subject_name : "Microsoft Windows Publisher" and process.code_signature.trusted == true) and
 not (process.name : "powershell.exe" and
      process.command_line :
              ("*AkAGUAeABlAGMAXwB3AHIAYQBwAHAAZQByAF8AcwB0AHIALgBTAHAAbABpAHQAKABAACgAIgBgADAAYAAwAGAAMABgADAAIgApA*",
               "*ABzAHAAbABpAHQAXwBwAGEAcgB0AHMAIAA9ACAAJABlAHgAZQBjAF8AdwByAGEAcABwAGUAcgBfAHMAdAByAC4AUwBwAGwAaQB0*",
               "*CgAgACAAIAAgAHQAcgBhAHAAIAB7AAoAIAAgACAAIAAgACAAIAAgACQAdwByAGEAcABwAGUAcgBfAHAAYQB0AGgAIAA9ACAAIgA*",
               "*JABlAHgAZQBjAF8AdwByAGEAcABwAGUAcgBfAHMAdAByACAAPQAgAFsAUwB5AHMAdABlAG0ALgBDAG8AbgBzAG8AbABlAF0*")) and
 not (process.name : "powershell.exe" and
      process.parent.executable : "C:\\Windows\\system32\\wsmprovhost.exe" and
      process.command_line : "*CQAcwBwAGwAaQB0AF8AcABhAHIAdABzACAAPQAgACQAZQB3AC4AUwBwAGwAaQB0ACgAQAAoACIAYAAwAGAAMABgADAAYAAwACIAKQAsACAAMgAsA*") and
 not (process.executable : "?:\\WINDOWS\\system32\\osk.exe" and
      process.parent.executable : ("?:\\WINDOWS\\System32\\WinLogon.exe", "?:\\Windows\\System32\\LogonUI.exe")) and
 not process.hash.sha256 : ("1e07a7a91451303d5cdac0a1673d581f5f7198fcc08fc79e4332aba6400f55a8",
                            "f3607f433952cb23d9eb0fc5e31fd0c4079cad3133dc79d149022900d208876c") and
 not ((process.executable : "C:\\Windows\\SoftwareDistribution\\Download\\Install\\SecurityHealthSetup.exe" or process.pe.original_file_name == "SecurityHealthSetup.exe") and
      process.Ext.effective_parent.executable : "C:\\Windows\\servicing\\TrustedInstaller.exe" and
      process.code_signature.subject_name in ("Microsoft Corporation", "Microsoft Windows") and process.code_signature.trusted == true)

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.executableeqC:\Windows\SoftwareDistribution\Download\Install\SecurityHealthSetup.exeexcludes:process.executable field:"process.executable" value:"C:\Windows\SoftwareDistribution\Download\Install\SecurityHealthSetup.exe"
process.pe.original_file_nameeqSecurityHealthSetup.exeexcludes:process.pe.original_file_name field:"process.pe.original_file_name" value:"SecurityHealthSetup.exe"
process.Ext.effective_parent.executableeqC:\Windows\servicing\TrustedInstaller.exeexcludes:process.Ext.effective_parent.executable field:"process.Ext.effective_parent.executable" value:"C:\Windows\servicing\TrustedInstaller.exe"
process.code_signature.subject_nameinMicrosoft Corporation, Microsoft Windowsexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Microsoft Corporation" field:"process.code_signature.subject_name" value:"Microsoft Windows"
process.code_signature.trustedeqtrueexcludes:process.code_signature.trusted field:"process.code_signature.trusted" value:"true"
process.Ext.effective_parent.executableeq?:\Windows\System32\Utilman.exeexcludes:process.Ext.effective_parent.executable field:"process.Ext.effective_parent.executable" value:"?:\Windows\System32\Utilman.exe"
process.parent.argseq/debugexcludes:process.parent.args field:"process.parent.args" value:"/debug"
process.parent.executableeq?:\Windows\System32\Utilman.exeexcludes:process.parent.executable field:"process.parent.executable" value:"?:\Windows\System32\Utilman.exe"
process.Ext.effective_parent.executableeq?:\Windows\servicing\TrustedInstaller.exeexcludes:process.Ext.effective_parent.executable field:"process.Ext.effective_parent.executable" value:"?:\Windows\servicing\TrustedInstaller.exe"
process.code_signature.subject_nameeqMicrosoft Windows Publisherexcludes:process.code_signature.subject_name field:"process.code_signature.subject_name" value:"Microsoft Windows Publisher"
process.executableeq?:\Windows\SoftwareDistribution\Download\Install\securityhealthsetup.exeexcludes:process.executable field:"process.executable" value:"?:\Windows\SoftwareDistribution\Download\Install\securityhealthsetup.exe"
process.argseq-datacollectorcreateexcludes:process.args field:"process.args" value:"-datacollectorcreate"
process.executableeq?:\windows\system32\WerMgr.exeexcludes:process.executable field:"process.executable" value:"?:\windows\system32\WerMgr.exe"
process.argseq-pexcludes:process.args field:"process.args" value:"-p"
process.argseq-uexcludes:process.args field:"process.args" value:"-u"
process.executableeq?:\Windows\System32\WerFault.exe, ?:\Windows\SysWOW64\WerFault.exe, ?:\Windows\System32\WerFaultSecure.exe, ?:\Windows\SysWOW64\WerFaultSecure.exeexcludes:process.executable
process.code_signature.subject_nameeqphilandro Software GmbH, Freedom Scientific Inc., TeamViewer Germany GmbH, Projector.is, Inc., TeamViewer GmbH, Cisco WebEx LLC, TeamViewer, PURSLANE, Tranquil I.T. Systems, VOICEFIVE, INC., AnyDesk Software GmbH, Zhou Huabing, Remote Utilities LLC, Bayside Computer Systems Incexcludes:process.code_signature.subject_name
process.command_linematchAkAGUAeABlAGMAXwB3AHIAYQBwAHAAZQByAF8AcwB0AHIALgBTAHAAbABpAHQAKABAACgAIgBgADAAYAAwAGAAMABgADAAIgApA, ABzAHAAbABpAHQAXwBwAGEAcgB0AHMAIAA9ACAAJABlAHgAZQBjAF8AdwByAGEAcABwAGUAcgBfAHMAdAByAC4AUwBwAGwAaQB0, CgAgACAAIAAgAHQAcgBhAHAAIAB7AAoAIAAgACAAIAAgACAAIAAgACQAdwByAGEAcABwAGUAcgBfAHAAYQB0AGgAIAA9ACAAIgA, JABlAHgAZQBjAF8AdwByAGEAcABwAGUAcgBfAHMAdAByACAAPQAgAFsAUwB5AHMAdABlAG0ALgBDAG8AbgBzAG8AbABlAF0excludes:process.command_line
process.nameeqpowershell.exeexcludes:process.name field:"process.name" value:"powershell.exe"
process.command_linematchCQAcwBwAGwAaQB0AF8AcABhAHIAdABzACAAPQAgACQAZQB3AC4AUwBwAGwAaQB0ACgAQAAoACIAYAAwAGAAMABgADAAYAAwACIAKQAsACAAMgAsAexcludes:process.command_line field:"process.command_line" value:"CQAcwBwAGwAaQB0AF8AcABhAHIAdABzACAAPQAgACQAZQB3AC4AUwBwAGwAaQB0ACgAQAAoACIAYAAwAGAAMABgADAAYAAwACIAKQAsACAAMgAsA"
process.parent.executableeqC:\Windows\system32\wsmprovhost.exeexcludes:process.parent.executable field:"process.parent.executable" value:"C:\Windows\system32\wsmprovhost.exe"
process.executableeq?:\WINDOWS\system32\osk.exeexcludes:process.executable field:"process.executable" value:"?:\WINDOWS\system32\osk.exe"
process.parent.executableeq?:\WINDOWS\System32\WinLogon.exe, ?:\Windows\System32\LogonUI.exeexcludes:process.parent.executable field:"process.parent.executable" value:"?:\WINDOWS\System32\WinLogon.exe" field:"process.parent.executable" value:"?:\Windows\System32\LogonUI.exe"
process.parent.executableeq?:\Windows\SoftwareDistribution\Download\Install\securityhealthsetup.exeexcludes:process.parent.executable field:"process.parent.executable" value:"?:\Windows\SoftwareDistribution\Download\Install\securityhealthsetup.exe"
process.executablewildcard?:\Program Files (x86)\Dolphin\SnovaMag*\dol_logon.exeexcludes:process.executable field:"process.executable" value:"?:\Program Files (x86)\Dolphin\SnovaMag*\dol_logon.exe"
process.hash.sha256eq1e07a7a91451303d5cdac0a1673d581f5f7198fcc08fc79e4332aba6400f55a8, f3607f433952cb23d9eb0fc5e31fd0c4079cad3133dc79d149022900d208876cexcludes:process.hash.sha256 field:"process.hash.sha256" value:"1e07a7a91451303d5cdac0a1673d581f5f7198fcc08fc79e4332aba6400f55a8" field:"process.hash.sha256" value:"f3607f433952cb23d9eb0fc5e31fd0c4079cad3133dc79d149022900d208876c"
process.parent.executableeq?:\Windows\System32\AtBroker.exeexcludes:process.parent.executable field:"process.parent.executable" value:"?:\Windows\System32\AtBroker.exe"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
process.Ext.effective_parent.executablewildcard
  • ?:\Program Files (x86)\Microsoft\*.exe
  • ?:\Program Files\Microsoft\*.exe
  • ?:\Windows\Microsoft.Net\*.exe
  • ?:\Windows\SysWOW64\*.exe
  • ?:\Windows\servicing\TrustedInstaller.exe
  • ?:\Windows\system32\*.exe
field:"process.Ext.effective_parent.executable" kind:wildcard
process.parent.Ext.real.pidgt
  • 0 transforms: number corpus 11 (elastic 11)
field:"process.parent.Ext.real.pid" kind:gt value:"0"
process.parent.executableis_not_null
  • (no value, null check)
field:"ParentImage" kind:is_not_null
user.idwildcard
  • S-1-5-18 corpus 13 (elastic 13)
field:"user.id" kind:wildcard value:"S-1-5-18"