The sub-techniques beta is now live! Read the release blog post for more info.

Access Token Manipulation

Windows uses access tokens to determine the ownership of a running process. A user can manipulate access tokens to make a running process appear as though it belongs to someone other than the user that started the process. When this occurs, the process also takes on the security context associated with the new token. For example, Microsoft promotes the use of access tokens as a security best practice. Administrators should log in as a standard user but run their tools with administrator privileges using the built-in access token manipulation command runas.[1]

Adversaries may use access tokens to operate under a different user or system security context to perform actions and evade detection. An adversary can use built-in Windows API functions to copy access tokens from existing processes; this is known as token stealing. An adversary must already be in a privileged user context (i.e. administrator) to steal a token. However, adversaries commonly use token stealing to elevate their security context from the administrator level to the SYSTEM level. An adversary can use a token to authenticate to a remote system as the account for that token if the account has appropriate permissions on the remote system.[2]

Access tokens can be leveraged by adversaries through three methods:[3]

Token Impersonation/Theft - An adversary creates a new access token that duplicates an existing token using DuplicateToken(Ex). The token can then be used with ImpersonateLoggedOnUser to allow the calling thread to impersonate a logged on user's security context, or with SetThreadToken to assign the impersonated token to a thread. This is useful for when the target user has a non-network logon session on the system.

Create Process with a Token - An adversary creates a new access token with DuplicateToken(Ex) and uses it with CreateProcessWithTokenW to create a new process running under the security context of the impersonated user. This is useful for creating a new process under the security context of a different user.

Make and Impersonate Token - An adversary has a username and password but the user is not logged onto the system. The adversary can then create a logon session for the user using the LogonUser function. The function will return a copy of the new session's access token and the adversary can use SetThreadToken to assign the token to a thread.

Any standard user can use the runas command, and the Windows API functions, to create impersonation tokens; it does not require access to an administrator account.

Metasploit’s Meterpreter payload allows arbitrary token manipulation and uses token impersonation to escalate privileges.[4] The Cobalt Strike beacon payload allows arbitrary token impersonation and can also create tokens. [5]

ID: T1134
Tactic: Defense Evasion, Privilege Escalation
Platform: Windows
Permissions Required: User, Administrator
Effective Permissions: SYSTEM
Data Sources: API monitoring, Access tokens, Process monitoring, Process command-line parameters
Contributors: Tom Ueltschi @c_APT_ure; Travis Smith, Tripwire; Robby Winchester, @robwinchester3; Jared Atkinson, @jaredcatkinson
Version: 1.0
Created: 14 December 2017
Last Modified: 14 October 2019

Procedure Examples

Name Description

APT28 has used CVE-2015-1701 to access the SYSTEM token and copy it into the current process as part of privilege escalation.[24]


Azorult can call WTSQueryUserToken and CreateProcessAsUser to start a new process with local system privileges.[19]


Bankshot grabs a user token using WTSQueryUserToken and then creates a process by impersonating a logged-on user.[17]

Cobalt Strike

Cobalt Strike can steal access tokens from exiting processes and make tokens from known credentials.[9]


Duqu examines running system processes for tokens that have specific system privileges. If it finds one, it will copy the token and store it for later use. Eventually it will start new processes with the stored token attached. It can also steal tokens to acquire administrative privileges.[14]


Empire can use Invoke-RunAs to make tokens as well as PowerSploit's Invoke-TokenManipulation to manipulate access tokens.[12]


FinFisher uses token manipulation with NtFilterToken as part of UAC bypass.[15][16]


Hydraq creates a backdoor through which remote attackers can adjust token privileges.[18]

Lazarus Group

Lazarus Group keylogger KiloAlfa obtains user tokens from interactive sessions to execute itself with API call CreateProcessAsUserA under that user's context.[22][23]


PoshC2 contains a number of modules, such as Invoke-RunAs and Invoke-TokenManipulation, for manipulating tokens.[13]


PowerSploit's Invoke-TokenManipulation Exfiltration module can be used to locate and impersonate user logon tokens.[10][11]


Pupy can obtain a list of SIDs and provide the option for selecting process tokens to impersonate.[8]


SslMM contains a feature to manipulate process privileges and tokens.[20]


Turla RPC backdoors can impersonate or steal process tokens before executing commands. [25]


ZxShell has a command called RunAs, which creates a new process as another user or process context. [21]


Mitigation Description
Privileged Account Management

Limit permissions so that users and user groups cannot create tokens. This setting should be defined for the local system account only. GPO: Computer Configuration > [Policies] > Windows Settings > Security Settings > Local Policies > User Rights Assignment: Create a token object. Also define who can create a process level token to only the local and network service through GPO: Computer Configuration > [Policies] > Windows Settings > Security Settings > Local Policies > User Rights Assignment: Replace a process level token.[6][7]

User Account Management

An adversary must already have administrator level access on the local system to make full use of this technique; be sure to restrict users and accounts to the least privileges they require.


If an adversary is using a standard command-line shell, analysts can detect token manipulation by auditing command-line activity. Specifically, analysts should look for use of the runas command. Detailed command-line logging is not enabled by default in Windows.[26]

If an adversary is using a payload that calls the Windows token APIs directly, analysts can detect token manipulation only through careful analysis of user network activity, examination of running processes, and correlation with other endpoint and network behavior.

There are many Windows API calls a payload can take advantage of to manipulate access tokens (e.g., LogonUser [27], DuplicateTokenEx[28], and ImpersonateLoggedOnUser[29]). Please see the referenced Windows API pages for more information.

Query systems for process and thread token information and look for inconsistencies such as user owns processes impersonating the local SYSTEM account.[3]


  1. Allievi, A.,Flori, E. (2018, March 01). FinFisher exposed: A researcher’s tale of defeating traps, tricks, and complex virtual machines. Retrieved July 9, 2018.
  2. Sherstobitoff, R. (2018, March 08). Hidden Cobra Targets Turkish Financial Sector With New Bankshot Implant. Retrieved May 18, 2018.
  3. Lelli, A. (2010, January 11). Trojan.Hydraq. Retrieved February 20, 2018.
  4. Yan, T., et al. (2018, November 21). New Wine in Old Bottle: New Azorult Variant Found in FindMyName Campaign using Fallout Exploit Kit. Retrieved November 29, 2018.
  5. Baumgartner, K., Golovkin, M.. (2015, May). The MsnMM Campaigns: The Earliest Naikon APT Campaigns. Retrieved April 10, 2019.
  6. Allievi, A., et al. (2014, October 28). Threat Spotlight: Group 72, Opening the ZxShell. Retrieved September 24, 2019.
  7. Novetta Threat Research Group. (2016, February 24). Operation Blockbuster: Unraveling the Long Thread of the Sony Attack. Retrieved February 25, 2016.
  8. Novetta Threat Research Group. (2016, February 24). Operation Blockbuster: Tools Report. Retrieved March 10, 2016.
  9. FireEye Labs. (2015, April 18). Operation RussianDoll: Adobe & Windows Zero-Day Exploits Likely Leveraged by Russia’s APT28 in Highly-Targeted Attack. Retrieved April 24, 2017.
  10. Faou, M. and Dumont R.. (2019, May 29). A dive into Turla PowerShell usage. Retrieved June 14, 2019.
  11. Mathers, B. (2017, March 7). Command line process auditing. Retrieved April 21, 2017.
  12. Microsoft TechNet. (n.d.). Retrieved April 25, 2017.
  13. Microsoft TechNet. (n.d.). Retrieved April 25, 2017.
  14. Microsoft TechNet. (n.d.). Retrieved April 25, 2017.