Detect Token Impersonation/Theft in Splunk
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/
SPL Detection Query
// T1134.001 — Token Impersonation/Theft (SPL — Sysmon + Security logs)
// Branch 1: Sysmon EventCode=10 — process access to LSASS or other privileged processes
// with access masks associated with token theft
index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=10
TargetImage IN ("*\\lsass.exe", "*\\winlogon.exe", "*\\csrss.exe", "*\\services.exe", "*\\wininit.exe")
(GrantedAccess="0x1010" OR GrantedAccess="0x1fffff" OR GrantedAccess="0x1f0fff"
OR GrantedAccess="0x143a" OR GrantedAccess="0x0040" OR GrantedAccess="0x40"
OR GrantedAccess="0x1410" OR GrantedAccess="0x0002" OR GrantedAccess="0x0004")
NOT (SourceImage IN ("*\\MsMpEng.exe", "*\\SenseIR.exe", "*\\SenseCE.exe",
"*\\SecurityHealthService.exe", "*\\csrss.exe", "*\\smss.exe", "*\\wininit.exe",
"*\\AzureADConnectAuthenticatio.exe"))
| eval Branch="ProcessAccess_PrivTarget"
| eval RiskScore=70
| eval SourceProc=SourceImage, TargetProc=TargetImage, TokenAccess=GrantedAccess
| table _time, host, SourceUser, SourceProc, TargetProc, TokenAccess, CallTrace, Branch, RiskScore
| append [
search index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
(Image="*\\incognito.exe" OR Image="*\\tokenvator.exe" OR Image="*\\tokenduplicator.exe"
OR CommandLine="*steal_token*" OR CommandLine="*impersonate_token*"
OR CommandLine="*Invoke-TokenManipulation*" OR CommandLine="*ImpersonateLoggedOnUser*"
OR CommandLine="*DuplicateTokenEx*" OR CommandLine="*SetThreadToken*"
OR CommandLine="*getsystem*" OR CommandLine="*rev2self*"
OR CommandLine="*NtFilterToken*" OR CommandLine="*SeImpersonatePrivilege*")
| eval Branch="TokenManip_Tool"
| eval RiskScore=85
| eval SourceProc=ParentImage, TargetProc=Image, TokenAccess=""
| table _time, host, User, SourceProc, TargetProc, CommandLine, Branch, RiskScore
]
| append [
search index=wineventlog sourcetype="WinEventLog:Security" EventCode=4672
(PrivilegeList="*SeImpersonatePrivilege*" OR PrivilegeList="*SeAssignPrimaryTokenPrivilege*"
OR PrivilegeList="*SeTcbPrivilege*" OR PrivilegeList="*SeDebugPrivilege*")
NOT (SubjectUserName="*$" OR SubjectUserName IN ("SYSTEM","LOCAL SERVICE","NETWORK SERVICE","ANONYMOUS LOGON"))
NOT (SubjectLogonId IN ("0x3e7","0x3e4","0x3e5"))
| eval Branch="HighRisk_Privilege_Assigned"
| eval RiskScore=60
| eval SourceProc=ProcessName, TargetProc="", TokenAccess=PrivilegeList
| table _time, host, SubjectUserName, SourceProc, TargetProc, TokenAccess, Branch, RiskScore
]
| sort - RiskScore _time Detects token impersonation and theft across three branches using Sysmon and Windows Security logs: (1) Sysmon EventCode=10 (ProcessAccess) to privileged processes with token-relevant GrantedAccess masks (0x1010, 0x1fffff, 0x143a, etc.) from non-whitelisted initiators; (2) Sysmon EventCode=1 (Process Create) matching known token manipulation tool names and post-exploitation command-line patterns (incognito, Invoke-TokenManipulation, steal_token, getsystem); (3) WinEventLog:Security EventCode=4672 for high-risk privilege assignments (SeImpersonatePrivilege, SeAssignPrimaryTokenPrivilege, SeTcbPrivilege) to non-system accounts. Each branch carries an independent risk score for prioritization.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Security and EDR products (Microsoft Defender, CrowdStrike Falcon, Carbon Black) legitimately access LSASS with high GrantedAccess values — whitelist by SourceImage path
- Password managers and enterprise credential management tools may read process memory from privileged processes
- Debugging sessions with WinDbg, x64dbg, or Visual Studio attach to processes with full access rights
- Legitimate system management tools (SysMon, ProcMon, Process Hacker in authorized use) opening privileged process handles for diagnostics
- SQL Server and IIS application pool accounts legitimately hold SeImpersonatePrivilege — exclude these known service account patterns
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.