#Why this matters
An initial foothold on a Windows workstation or application server rarely starts as NT AUTHORITY\SYSTEM. Instead, a tester or attacker usually lands inside a standard user shell or a restricted web/database service context. Local privilege escalation bridges that gap by turning a misconfigured service, loose folder permission, or over-privileged token into full local Administrator or SYSTEM control.
Because many third-party installers still ship weak directory ACLs or unquoted binary paths, defenders and system administrators need to know how to audit and harden Windows hosts before deployment.
#Access tokens, integrity levels, and risky privileges
Every Windows process runs under an access token created at logon. The token carries the user's Security Identifier (SID), group memberships, an Integrity Level (Low, Medium, High, or System), and a list of privileges. Under User Account Control (UAC), an administrator receives a split token: processes launch at Medium integrity by default and only elevate to High upon approval.
You can inspect your current token privileges with whoami /priv:
$ whoami /priv
PRIVILEGES INFORMATION
----------------------
Privilege Name Description State
============================= ========================================= ========
SeAssignPrimaryTokenPrivilege Replace a process level token Disabled
SeAuditPrivilege Generate security audits Disabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeImpersonatePrivilege Impersonate a client after authentication EnabledA crucial rule in Windows is that Disabled in whoami /priv does not mean removed. Any privilege listed in the token can be enabled programmatically by the process; only privileges completely absent from the token are unavailable.
| Token privilege | Typical legitimate holder | Escalation risk when held by untrusted code |
|---|---|---|
SeImpersonatePrivilege |
IIS app pools, SQL/service accounts | Process can impersonate a SYSTEM token if a privileged service connects to a controlled named pipe or COM endpoint |
SeAssignPrimaryTokenPrivilege |
Service managers, logon daemons | Allows launching a new process using an impersonated primary token |
SeDebugPrivilege |
Administrators, system debuggers | Allows opening and writing into memory of SYSTEM processes |
SeBackupPrivilege / SeRestorePrivilege |
Backup agents | Bypasses NTFS file ACLs to read or overwrite sensitive system files and registry hives |
#Service misconfigurations: binary ACLs, service ACLs, and unquoted paths
Windows services typically run as LocalSystem (NT AUTHORITY\SYSTEM). Three distinct configuration flaws allow a standard user to hijack what a privileged service executes:
- Weak service binary or directory ACL: The service executable sits in a non-default folder (such as
C:\Apps\LabAgent\agent.exe) whereBUILTIN\UsersorAuthenticated Usershas Modify(M), Write(W), or Full Control(F)permissions. Replacing or altering that binary executes arbitrary code when the service starts. - Weak service object ACL: The Service Control Manager (SCM) grants a standard user
SERVICE_CHANGE_CONFIGorWRITE_DAC, allowing them to modify the service'sbinPathwithsc configor editHKLM\SYSTEM\CurrentControlSet\Services\<Name>\ImagePath. - Unquoted service path: When a service
BINARY_PATH_NAMEcontains spaces without surrounding double quotes, WindowsCreateProcesstries shorter prefix paths in order before reaching the real executable.
- Parse unquoted ImagePathC:\Program Files\Lab Vendor\App Service\agent.exe
- Probe prefix 1C:\Program.exe
- Probe prefix 2C:\Program Files\Lab.exe
- Probe prefix 3C:\Program Files\Lab Vendor\App.exe
- Launch real binaryC:\Program Files\Lab Vendor\App Service\agent.exe
Notice that an unquoted service path is only exploitable if two additional conditions hold: the user has write permission to one of the intermediate parent directories (such as C:\ or C:\Program Files\Lab Vendor), and the user can restart the service (or wait for a system reboot).
You can audit any service manually using sc qc and icacls:
$ sc qc LabBackup
[SC] QueryServiceConfig SUCCESS
SERVICE_NAME: LabBackup
TYPE : 10 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
BINARY_PATH_NAME : C:\Program Files\Lab Vendor\Backup Agent\agent.exe
SERVICE_START_NAME : LocalSystem
$ icacls "C:\Program Files\Lab Vendor"
C:\Program Files\Lab Vendor BUILTIN\Users:(OI)(CI)(M)
NT AUTHORITY\SYSTEM:(OI)(CI)(F)
BUILTIN\Administrators:(OI)(CI)(F)Here, BINARY_PATH_NAME lacks quotes and BUILTIN\Users has inherited Modify (OI)(CI)(M) permissions on C:\Program Files\Lab Vendor. Because Backup.exe is probed inside that folder before Backup Agent\agent.exe, a standard user could plant a binary at C:\Program Files\Lab Vendor\Backup.exe. In larger environments, automated audit scripts such as WinPEAS or PowerShell queries against Win32_Service surface these findings across dozens of services quickly.
#Registry and installer vectors
Two additional local vectors appear frequently in Windows hardening reviews:
- AlwaysInstallElevated: If both
HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevatedandHKCU\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevatedare set to1, Windows Installer runs any.msipackage launched by a standard user withSYSTEMprivileges. Setting only one of the two keys has no effect; both must equal1. - Scheduled tasks and writable PATH entries: Scheduled tasks configured to run as
SYSTEMthat invoke scripts in writable folders (such asC:\Scripts) or call binaries without absolute paths follow the same hijacking logic as services.
#Defending and common mistakes
Securing Windows hosts against local escalation relies on strict defaults:
- Quote all service paths: Always wrap
ImagePathvalues containing spaces in double quotes, including any arguments placed outside the quotes ("C:\Program Files\App\svc.exe" --config). - Protect application folders and SCM ACLs: Install software inside
C:\Program Fileswith default inherited ACLs, and verify non-admin groups never hold Modify(M)or Write(W)on custom directories or service objects. - Keep service accounts minimal: Prefer Windows Virtual Accounts (
NT SERVICE\<ServiceName>) or low-privilege accounts instead ofLocalSystemwhenever possible, and avoid grantingSeImpersonatePrivilegeunless required. - Disable AlwaysInstallElevated: Enforce
AlwaysInstallElevated = 0via GPO and monitor Event ID7045(new service installed) and4697to detect suspicious service creation or binary path changes.
Common mistakes include quoting an unquoted path while leaving BUILTIN\Users:(M) on the binary's own directory (the binary itself can still be overwritten), forgetting that Disabled privileges in whoami /priv can still be enabled by the process, and assuming HKLM AlwaysInstallElevated = 1 alone is inactive without checking HKCU as well.
#Summary
Local Windows privilege escalation commonly stems from token privileges like SeImpersonatePrivilege, modifiable service binaries or ACLs, unquoted service paths with writable parent folders, and AlwaysInstallElevated policies. Auditing hosts with whoami /priv, sc qc, icacls, and automated baseline tools reveals these weaknesses clearly. Quoting service paths, locking down directory and SCM ACLs, disabling AlwaysInstallElevated, and running services under minimal virtual accounts close these escalation routes.