TExcelTAD
Home › Security Foundations: Concepts, Law, Ethics & Your Lab › Windows Accounts, Tokens and UAC

Windows Accounts, Tokens and UAC

A help-desk technician signs in to her workstation with an account that is a member of the local Administrators group "because installing printers needs it". She opens an email attachment. On Linux the attachment would run as her and stop there. On Windows the answer depends on details most users never see: which token the process received, at which integrity level, with which privileges enabled, and whether UAC asked before handing out the full one. Those details decide whether the attachment can read her files, or the whole machine.

The building blocks (SIDs, tokens, ACLs, the split token, integrity levels) are explained in Windows Users, UAC & ACLs. This lesson reads them as a security reviewer: which accounts and privileges are risky, how their use shows up in logs, and what hardening removes the risk. Active Directory accounts come later in Windows & Active Directory Security.

Accounts, by risk

Account What it is Why it matters
built-in Administrator (RID 500) the first local admin; disabled by default on client Windows by default not subject to UAC Admin Approval Mode, and its name and SID are known to everyone
members of Administrators (S-1-5-32-544) admins who get a split token one prompt away from full control
standard users (Users, S-1-5-32-545) the normal case need an admin's credentials to elevate
Guest (RID 501) disabled by default should stay disabled
LocalSystem (S-1-5-18) the identity of the OS itself and many services more powerful than any admin on the machine
LocalService / NetworkService (S-1-5-19, -20) low-privilege service identities still hold SeImpersonatePrivilege
virtual accounts NT SERVICE\<name>, managed service accounts one identity per service the right way to run a service

The rule of thumb is the Linux one: people use standard accounts day to day, admins use a separate admin account only when needed, and services run as the least powerful identity that works.

Tokens and privileges

Every process carries an access token: user SID, group SIDs, privileges and an integrity level. Each privilege is either present-and-disabled (the program must switch it on, AdjustTokenPrivileges) or present-and-enabled. A handful of privileges are each equivalent to full control of the machine, because they bypass the normal access checks:

Privilege Lets the holder Who normally has it
SeDebugPrivilege open any process, including lsass.exe, and read its memory Administrators
SeImpersonatePrivilege act with the token of a client that connects to it services, LocalService, NetworkService, IIS app pools
SeBackupPrivilege / SeRestorePrivilege read / write any file regardless of its ACL Administrators, Backup Operators
SeTakeOwnershipPrivilege become owner of any object, then change its ACL Administrators
SeLoadDriverPrivilege load a kernel driver Administrators
SeTcbPrivilege "act as part of the operating system" LocalSystem only

An auditor compares what an account holds with what it needs. The session below is a lab session on a test workstation WS01.lab.test (10.10.0.21) in the isolated lab: the same admin account in a normal and in an elevated console. It is sample output, abbreviated.

console
PS C:\Users\helpdesk> whoami /groups | Select-String 'Mandatory|Administrators'
BUILTIN\Administrators       Alias  S-1-5-32-544  Group used for deny only
Mandatory Label\Medium Mandatory Level  Label  S-1-16-8192
PS C:\Users\helpdesk> whoami /priv | Select-String 'Debug|Backup|Impersonate'
PS C:\Users\helpdesk> # (nothing: the filtered token has none of them)

# --- the same account after "Run as administrator" (UAC consent prompt accepted)
PS C:\Windows\system32> whoami /groups | Select-String 'Mandatory|Administrators'
BUILTIN\Administrators       Alias  S-1-5-32-544  Mandatory group, Enabled by default, Enabled group, Group owner
Mandatory Label\High Mandatory Level  Label  S-1-16-12288
PS C:\Windows\system32> whoami /priv | Select-String 'Debug|Backup|Impersonate'
SeBackupPrivilege             Back up files and directories             Disabled
SeDebugPrivilege              Debug programs                            Disabled
SeImpersonatePrivilege        Impersonate a client after authentication Enabled

The filtered token marks Administrators deny-only and carries Medium integrity; the elevated one has the group enabled, High integrity and the powerful privileges. "Disabled" here means present but not switched on, which any elevated program can do itself.

Auditing privileges in PowerShell

whoami /priv /fo csv prints the same table as CSV, which you can collect from many machines. The script below runs on PowerShell 7 (here on Linux, so the CSV is embedded) and flags the dangerous privileges in two exports: a service account and an elevated admin.

powershell · try it yourself
$exports = @{
  'svc-report (service)' = @'
"Privilege Name","Description","State"
"SeChangeNotifyPrivilege","Bypass traverse checking","Enabled"
"SeImpersonatePrivilege","Impersonate a client after authentication","Enabled"
"SeCreateGlobalPrivilege","Create global objects","Enabled"
'@
  'helpdesk (elevated)' = @'
"Privilege Name","Description","State"
"SeShutdownPrivilege","Shut down the system","Disabled"
"SeDebugPrivilege","Debug programs","Disabled"
"SeBackupPrivilege","Back up files and directories","Disabled"
"SeTakeOwnershipPrivilege","Take ownership of files or other objects","Disabled"
"SeChangeNotifyPrivilege","Bypass traverse checking","Enabled"
'@
}
$dangerous = 'SeDebugPrivilege','SeImpersonatePrivilege','SeBackupPrivilege',
             'SeRestorePrivilege','SeTakeOwnershipPrivilege','SeLoadDriverPrivilege','SeTcbPrivilege'
foreach ($name in $exports.Keys | Sort-Object) {
  $rows = $exports[$name] | ConvertFrom-Csv
  $hits = $rows | Where-Object { $dangerous -contains $_.'Privilege Name' }
  "{0}: {1} privileges, {2} dangerous" -f $name, $rows.Count, @($hits).Count
  foreach ($h in $hits) { "  {0,-26} {1}" -f $h.'Privilege Name', $h.State }
}
helpdesk (elevated): 5 privileges, 3 dangerous
  SeDebugPrivilege           Disabled
  SeBackupPrivilege          Disabled
  SeTakeOwnershipPrivilege   Disabled
svc-report (service): 3 privileges, 1 dangerous
  SeImpersonatePrivilege     Enabled

The service account's SeImpersonatePrivilege is normal for a service and a well-known escalation path if the service is compromised: tricking a SYSTEM process into connecting to it lets the service impersonate SYSTEM. You can't remove it from every service, so you keep such services patched, isolated and running as their own virtual account, and you watch for the symptoms below.

How it is detected

Windows records token and privilege use in the Security event log (more in The Windows Registry and Event Log):

  • 4624 (successful logon) includes the logon type and, on current versions, an "Elevated Token" field.
  • 4672 "Special privileges assigned to new logon": an account logged on with admin-equivalent privileges. Expected for admins and SYSTEM; unexpected for a help-desk or service account.
  • 4688 (process creation, when enabled) records the token elevation type (%%1936 default, %%1937 full, %%1938 limited) and the mandatory label, so "a Medium-integrity Word started a High-integrity shell" is visible.
  • 4732 a member was added to a security-enabled local group, for example Administrators.

How it is fixed or prevented

  • Separate accounts: daily work as a standard user; admin tasks with a separate admin account, ideally from a dedicated admin workstation.
  • Keep UAC on (EnableLUA = 1) at the default level or "Always notify", and require the secure desktop. Microsoft's own position is that UAC is a convenience and defence-in-depth feature, not a security boundary: it slows malware down and makes elevation visible, it doesn't stop an admin-account compromise.
  • Unique local admin passwords on every machine (Windows LAPS), and the RID 500 account disabled or renamed, so one stolen password doesn't open every workstation.
  • Least privilege for services: virtual accounts or (group) managed service accounts instead of user accounts with passwords, never a domain admin as a service account.
  • Protect LSASS (Credential Guard, LSA protection RunAsPPL) so SeDebugPrivilege can't simply read credentials out of memory.

Pitfalls

  • "Admin" is not one thing. The same account has a filtered and a full token; always ask which one a process has.
  • Removing users from Administrators but granting SeBackupPrivilege (for example through Backup Operators) leaves them able to read every file, including the registry hives with password hashes.
  • Treating UAC as the barrier. Many UAC bypasses exist; the barrier is not being an admin.
  • Shared local admin passwords turn one compromised machine into all of them.

Practice

  1. A process runs with Mandatory Label\High Mandatory Level and BUILTIN\Administrators ... Enabled group. Filtered or full token?
  2. Event 4672 appears for svc-backup every night at 02:00. Is that suspicious?
  3. Which of the dangerous privileges does a normal IIS application pool hold?
Answers
  1. Full (elevated) token: the filtered one has Medium integrity and Administrators as deny-only.
  2. Probably not, if svc-backup holds SeBackupPrivilege by design and runs on schedule. It becomes suspicious at a different time, from a different host, or with an interactive logon type. Write the expectation down so the alert can tell the difference.
  3. SeImpersonatePrivilege, like most service identities; this is why a compromised web application on Windows is often one step from SYSTEM.

Test yourself

What does UAC give an administrator at sign-in?

  1. One full token
  2. A filtered Medium-integrity token for daily use and a full High-integrity token after elevation
  3. Only a guest token
  4. A Linux UID

Why is SeDebugPrivilege considered equivalent to full control?

  1. It shows debug messages
  2. It lets the holder open any process, including LSASS, and read or change its memory
  3. It only works in Visual Studio
  4. It disables the event log

Which event ID says that an account logged on with special (admin-equivalent) privileges?

  1. 4625
  2. 4672
  3. 4720
  4. 1102

What is Microsoft's stated position on UAC?

  1. It is a security boundary
  2. It is a convenience and defence-in-depth feature, not a security boundary
  3. It replaces antivirus
  4. It is only for domain controllers