Skip to content

Windows Access Tokens and Security Context: The Authorization Core

An Access Token is a Windows kernel object (nt!_TOKEN) generated by the Local Security Authority Subsystem Service (LSASS) upon successful authentication. It encapsulates the complete security context required for authorization decisions:

  • User SID: The primary identity of the account.
  • Group SIDs: All local, domain, and well-known group memberships evaluated at logon.
  • Privileges List: Operating system capabilities assigned to the principal (SeDebugPrivilege, SeImpersonatePrivilege), each marked as Enabled or Disabled.
  • Integrity Level: Mandatory Integrity Control (MIC) classification: Untrusted, Low, Medium, High, or System.
  • Token Type: Primary Token (bound to a process) or Impersonation Token (bound to an individual thread to temporarily act on behalf of a client).
  • Authentication ID & Logon Session: Unique LUID referencing the logon session.

Understanding access tokens is vital to deconstructing in-memory attacks and privilege escalation:

  1. Token Theft & Impersonation (T1134): An attacker with SYSTEM rights on a server can inspect memory, duplicate an administrator’s access token (via incognito or Mimikatz token::elevate), and spawn processes under that identity without knowing their credentials.
  2. User Account Control (UAC) Filtering: Interactive administrators receive a split token. By default, processes run under a Medium Integrity token stripped of administrative SIDs and privileges. Un-elevated malicious activity will fail against protected resources.
  3. SeImpersonatePrivilege Exploitation (Potato Attacks): Service accounts (e.g., IIS pools, SQL service) holding this privilege can force a SYSTEM process to authenticate against a local named pipe, capture its token, and elevate immediately.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Access Token β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ User SID : S-1-5-21-...-1105 (jdoe) β”‚
β”‚ Group SIDs : S-1-5-21-...-513 (Domain Users) β”‚
β”‚ S-1-5-32-544 (Administrators) β”‚
β”‚ S-1-1-0 (Everyone) β”‚
β”‚ S-1-5-11 (Authenticated Users) β”‚
β”‚ Privileges : SeChangeNotifyPrivilege (En) β”‚
β”‚ SeDebugPrivilege (Disabled) β”‚
β”‚ Integrity : High (S-1-16-12288) β”‚
β”‚ Token Type : Primary β”‚
β”‚ Impersonation Level : SecurityImpersonation β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

When a process calls CreateProcess, the child process inherits a duplicate of the parent’s primary token by default.

  • Primary Token: Associated with the process. Applied to all threads unless thread-level impersonation is active.
  • Impersonation Token: Applied to a specific thread to perform operations in the security context of a client:
    • SecurityAnonymous: Client identity is unknown.
    • SecurityIdentification: Server knows client identity and SIDs, but cannot access securable objects on its behalf.
    • SecurityImpersonation: Server can access local securable objects on behalf of the client.
    • SecurityDelegation: Server can access remote network resources on behalf of the client (requires Kerberos delegation).

  • Duplicating Tokens Across Processes: Using DuplicateTokenEx, an elevated process can copy a token from another session and spawn processes under that user identity.
  • Enabling Disabled Privileges: If a privilege is present in a token with the Disabled flag, the process can enable it on demand via AdjustTokenPrivileges.
  • Dropping Privileges (Restricted Tokens): Sandboxed applications (e.g., Chrome, Edge) can strip groups and privileges to spawn child processes at Low Integrity.

  • Injecting New SIDs into an Active Token: Once created by LSASS, the SID array within a token is immutable. Gaining new group memberships requires creating a new logon session.
  • Writing Objects Under Identification Level: The SRM strictly blocks access requests requiring write permissions if the thread’s impersonation level is below SecurityImpersonation.
  • Reaching Network Hosts with a Stolen Local Token: A stolen access token lacks Kerberos session keys and cannot traverse to remote machines without explicit delegation.


  1. An adversary compromises an IIS application running under IIS APPPOOL\DefaultAppPool.
  2. Execution of whoami /priv reveals SeImpersonatePrivilege : Enabled.
  3. The attacker deploys PrintSpoofer or SweetPotato.
  4. The tool creates a local named pipe (\\.\pipe\spoolss) and triggers the print spooler service (SYSTEM) to validate an RPC binding against it.
  5. When the spooler connects, the exploit calls ImpersonateNamedPipeClient().
  6. The thread adopts the spooler’s SYSTEM token and calls CreateProcessWithTokenW() to spawn an interactive shell with full SYSTEM authority.

EventID: 4672 # Special Privileges Assigned to New Logon
SubjectUserName: Administrator
PrivilegeList:
SeDebugPrivilege
SeImpersonatePrivilege
SeTcbPrivilege
Sysmon EventID 10 # Process Access (Token Duplication)
SourceImage: C:\Users\Public\mimikatz.exe
TargetImage: C:\Windows\System32\lsass.exe
GrantedAccess: 0x1410 # PROCESS_VM_READ | PROCESS_QUERY_INFORMATION

  1. The Windows kernel authorizes processes and threads via tokens, not usernames.
  2. Tokens are snapshot copies of SIDs and privileges frozen at authentication time.
  3. SeImpersonatePrivilege allows service accounts to escalate directly to SYSTEM.
  4. UAC splits administrative tokens into Medium (filtered) and High (elevated) pairs.