Skip to main content
Windows Security Architecture, CLI, Registry & Services
Lesson 7 of 12

Windows Security Architecture, CLI, Registry & Services

Understand Windows SIDs, access tokens and DACLs, inspect autorun registry keys and service permissions from the CLI, and remediate common privilege-escalation misconfigurations.

Intermediate 26 min Linux & Windows
Authorised environments only — The techniques described here are used only in training labs and on systems you own or have written permission to test.

Learning objectives

  • Explain how SIDs, access tokens, integrity levels and DACLs enforce Windows access control
  • Inspect user privileges, NTFS permissions, registry autorun keys and service configs from the CLI
  • Identify weak service DACLs, writable binary paths and unquoted service paths in a lab host
  • Harden service accounts and ACLs using least privilege and explicit quoting

Recommended first: Linux Processes, systemd Sandboxing & auditd LogsCron Jobs, PATH Hijacking & Service Misconfigs

#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.

Checking current token and folder ACLs on WS-LAB-01
$ 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 or SYSTEM.
  • 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.

Querying Run keys with reg.exe
$ 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.

Inspecting a lab service configuration and DACL
$ 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_STOP

Three misconfigurations turn a LocalSystem service into a privilege-escalation path:

  1. Check service DACL (accesschk)SERVICE_CHANGE_CONFIG or WRITE_DAC for non-admins?
  2. Check binary ACL (icacls)Can a non-admin overwrite the executable or its folder?
  3. Check BINARY_PATH_NAME (sc qc)Unquoted path with spaces outside System32?
  1. Weak service DACL: Non-admins holding SERVICE_CHANGE_CONFIG or WRITE_DAC can alter BINARY_PATH_NAME (sc config) and restart the service so LocalSystem runs a different binary.
  2. 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.
  3. Unquoted service path: Without quotes around C:\Lab Apps\Updater\updater.exe, Windows probes C:\Lab.exe before 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 ImagePath under HKLM\SYSTEM\CurrentControlSet\Services\<Name>, and avoid placing services directly under C:\.
  • Use least-privilege service accounts (LocalService, NetworkService or virtual accounts NT SERVICE\<Name>) instead of LocalSystem.
  • Common mistake - ignoring SCM ACLs: Locking the .exe with icacls does not help if the service DACL grants SERVICE_CHANGE_CONFIG to Users.
  • Common mistake - relying on UAC: UAC separates Medium and High integrity for admins; it does not fix weak HKLM or 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 LocalSystem services.
  • Fix them with explicit path quoting, tight NTFS and SCM ACLs, and least-privilege service accounts.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge