Post

Windows Identity: SIDs, Access Tokens, Integrity Levels and UAC

How Windows turns an authenticated account into an authorization context: SID structure and allocation, access-token contents, the Security Reference Monitor access check, Mandatory Integrity Control, UAC elevation, attack paths, telemetry and hardening.

Windows Identity: SIDs, Access Tokens, Integrity Levels and UAC

Introduction

Windows separates two questions that are often collapsed into the word identity:

  1. Authentication: who are you?
  2. Authorization: what may you do?

An authentication package such as Kerberos or NTLM validates credentials. The result is not a user name that the kernel compares with an ACL. Windows resolves the account and its groups to security identifiers (SIDs), creates a logon session and one or more access tokens, and attaches a token to every process and thread that acts for that identity. The Security Reference Monitor (SRM) then makes authorization decisions from the token and the target object’s security descriptor.1

flowchart LR
    C[Credentials or existing identity] --> A[Authentication package]
    A --> I[Account and group SIDs]
    I --> L[Logon session]
    L --> T[Access token]
    T --> P[Process or impersonating thread]
    P --> R[Resource request]
    R --> M{MIC policy permits it?}
    M -- No --> D[Access denied]
    M -- Yes --> X{DACL, privileges and other policy permit it?}
    X -- No --> D
    X -- Yes --> H[Handle with granted access]

    P -. requests elevation .-> U[UAC elevation policy]
    U -. creates a new process .-> E[Elevated token and process]

Figure 1 — From authentication to authorization. UAC is an elevation path that can create another process; it is not an extra stage in every object access check.

The companion article on logon sessions and access tokens examines LUIDs, logon types and token lifetime in detail. This article follows the complete authorization path: SID, token, Mandatory Integrity Control (MIC), discretionary access check and UAC elevation.

Security identifiers

Names change; SIDs identify

A security principal is an entity to which Windows can assign access: a user, computer, service account or security group. Its display name is for humans and can change. The SID is the variable-length binary value used in tokens and access-control entries (ACEs). Renaming Alice does not invalidate the ACLs that refer to Alice because those ACLs contain her SID, not the text Alice.2

The familiar string representation follows this form:

1
S-Revision-IdentifierAuthority-SubAuthority1-...-SubAuthorityN
flowchart LR
    S["S"] --> R["1<br/>Revision"]
    R --> A["5<br/>NT Authority"]
    A --> D1["21"]
    D1 --> D2["A"]
    D2 --> D3["B"]
    D3 --> D4["C<br/>Domain identifier"]
    D4 --> RID["RID<br/>Account-relative ID"]

Figure 2 — Conceptual anatomy of an Active Directory account SID: S-1-5-21-A-B-C-RID. The complete domain SID is the prefix through C; the last subauthority distinguishes the principal inside that domain.

The S is the notation prefix, revision 1 is the version of the SID format, and identifier authority 5 is the NT Authority. A sequence of subauthorities follows. For a normal Active Directory account, the domain SID is followed by a relative identifier (RID) allocated to the account. The local Security Accounts Manager performs the analogous job for local accounts; in a domain, Active Directory domain controllers allocate RIDs from RID pools. The last subauthority is not universally an account RID, however: its meaning depends on the SID namespace.3

Consider a well-known SID:

1
S-1-5-32-544
Component Meaning
S SID string notation
1 Revision
5 NT Authority
32 Builtin domain
544 Builtin Administrators alias

Unlike an account SID, S-1-5-32-544 is the same on every Windows system. This is why an ACL can refer to the builtin Administrators group without knowing the computer or domain SID.

SID families that appear in authorization

Family Example Purpose
Account SID S-1-5-21-...-RID Local or domain user, computer or group
Well-known SID S-1-5-18 Stable identity such as Local System
Builtin alias S-1-5-32-544 Local Administrators group
Service SID S-1-5-80-... Isolates a service identity and its resources
Logon SID S-1-5-5-X-Y Identifies one logon session
Integrity SID S-1-16-RID Represents a Mandatory Integrity Control level
Capability SID S-1-15-3-... Grants an app-container capability

An access token normally contains many of these at once. The user’s SID says who logged on, group SIDs express memberships, a logon SID identifies that particular session, and an integrity SID describes the trust level of the running security context.

Access tokens: identity made actionable

The access token is the kernel object that packages a security context. A process has a primary token. A thread may temporarily carry an impersonation token; when it does, access checks for that thread use the impersonation identity instead of the process identity.4

What a token contains

Token field Authorization role
User SID Principal represented by the token
Group SIDs and attributes Enabled, disabled, mandatory or deny-only memberships
Privileges System-wide powers such as SeBackupPrivilege or SeDebugPrivilege; presence and enabled state are distinct
Restricted and capability SIDs Additional allow constraints for restricted tokens and application capabilities
Integrity SID and mandatory policy MIC level and process-creation policy
Owner and primary group Defaults used when creating securable objects
Default DACL Default discretionary ACL for newly created objects; it does not authorize every action by the token
Authentication ID LUID linking the token to its logon session
Token type Primary or impersonation
Impersonation level Anonymous, Identification, Impersonation or Delegation
Elevation data Elevation type and, for split tokens, a link to the counterpart token

Group presence alone is not enough to predict a decision. A group can be disabled or marked deny-only, as happens to administrative SIDs in a filtered UAC token. A deny ACE that matches a deny-only SID still denies access, but an allow ACE for that SID cannot grant access. Restricted tokens introduce another constraint: Windows must satisfy both the normal SID set and the restricted SID set.5

Privileges are not a generic way to ignore a DACL. Each privilege has defined semantics. For example, SeBackupPrivilege can permit backup-style access when the caller requests the corresponding backup intent; an arbitrary enabled privilege does not turn every failed access check into success.6

Primary and impersonation tokens

flowchart TB
    P[Server process<br/>primary token: Service A] --> T[Worker thread]
    C[Client connects<br/>identity: Alice] --> I[Server impersonates client]
    I --> T2[Worker thread<br/>impersonation token: Alice]
    T2 --> F[Open resource as Alice]
    T2 --> V[RevertToSelf]
    V --> T3[Worker thread<br/>effective token: Service A]

Figure 3 — Impersonation lets a server perform a bounded operation in the client’s security context. Failing to revert or accepting an unexpectedly powerful client can turn the feature into a privilege boundary.

The four impersonation levels limit what the server can learn or do:

Level Effective capability
Anonymous Client identity is hidden from the server
Identification Server can query identity and perform ACL checks, but cannot impersonate it to access objects
Impersonation Server can act as the client on the local computer
Delegation Server can act as the client on remote computers when the authentication mechanism permits delegation

Code can obtain a handle to its process token with OpenProcessToken. The process handle must have PROCESS_QUERY_LIMITED_INFORMATION, and the requested token rights are checked against the token object’s DACL. Possessing a process handle therefore does not automatically grant arbitrary access to its token.7

For a quick read-only inspection:

1
2
3
4
whoami /user
whoami /groups
whoami /priv
whoami /all

whoami /groups also exposes the mandatory-label SID. Process Explorer is useful for comparing the token of a normal shell with an elevated one and for seeing group attributes that a flat group-membership list hides.

How Windows makes an access decision

When code opens a securable object, the Object Manager and the object’s subsystem bring together:

  • the caller’s effective token;
  • the requested access mask;
  • the object’s security descriptor;
  • generic-rights mappings and object-specific policy.

The resulting handle stores the granted access mask. Ordinary I/O through that handle normally relies on the authority already granted when it was opened, rather than re-running the object’s DACL for every operation. This is why handle inheritance and duplication matter so much; the Object Manager article examines that capability transfer in detail.

flowchart TD
    Q[Object open request] --> ET[Select effective token<br/>thread token if impersonating,<br/>otherwise process token]
    ET --> G[Map generic rights and determine<br/>the object-specific requested mask]
    G --> MIC{Mandatory label check}
    MIC -- Violates object policy --> DENY[STATUS_ACCESS_DENIED]
    MIC -- Permitted --> P[Apply relevant privilege,<br/>owner and object-type rules]
    P --> DACL{Evaluate DACL ACEs<br/>against token SIDs}
    DACL -- Requested rights not granted --> DENY
    DACL -- Requested rights granted --> CB[Apply any additional subsystem<br/>or kernel callback restrictions]
    CB --> HANDLE[Return handle carrying<br/>the granted access mask]

Figure 4 — A deliberately simplified access-open path. Exact ordering and special rules vary by object type, but MIC is evaluated before the discretionary access check.

The DACL is discretionary: an owner with suitable rights can change it. MIC is mandatory system policy and acts as a boundary before the DACL. A generous DACL therefore cannot override a mandatory-label denial.89 The full kernel path and its object-type-specific exceptions are covered in Windows Internals.10

Mandatory Integrity Control

MIC adds a trust dimension that is independent of user and group identity. Every access token has an integrity SID. A securable object may have a SYSTEM_MANDATORY_LABEL_ACE in the SACL containing its integrity level and policy bits.9

Integrity levels

Level Integrity SID Typical context
Untrusted S-1-16-0 Highly restricted code
Low S-1-16-4096 Legacy sandboxed or low-integrity process
Medium S-1-16-8192 Standard interactive process
High S-1-16-12288 Elevated administrator process
System S-1-16-16384 Local System services and core OS processes
Protected Process S-1-16-20480 Protected-process context; process protection also has separate signer rules

The mandatory ACE controls what a subject at a lower integrity level may do:

  • SYSTEM_MANDATORY_LABEL_NO_WRITE_UP denies write-up;
  • SYSTEM_MANDATORY_LABEL_NO_READ_UP denies read-up;
  • SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP denies execute-up.

The default object policy is no-write-up, not a universal no-read-up policy. A Low process may therefore be able to read a Medium object if the DACL permits it, while still being unable to modify it. MIC is a defense-in-depth mechanism against modification by less-trusted code, not a complete confidentiality sandbox.

flowchart LR
    L[Low-IL process] -->|write request| O[Medium-IL object<br/>NO_WRITE_UP]
    O --> X[Denied by MIC<br/>even if DACL allows]

    L2[Low-IL process] -->|read request| O2[Medium-IL object<br/>default label policy]
    O2 --> A{DACL allows read?}
    A -- Yes --> OK[Read permitted]
    A -- No --> NO[Access denied]

Figure 5 — Integrity policy and DACL answer different questions. The default mandatory policy blocks write-up, but read access still depends on the DACL.

Integrity during process creation

Under the normal mandatory policy, a new process receives the lower of the parent token’s integrity level and the executable file’s integrity level. A Medium process does not become High merely by starting a High-labeled file, and a Medium parent that launches a Low-labeled executable produces a Low process.11

This can be inspected in a lab with built-in tools:

1
2
3
4
5
whoami /groups | findstr /i "Mandatory Label"
icacls .\sample.exe

# Use only on a disposable copy in a lab.
icacls .\sample.exe /setintegritylevel Low

icacls displays both the DACL and an explicit integrity label, but they are not the same mechanism. Also note that many objects have no explicit mandatory ACE and inherit or receive a default label during creation.

User Account Control

UAC reduces routine use of administrative authority. When a user who belongs to Administrators signs in with Admin Approval Mode enabled, Windows creates two linked tokens:

  • a filtered token, normally Medium integrity, with administrative SIDs disabled or deny-only and administrative privileges removed or disabled;
  • a full administrator token, normally High integrity, used only after an approved elevation.12

Explorer starts with the filtered token, so applications launched normally also run filtered. Elevation does not alter the existing process. The AppInfo service brokers creation of a new process with the full token after policy, manifest and consent checks.

sequenceDiagram
    participant U as User
    participant M as Medium-IL process
    participant A as AppInfo service
    participant D as Secure desktop / consent UI
    participant H as High-IL process

    U->>M: Launch with runas or elevation manifest
    M->>A: Request elevated process creation
    A->>A: Evaluate executable and UAC policy
    A->>D: Request consent or credentials if configured
    U-->>D: Approve or provide credentials
    D-->>A: Authorization result
    A->>H: Create new process with selected elevated identity

Figure 6 — A UAC elevation creates a new process. The secure desktop isolates the consent UI from ordinary interactive applications; it does not add a check to every subsequent file or registry operation.

A standard user does not possess a hidden full token. When policy presents a credential prompt, valid administrator credentials create the elevated process under that administrator identity. This matters for profile paths, network credentials, audit attribution and DPAPI-protected data.

An elevation can be requested explicitly:

1
Start-Process powershell.exe -Verb RunAs

The current policy can be read without changing it:

1
2
3
$uac = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System'
Get-ItemProperty $uac -Name EnableLUA, ConsentPromptBehaviorAdmin, `
    ConsentPromptBehaviorUser, PromptOnSecureDesktop

Prompt-policy values

The values below describe the common registry representation. Group Policy or MDM should be used to manage them consistently rather than editing endpoints ad hoc.13

Value ConsentPromptBehaviorAdmin
0 Elevate without prompting
1 Prompt for credentials on the secure desktop
2 Prompt for consent on the secure desktop
3 Prompt for credentials
4 Prompt for consent
5 Prompt for consent for non-Windows binaries (default)
Value ConsentPromptBehaviorUser
0 Automatically deny elevation requests
1 Prompt for credentials on the secure desktop
3 Prompt for credentials (default)

PromptOnSecureDesktop=1 is the default and forces prompts onto the secure desktop; 0 presents them on the interactive desktop. It is a separate setting, so reducing the table to a single numbered “UAC level” loses an important dimension. EnableLUA=1 enables Admin Approval Mode and the UAC model. Disabling it affects more than prompt visibility and should not be treated as an acceptable way to suppress prompts.1314

UAC is not a security boundary against a local administrator. It reduces accidental administrative execution, separates normal and elevated process trees and creates a visible elevation decision. Microsoft does not treat bypasses between two processes owned by the same administrative user as a Windows security-boundary crossing. UAC should therefore be combined with standard-user operation, application control and credential protection.

Attack paths and abuse patterns

The identity pipeline exposes several different attack surfaces. They should not all be described as “UAC bypass” or “token theft,” because their prerequisites and defensive controls differ.

SID and group manipulation

An ACL trusts the SID stored in its ACE. An attacker who gains authority to change privileged group membership changes which SIDs appear in future tokens. In Active Directory, abuse of the sIDHistory attribute can make a new account appear to authorization checks as if it also held an older or privileged SID. Legitimate migration tooling uses SID history, so detections must correlate the change with an approved migration window rather than assuming every value is malicious.15

The token is generally built at logon. Removing a user from a group does not rewrite every existing token; the user may need to sign out and establish a new logon session before the changed membership is reflected everywhere.

Token theft, duplication and impersonation

Code that obtains a suitable handle to another token may duplicate it and use it for impersonation or to create a process, subject to the relevant access rights and privileges. Common paths include:

  • stealing or duplicating a token handle already present in a compromised process;
  • opening a higher-privilege process and then its token after acquiring sufficient process and token rights;
  • coercing or waiting for a privileged client to connect to a service endpoint, then abusing server-side impersonation;
  • using SeImpersonatePrivilege or SeAssignPrimaryTokenPrivilege in an unintended service or broker path.

These paths explain why a stolen password is not required for every privilege transition. A token is already authenticated authority. The defensive focus is therefore on process-handle rights, token-handle provenance, privileged service endpoints and unusual process creation under a different logon context.16

Integrity and UAC mistakes

MIC can be weakened by assigning an unexpectedly low integrity label to a sensitive object or by allowing a lower-integrity process to influence data that a higher-integrity component later consumes. UAC abuse instead targets the elevation workflow: an attacker may try to influence an auto-elevated or trusted component, a COM activation, a scheduled task or another privileged broker so that High-integrity code executes attacker-controlled input.

The useful detection question is not merely “was there a UAC prompt?” It is: which Medium process caused which High process to appear, using which user, binary, command line and parent chain? Some legitimate elevation paths change the apparent parent relationship, so correlation should include the logon ID and timestamps, not just ParentProcessId.

Telemetry and detection

No single event records the complete identity decision. A useful timeline joins authentication, token properties, process creation, object access and directory changes.

Source What it contributes
Security 4624 Successful logon, account SID, Logon ID, logon type, authentication package, impersonation level and elevated-token field
Security 4648 A process attempted a logon using explicit credentials; useful around runas and credential-prompt workflows
Security 4672 Sensitive privileges assigned to a new logon
Security 4688 New process, creator and target identity, command line when enabled, token elevation type and mandatory label on supported event versions
Security 4656 / 4663 Handle request and object access when the relevant SACL and audit policy are configured
Security 4703 A token privilege was enabled or disabled, when Audit Token Right Adjusted is enabled
Security 4728 / 4732 / 4756 Member added to a global, local or universal security group
Security 4765 / 4766 SID history added, or an attempt to add it failed
Sysmon 1 Process creation with hashes, user, parent, command line and integrity level
EDR process/token telemetry Token identity changes, impersonation, token duplication and cross-process handle activity, product-dependent

Event 4696, “A primary token was assigned to a process,” appears in older documentation but is deprecated beginning with Windows 7 and Windows Server 2008 R2. It should not be the foundation of a modern detection strategy.17

High-value correlations

Medium-to-High transitions. Alert on unusual High- or System-integrity processes whose initiating user activity began in a Medium process. Baseline expected administrative tools, software deployment systems and parent/child patterns. Investigate unsigned or user-writable images, suspicious command lines, mismatched users and rare High-integrity binaries.

Token identity different from the process lineage. A process executing as another user can be legitimate for services, scheduled tasks and elevation. It becomes suspicious when combined with an unusual source process, a new logon ID, explicit credentials, token access or a privileged child launched from a user-writable location.

Privilege adjustment plus sensitive access. Correlate 4703, EDR token changes and process-access telemetry with access to LSASS, protected services, SAM/SECURITY hives or another user’s process. A privilege merely present in a token is weaker evidence than one enabled immediately before a sensitive operation.

Directory identity drift. Treat privileged-group changes and SID-history changes as identity-plane events. Correlate 4728, 4732, 4756, 4765 and 4766 with the actor, source workstation, change ticket and the next 4624 for the affected account.18

UAC policy drift. Monitor the UAC policy keys and their governing GPO/MDM configuration. EnableLUA=0, elevation without prompting or moving prompts off the secure desktop should be rare, approved and attributable.

Hardening

Control Security effect
Operate daily sessions as a standard user Removes the linked full administrator token from ordinary browsing and productivity activity
Use separate administrative identities Makes elevation attributable and prevents a compromised daily-use identity from already belonging to privileged groups
Keep EnableLUA=1 and Admin Approval Mode enabled Preserves filtered-token operation and an explicit elevation workflow
Keep prompts on the secure desktop Prevents ordinary desktop applications from driving or spoofing the consent UI
Use consent for non-Windows binaries or a stricter organization-approved policy Avoids silent elevation while balancing credential exposure and operator workflow
Prefer automatic denial for standard-user elevation where support permits Prevents users from entering powerful credentials into arbitrary application prompts
Minimize privileged group membership and review SID history Reduces the SIDs that can authorize sensitive access and catches migration residue or abuse
Restrict SeImpersonatePrivilege, SeAssignPrimaryTokenPrivilege, SeTcbPrivilege and SeDebugPrivilege Narrows token-manipulation and cross-process attack paths
Give services dedicated identities and narrow ACLs Prevents one shared service account or broad group from becoming a universal authorization key
Use Windows LAPS for local administrators Prevents reuse of one local-administrator password across endpoints
Enable Credential Guard and LSA protection where supported Reduces theft of credentials and token-adjacent secrets from LSASS
Apply application control and protect user-writable search paths Limits untrusted code that could initiate elevation or influence privileged brokers
Audit process creation, account management and selected object access Makes token transitions, group changes and sensitive resource access correlatable
Treat MIC as defense in depth, not a DACL replacement Preserves least-privilege ACL design instead of relying on integrity levels alone

Hardening should preserve the distinction between identity, discretionary rights and trust level. Adding a user to fewer groups reduces token authority; tightening a DACL reduces access to one object; MIC limits influence across trust levels; UAC changes how administrative tokens are used. No one control substitutes for the other three.

Summary

Windows authentication resolves a principal to a SID and group membership. The resulting logon session is referenced by access tokens that contain the user SID, group attributes, privileges, restrictions, integrity level and token type. Processes run with primary tokens; threads may temporarily use impersonation tokens. During an object-open request, Windows selects the effective token, applies Mandatory Integrity Control, evaluates discretionary rights and returns a handle containing only the granted access.

MIC and UAC solve different problems. MIC compares the subject and object integrity levels before the DACL and normally prevents lower-trust code from writing upward. UAC keeps an administrator’s normal process tree on a filtered Medium token and brokers creation of a separate elevated process when policy allows it. UAC is therefore not a third check performed after icacls, and it is not a complete security boundary against code already running as a local administrator.

For defenders, identity telemetry becomes useful when it is joined: logon ID from 4624, privileges from 4672, elevation and integrity from 4688 or Sysmon, token manipulation from EDR, and group or SID-history changes from directory auditing. For engineers, the safest design remains narrow groups, narrow privileges, explicit ACLs, bounded impersonation and a brokered, auditable elevation path.

References

  1. Microsoft Learn, Access Tokens. ↩︎

  2. Microsoft Learn, Security Identifiers. ↩︎

  3. Microsoft Learn, SID Components. ↩︎

  4. Microsoft Learn, Impersonation Tokens. ↩︎

  5. Microsoft Learn, Restricted Tokens. ↩︎

  6. Microsoft Learn, Privileges. ↩︎

  7. Microsoft Learn, OpenProcessToken function. ↩︎

  8. Microsoft Learn, How DACLs Control Access to an Object. ↩︎

  9. Microsoft Learn, Mandatory Integrity Control. ↩︎ ↩︎2

  10. P. Yosifovich, A. Ionescu, M. Russinovich, D. Solomon, Windows Internals, Part 1, 7th edition, Microsoft Press, 2017, chapters 7 and 8. ↩︎

  11. Microsoft Learn, TOKEN_MANDATORY_POLICY structure. ↩︎

  12. Microsoft Learn, How User Account Control works. ↩︎

  13. Microsoft Learn, User Account Control settings and configuration. ↩︎ ↩︎2

  14. Microsoft Open Specifications, PromptOnSecureDesktop. ↩︎

  15. Microsoft Learn, Using SID History to Preserve Resource Access. ↩︎

  16. Microsoft Learn, Access Rights for Access-Token Objects. ↩︎

  17. Microsoft Learn, 4696(S): A primary token was assigned to a process. ↩︎

  18. Microsoft Learn, Advanced Audit Policy Configuration settings. ↩︎

This post is licensed under CC BY 4.0 by the author.

© 0xabadface. Some rights reserved.

Using the Chirpy theme for Jekyll.