Detect Token Impersonation/Theft in Google Chronicle
Adversaries may duplicate then impersonate another user's existing token to escalate privileges and bypass access controls. DuplicateToken or DuplicateTokenEx are used to clone an existing process token, which is then applied to the current thread via ImpersonateLoggedOnUser or SetThreadToken, or used to create a new process via CreateProcessWithTokenW. This allows an adversary to operate under a different security context — typically a higher-privileged user — without needing that user's credentials. Token theft is commonly performed against LSASS, winlogon, explorer.exe, or other processes running as privileged users, and is a core capability of post-exploitation frameworks including Cobalt Strike (steal_token), Metasploit (incognito), Havoc, SILENTTRINITY, and Pupy. Real-world actors including APT28, Emotet, REvil, Tarrask, and FinFisher have all leveraged this technique.
MITRE ATT&CK
- Technique
- T1134 Access Token Manipulation
- Sub-technique
- T1134.001 Token Impersonation/Theft
- Canonical reference
- https://attack.mitre.org/techniques/T1134/001/
YARA-L Detection Query
rule t1134_001_token_impersonation_theft {
meta:
author = "Argus Detection Engineering"
description = "Detects token impersonation and theft via privileged process handle acquisition, token manipulation tool execution, and high-risk privilege assignment to non-system accounts (MITRE ATT&CK T1134.001)"
mitre_attack_technique = "T1134.001"
mitre_attack_tactic = "Privilege Escalation, Defense Evasion"
platform = "Windows"
severity = "HIGH"
confidence = "HIGH"
version = "1.0"
reference = "https://attack.mitre.org/techniques/T1134/001/"
events:
(
/* Branch 1: PROCESS_OPEN to LSASS or other privileged Windows processes with token-capable access rights */
(
$e.metadata.event_type = "PROCESS_OPEN" and
re.regex($e.target.process.file.full_path,
`(?i)(\\lsass\.exe|\\winlogon\.exe|\\csrss\.exe|\\services\.exe|\\wininit\.exe)$`) and
$e.target.process.access_mask in
("0x1010", "0x1fffff", "0x1f0fff", "0x143a", "0x0040", "0x40", "0x1410", "0x0002", "0x0004") and
not re.regex($e.principal.process.file.full_path,
`(?i)(\\MsMpEng\.exe|\\SenseIR\.exe|\\SenseCE\.exe|\\SecurityHealthService\.exe|\\csrss\.exe|\\smss\.exe|\\wininit\.exe|\\AzureADConnectAuthenticatio\.exe)$`)
)
or
/* Branch 2: PROCESS_LAUNCH matching known token manipulation tool names or C2 framework post-exploitation CLI strings */
(
$e.metadata.event_type = "PROCESS_LAUNCH" and
(
re.regex($e.target.process.file.full_path,
`(?i)(\\incognito\.exe|\\tokenvator\.exe|\\tokenduplicator\.exe|\\token_manipulator\.exe)$`) or
re.regex($e.target.process.command_line,
`(?i)(steal_token|impersonate_token|Invoke-TokenManipulation|ImpersonateLoggedOnUser|DuplicateTokenEx|SetThreadToken|getsystem|rev2self|NtFilterToken|SeImpersonatePrivilege)`)
)
)
or
/* Branch 3: Windows Security EventID 4672 — high-risk impersonation or TCB privilege assigned to non-system interactive account */
(
$e.metadata.product_event_type = "4672" and
(
re.regex($e.extensions.auth.auth_details,
`(?i)(SeImpersonatePrivilege|SeAssignPrimaryTokenPrivilege|SeTcbPrivilege|SeDebugPrivilege)`) or
re.regex($e.target.user.attribute.labels.value,
`(?i)(SeImpersonatePrivilege|SeAssignPrimaryTokenPrivilege|SeTcbPrivilege|SeDebugPrivilege)`)
) and
not re.regex($e.principal.user.userid, `\$$`) and
not $e.principal.user.userid in
("SYSTEM", "LOCAL SERVICE", "NETWORK SERVICE", "ANONYMOUS LOGON")
)
)
condition:
$e
} Chronicle YARA-L 2.0 multi-branch rule detecting T1134.001 token impersonation/theft across three attack patterns. Branch 1 covers PROCESS_OPEN events targeting LSASS, winlogon, csrss, services, and wininit with access masks associated with token duplication operations (TOKEN_DUPLICATE 0x0002, PROCESS_DUP_HANDLE 0x0040, mimikatz 0x1010, C2 composite 0x143a), excluding known AV/EDR principals. Branch 2 covers PROCESS_LAUNCH events matching known token manipulation binary names and post-exploitation CLI strings from Cobalt Strike (steal_token), Metasploit Incognito (impersonate_token, getsystem, rev2self), and PowerSploit (Invoke-TokenManipulation). Branch 3 covers Windows Security EventID 4672 where SeImpersonatePrivilege, SeAssignPrimaryTokenPrivilege, SeTcbPrivilege, or SeDebugPrivilege is assigned to a non-system, non-machine-account interactive user.
Data Sources
Required Tables
False Positives & Tuning
- Microsoft Defender Antivirus and Windows Defender ATP routinely open LSASS for memory scanning — the principal process exclusion covers MsMpEng.exe but newer Microsoft security process names may require additions to the allowlist regex
- SQL Server Database Engine and IIS worker processes (w3wp.exe) hold SeImpersonatePrivilege by design for impersonating database connection principals — these generate EventID 4672 alerts on every service account logon and should be excluded by principal.user.userid pattern
- Authorized penetration testing activities using Cobalt Strike or Havoc C2 on designated red team endpoints will produce high-fidelity Branch 2 matches — scope detection to production assets using principal.asset.hostname or asset group labels
Other platforms for T1134.001
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1DuplicateToken API Call via PowerShell P/Invoke (Self-Token)
Expected signal: Sysmon Event ID 1: Process Create for powershell.exe with CommandLine containing 'TokenDup', 'DuplicateToken', 'OpenProcessToken'. Sysmon Event ID 7 (ImageLoad): advapi32.dll and kernel32.dll loaded by powershell.exe. PowerShell ScriptBlock Log Event ID 4104 with the full Add-Type block showing DllImport declarations for advapi32.dll token APIs.
- Test 2LSASS Process Handle Acquisition (Sysmon EventID 10 Trigger)
Expected signal: Sysmon Event ID 10 (ProcessAccess): SourceImage=powershell.exe, TargetImage=C:\Windows\System32\lsass.exe, GrantedAccess=0x0400, CallTrace will show the call chain through ntdll.dll → kernel32.dll → the powershell.exe process. This is the primary detection event. Security Event ID 4656 (Handle request) may also appear if object access auditing is enabled.
- Test 3ImpersonateLoggedOnUser on Current Process Token
Expected signal: Sysmon Event ID 1: Process Create for powershell.exe with CommandLine containing 'ImpersonateLoggedOnUser', 'RevertToSelf', 'TokenImp'. PowerShell ScriptBlock Log Event ID 4104 with the full P/Invoke block showing advapi32.dll imports for impersonation APIs. Security Event ID 4672 may fire if the token carries elevated privileges.
- Test 4Invoke-TokenManipulation Enumeration via PowerSploit
Expected signal: Sysmon Event ID 1: powershell.exe process with CommandLine containing 'Invoke-TokenManipulation' and '-Enumerate'. Sysmon Event ID 3: Network connection from powershell.exe to raw.githubusercontent.com on port 443 (for the download). Sysmon Event ID 11: File created at %TEMP%\InvTokMnp.ps1. PowerShell ScriptBlock Log Event ID 4104: multiple events showing the Invoke-TokenManipulation module code and the -Enumerate call. Security Event ID 4672 if the enumeration surfaces elevated token contexts.
References (9)
- https://attack.mitre.org/techniques/T1134/001/
- https://learn.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-duplicatetoken
- https://learn.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-duplicatetokenex
- https://learn.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-impersonateloggedonuser
- https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadtoken
- https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Invoke-TokenManipulation.ps1
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1134.001/T1134.001.md
- https://posts.specterops.io/understanding-and-defending-against-access-token-manipulation-ef7d9fa67d50
- https://learn.microsoft.com/en-us/sysinternals/downloads/sysmon
Unlock Pro Content
Get the full detection package for T1134.001 including response playbook, investigation guide, and atomic red team tests.