#Why this matters
In earlier Linux lessons you saw how user IDs, POSIX permissions, cron jobs and systemd units define the local attack surface. Windows solves the same problems with a different architecture: Security Identifiers (SIDs), access tokens, Access Control Lists (ACLs), a central Registry database and background services managed by the Service Control Manager (SCM).
Misconfigurations in these subsystems are one of the fastest paths from a standard user shell to NT AUTHORITY\SYSTEM. Knowing how to inspect registry keys and service permissions from the command line lets both defenders and authorised testers find and fix those gaps before an attacker exploits them.
#Windows security architecture in brief
On Windows, every user, group and built-in account receives a Security Identifier (SID). For example, S-1-5-18 is NT AUTHORITY\SYSTEM, and S-1-5-32-544 is BUILTIN\Administrators.
At sign-in, Windows creates an access token for the user's processes containing their user SID, group memberships, privileges (such as SeDebugPrivilege) and an integrity level (Untrusted, Low, Medium, High or System). With User Account Control (UAC) enabled, an administrator runs routine apps with a Medium-integrity token and elevates to High integrity only when needed.
Every securable object (file, folder, registry key or service) carries a Discretionary Access Control List (DACL) of Access Control Entries (ACEs) allowing or denying rights to specific SIDs.
| Linux concept | Windows equivalent | Security role |
|---|---|---|
| UID / GID | SID (user and group) | Identifies security principals |
root (UID 0) |
NT AUTHORITY\SYSTEM |
Highest local privilege |
| POSIX mode / ACL | DACL (list of ACEs) | Controls read, write and execute |
/etc config files |
Registry (HKLM, HKCU) |
Stores OS, app and autorun settings |
systemd unit |
Windows Service (SCM) | Runs background daemons at boot |
#Inspecting identity and file ACLs from the CLI
Before auditing services or registry keys, check your shell's privileges and folder permissions on disk.
$ whoami /priv
PRIVILEGES INFORMATION
----------------------
Privilege Name Description State
============================= ==================================== ========
SeShutdownPrivilege Shut down the system Disabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
$ icacls "C:\LabApps\Agent"
C:\LabApps\Agent BUILTIN\Administrators:(I)(OI)(CI)(F)
NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
BUILTIN\Users:(I)(OI)(CI)(RX)In icacls, (F) is Full control, (M) is Modify and (RX) is Read and execute, while (OI) and (CI) mark inheritance to files and subfolders. If BUILTIN\Users or Authenticated Users holds (M) or (F) on a folder whose executable runs as SYSTEM, any local user can swap the binary.
#Registry hives and autorun persistence
The Windows Registry stores configuration in root hives. Two matter most during audits:
- HKEY_LOCAL_MACHINE (
HKLM): machine-wide settings, services and system startup entries; modifying it normally requires Administrator orSYSTEM. - HKEY_CURRENT_USER (
HKCU): per-user preferences and startup entries writable by the signed-in user.
Both hives include Run and RunOnce keys that launch programs at sign-in, while service definitions live under HKLM\SYSTEM\CurrentControlSet\Services.
$ reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
SecurityHealth REG_EXPAND_SZ %windir%\system32\SecurityHealthSystray.exe
LabMonitor REG_SZ "C:\Program Files\LabMonitor\mon.exe"#Windows services and privilege-escalation flaws
Background services are configured in the Registry and started by the Service Control Manager (services.exe). You can inspect a service's configuration with sc qc (query config) and its current state with sc query.
$ sc qc LabUpdater
[SC] QueryServiceConfig SUCCESS
SERVICE_NAME: LabUpdater
TYPE : 10 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
BINARY_PATH_NAME : C:\Lab Apps\Updater\updater.exe
SERVICE_START_NAME : LocalSystem
$ accesschk.exe -accepteula -uwcqv "Authenticated Users" LabUpdater
RW LabUpdater
SERVICE_CHANGE_CONFIG
SERVICE_START
SERVICE_STOPThree misconfigurations turn a LocalSystem service into a privilege-escalation path:
- Check service DACL (accesschk)SERVICE_CHANGE_CONFIG or WRITE_DAC for non-admins?
- Check binary ACL (icacls)Can a non-admin overwrite the executable or its folder?
- Check BINARY_PATH_NAME (sc qc)Unquoted path with spaces outside System32?
- Weak service DACL: Non-admins holding
SERVICE_CHANGE_CONFIGorWRITE_DACcan alterBINARY_PATH_NAME(sc config) and restart the service soLocalSystemruns a different binary. - Writable binary or directory: Even with a locked service DACL,
(M)or(F)rights on the binary or its folder let a user replace the executable before the next start. - Unquoted service path: Without quotes around
C:\Lab Apps\Updater\updater.exe, Windows probesC:\Lab.exebefore reaching the intended binary, so a writable parent path lets a local user hijack startup.
#Defending and common mistakes
- Quote every service path with spaces in
ImagePathunderHKLM\SYSTEM\CurrentControlSet\Services\<Name>, and avoid placing services directly underC:\. - Use least-privilege service accounts (
LocalService,NetworkServiceor virtual accountsNT SERVICE\<Name>) instead ofLocalSystem. - Common mistake - ignoring SCM ACLs: Locking the
.exewithicaclsdoes not help if the service DACL grantsSERVICE_CHANGE_CONFIGtoUsers. - Common mistake - relying on UAC: UAC separates Medium and High integrity for admins; it does not fix weak
HKLMor service ACLs.
#Summary
- Windows access control uses SIDs, access tokens, integrity levels and DACLs on files, registry keys and services.
- CLI tools (
whoami /priv,icacls,reg query,sc qc,AccessChk) expose misconfigurations quickly. - Weak service DACLs, writable binaries and unquoted paths enable privilege escalation on
LocalSystemservices. - Fix them with explicit path quoting, tight NTFS and SCM ACLs, and least-privilege service accounts.