TL;DR — Local Privilege Escalation (LPE) in the Windows kernel is the art of turning a low-privileged foothold into SYSTEM by abusing a flaw in kernel-mode code. This article surveys the modern bug classes (pool corruption, type confusion, arbitrary read/write, race conditions), walks the canonical exploitation flow from a write primitive to a stolen token, and explains the mitigation gauntlet — SMEP, SMAP, kCFG, HVCI/VBS — that modern exploits must defeat.
Executive Summary
An attacker who lands code on a Windows machine — through phishing, a browser bug, or a compromised service — almost always arrives as a medium or low integrity, non-administrative user. That is by design: sandboxing and least privilege ensure the initial foothold is weak. The job of an LPE exploit is to bridge the gap from that weak position to NT AUTHORITY\SYSTEM, the highest-privileged context on the machine, from which the attacker can disable defences, install drivers, and persist.
The kernel is the most valuable target for this because it is the ultimate trust boundary: kernel code runs at ring 0 with full access to all memory and hardware. A single exploitable bug in the kernel, a driver, or win32k can collapse the entire user/kernel separation. Microsoft has spent two decades layering mitigations to make this hard; modern kernel exploitation is largely the story of defeating those mitigations one by one.
Why the Kernel Is the Prize
flowchart TD
A["Initial foothold<br/>(low/medium integrity user)"] --> B["Kernel/driver vulnerability"]
B --> C["Memory corruption primitive<br/>(write-what-where, R/W, UAF)"]
C --> D["Defeat mitigations<br/>(SMEP, kCFG, VBS...)"]
D --> E["Manipulate kernel structures<br/>(EPROCESS token)"]
E --> F["SYSTEM privileges"]
F --> G["Disable EDR, load driver,<br/>persist, dump credentials"]
style B fill:#1a230c,stroke:#fca311,color:#fef3c7
style F fill:#2a0c14,stroke:#ef233c,color:#fee2e2User mode and kernel mode are separated by the CPU's privilege rings. User-mode code talks to the kernel through a narrow, well-defined interface: system calls. The kernel's attack surface is everything reachable through that interface — and it is enormous: hundreds of syscalls, the win32k.sys GUI subsystem, the I/O manager and its thousands of third-party drivers, and ioctl handlers that take attacker-shaped input.
The Modern Bug Classes
| Bug class | Description | Typical primitive |
|---|---|---|
| Pool buffer overflow | Write past a kernel pool allocation | Adjacent-object corruption |
| Use-after-free (UAF) | Object freed but still referenced | Reclaim with controlled data → R/W |
| Type confusion | Object treated as the wrong type | Controlled field interpretation |
| Arbitrary write (write-what-where) | Write a controlled value to a controlled address | Direct structure manipulation |
| Arbitrary read | Read from a controlled address | Defeat KASLR, locate structures |
| Race condition (TOCTOU) | State changes between check and use | Double-fetch, object lifecycle abuse |
| Integer overflow | Size miscalculation → undersized allocation | Leads to overflow/OOB |
The two primitives every exploit ultimately wants are arbitrary read and arbitrary write of kernel memory. Most bugs do not hand you these directly; the craft of exploitation is converting a constrained bug (say, a single controlled free, or a one-byte overflow) into reliable, repeatable read/write.
The Kernel Pool: Where the Action Happens
Most modern kernel exploitation is heap (pool) exploitation. The kernel allocates objects from pools, and an attacker's job is pool grooming: arranging allocations so a vulnerable object sits adjacent to an object the attacker can later abuse.
POOL GROOMING (conceptual layout before triggering the bug) [ controlled obj ][ VICTIM obj ][ controlled obj ][ free hole ] ^ ^ ^ spray filler the buggy object spray filler Goal: when VICTIM is freed/overflowed, the adjacentcontrolled object's fields (e.g. a function pointer orsize field) are corrupted in a useful, predictable way.Windows hardened the pool over time (the Segment Heap for the kernel, pool quota and header cookies, randomised allocation) specifically to make grooming less deterministic. Attackers respond with better-understood "spray" objects whose size and lifetime they control — historically pipe attributes, named pipes, tagWND/win32k objects, and registry key/value structures.
The Canonical Exploitation Flow
Suppose we have achieved a write-what-where primitive (the cleanest case). The path to SYSTEM is well established:
Step 1 — Defeat KASLR (get a read / a leak)
Kernel Address Space Layout Randomisation hides where structures live. The exploit needs to learn real addresses, usually via an information leak — a separate read primitive, a side channel, or (historically, before it was restricted for low-integrity callers) NtQuerySystemInformation's module list, which leaks driver base addresses.
Step 2 — Locate the token structures
Each process has an `EPROCESS` structure in kernel memory, and within it a pointer to a security token describing its privileges. The exploit walks the EPROCESS list to find:
- Its own process's
EPROCESS(and the offset to itsToken). - The SYSTEM process's
EPROCESS(PID 4), which holds the all-powerful SYSTEM token.
Step 3 — Token theft (the classic technique)
Using the write primitive, the exploit overwrites its own process's token pointer with the SYSTEM process's token pointer. Now the attacker's process is SYSTEM, with no further exploitation needed.
BEFORE: AttackerEPROCESS.Token ──► [ low-priv token ] SystemEPROCESS.Token ──► [ SYSTEM token ] WRITE: copy SystemEPROCESS.Token value into AttackerEPROCESS.Token AFTER: AttackerEPROCESS.Token ──► [ SYSTEM token ] ← attacker is now SYSTEMsequenceDiagram
participant E as Exploit (low priv)
participant K as Kernel memory
E->>K: Leak driver/EPROCESS addresses (defeat KASLR)
E->>K: Find SYSTEM EPROCESS (PID 4) token
E->>K: Write SYSTEM token ptr over own token ptr
Note over E: cmd.exe spawned by exploit now runs as SYSTEMAn alternative to token swapping is privilege bit manipulation — flipping the Privileges.Enabled/Present bitmasks in the token to grant SeDebugPrivilege, SeImpersonatePrivilege, etc., which can then be abused in user mode (e.g. via the "Potato" family of impersonation attacks).
Step 4 — Stabilise
A clean exploit must repair kernel state so the system does not bugcheck (BSOD) when it later touches the corrupted structures. Fixing up pool headers and reference counts is often harder than the initial exploitation.
The Mitigation Gauntlet
Modern Windows exploits cannot simply "jump to shellcode." A series of mitigations each removes a classic technique:
| Mitigation | What it stops | How exploits adapt |
|---|---|---|
| DEP / NX | Executing data pages | Use ROP / data-only attacks |
| SMEP | Kernel executing user-mode code | Stay in kernel: ROP within kernel, data-only token theft |
| SMAP | Kernel reading user-mode data unexpectedly | Keep payload data in kernel pool |
| KASLR | Knowing kernel addresses | Information leaks |
| kCFG (Control Flow Guard) | Calling arbitrary indirect targets | Data-only attacks; valid-target gadgets |
| HVCI / VBS | Unsigned code in kernel; protects critical structures via hypervisor | Pure data-only exploitation; avoid code injection entirely |
| Kernel CET / shadow stack | ROP via return-address corruption | Forward-edge / data-only techniques |
flowchart LR
A["Exploit primitive"] --> B{"SMEP/SMAP?"}
B -->|yes| C["No user-mode payload:<br/>stay data-only / kernel ROP"]
C --> D{"kCFG / CET?"}
D -->|yes| E["Avoid corrupting<br/>control flow → data-only<br/>token theft"]
E --> F{"HVCI / VBS?"}
F -->|yes| G["No code injection at all;<br/>manipulate protected-but-<br/>reachable data"]
G --> H["SYSTEM via token swap"]
style H fill:#2a0c14,stroke:#ef233c,color:#fee2e2The cumulative effect is profound. The dominant modern technique is the data-only attack: never inject or execute new code at all, only read and write existing kernel data (like a token pointer). Data-only attacks sidestep SMEP, kCFG, and even HVCI, because no new code runs — which is exactly why token theft via a write primitive remains the evergreen endgame.
win32k: The Perennial Hotspot
A disproportionate share of historical Windows LPEs live in `win32k.sys`, the kernel-mode component of the Windows GUI. It is huge, old, processes complex attacker-influenced input (window messages, fonts, menus), and was historically reachable from sandboxes. Microsoft's mitigations here are instructive:
- `win32k` syscall filtering — sandboxed processes (e.g. the browser renderer) can be blocked from calling
win32ksyscalls entirely, removing the attack surface. - Type isolation for
win32kobjects to make UAF/type-confusion harder.
The lesson: the most effective mitigation is often attack-surface reduction — preventing the vulnerable code from being reached — rather than making the vulnerable code safe.
Constructing Read/Write From a Weaker Bug
The clean "write-what-where" example above is the destination, not the starting point. Real vulnerabilities hand you something far more constrained — a single freed object, a one-byte overflow, an off-by-one in a size calculation — and the craft is amplifying that into reliable arbitrary read and write. A representative use-after-free amplification:
- Free a victim object. The bug frees an object the kernel still holds a reference to.
- Reclaim the slot. The attacker immediately allocates a controllable object of the same pool size into the freed slot. Historically, attacker-controlled objects with predictable sizes —
Pipeattributes,WNFstate data, named-pipe buffers, registry value blobs — are sprayed to win this race. - Forge a fake object. Because the kernel now operates on the dangling reference but the memory contains attacker data, fields the kernel treats as pointers or lengths are attacker-controlled.
- Bootstrap a primitive. A controlled length field yields out-of-bounds read/write; a controlled pointer yields arbitrary read or write. From a single such primitive, the attacker builds a stable, repeatable read/write capability — often by constructing a fake object whose "data buffer" pointer they can repoint at will.
flowchart LR
A["Constrained bug<br/>(UAF / overflow)"] --> B["Pool grooming<br/>+ reclaim with<br/>controlled object"]
B --> C["Out-of-bounds or<br/>dangling field control"]
C --> D["Relative R/W"]
D --> E["Arbitrary R/W<br/>(stable primitive)"]
E --> F["Token theft → SYSTEM"]
style A fill:#1a230c,stroke:#fca311,color:#fef3c7
style F fill:#2a0c14,stroke:#ef233c,color:#fee2e2The "spray a controllable object into a freed slot" step is why Microsoft has progressively hardened the most-abused spray objects (pipe attributes, tagWND) and randomised pool allocation — to make step 2 unreliable and break the amplification before it begins.
Learning Safely: HEVD and Real-World CVE Classes
For researchers and defenders who want to understand these techniques without weaponising live zero-days, the canonical training target is the HackSys Extreme Vulnerable Driver (HEVD) — a deliberately vulnerable Windows kernel driver that implements, in isolation, each classic bug class: stack overflow, pool overflow, use-after-free, type confusion, arbitrary write, and integer overflow. It is the kernel equivalent of a CTF playground, letting practitioners build each primitive against a known-vulnerable, fully documented target with mitigations toggled on or off at will.
The bug classes HEVD teaches map directly onto real, patched CVEs that defenders should recognise:
| Real-world class | Example bug type | Where it lives |
|---|---|---|
win32k type confusion / UAF | CVE-2021-1732 (window object) | win32kfull.sys |
| CLFS (logging file system) | Repeated 2022–2023 LPEs | clfs.sys |
| Pool overflow in a third-party driver | Many vendor driver bugs | Signed 3rd-party drivers |
| BYOVD abuse | Vulnerable-but-signed drivers loaded by attackers | e.g. anti-cheat / utility drivers |
The recurrence of win32k and clfs in the LPE-of-the-month cycle reflects their age, size, and the complexity of the attacker-influenced input they parse. For defenders, the practical signal is that most in-the-wild kernel LPE is an n-day — a known, patched bug exploited against machines that have not applied the update — which is precisely why disciplined patching is the highest-value defence in this entire domain.
Detection
Kernel exploitation is stealthy by nature (it runs below most sensors), but it is not undetectable:
| Source | Indicator |
|---|---|
| EDR / kernel callbacks | A process's token suddenly mapping to SYSTEM without a legitimate logon |
| ETW (Threat-Intelligence provider) | Suspicious NtQuerySystemInformation leaks, anomalous handle operations |
| Crash telemetry | Frequent bugchecks (BSODs) during a failed exploit's instability |
| Driver telemetry | Loading of known-vulnerable signed drivers (BYOVD) just before escalation |
| Process lineage | A SYSTEM cmd.exe/powershell.exe parented by a low-priv process |
Detection reality: because data-only attacks inject no code, signature-based detection is weak. The strongest signals are behavioural and relational — e.g. "this medium-integrity process now owns a SYSTEM token" — which is why kernel-level EDR telemetry and token-integrity monitoring matter more than file scanning here.
Defence
- Patch the kernel and drivers. The vast majority of real-world LPEs exploit known, patched bugs against unpatched machines. Timely patching closes most of the risk.
- Enable VBS / HVCI and kernel CET on supported hardware. They eliminate code-injection techniques and force attackers into the much harder data-only realm.
- Block vulnerable drivers (BYOVD). Enable Microsoft's vulnerable driver blocklist and WDAC policies; many "kernel exploits" are actually attackers bringing their own buggy signed driver.
- Reduce attack surface. Use
win32ksyscall filtering and process mitigation policies on high-risk processes; sandbox aggressively so a foothold starts at low integrity. - Least privilege + credential protection. Limit what a SYSTEM compromise yields: Credential Guard, LSASS protection (PPL), and tiered administration contain the blast radius.
- Behavioural EDR. Deploy sensors that monitor token integrity and process lineage, since data-only kernel attacks evade static detection.
Named Pipe Privilege Escalation
While pool-heap exploitation dominates the research literature, named pipe impersonation represents one of the most reliable and widely exploited LPE primitives in real-world intrusions. It operates entirely in user mode and requires no kernel vulnerability at all — making it complementary to, and often preferred over, traditional kernel exploitation when the target is an unpatched or poorly configured system. The Potato family of exploits (Hot Potato, Sweet Potato, Juicy Potato, Rotten Potato, and PrintSpoofer) are all named-pipe impersonation variants.
How Named Pipe Impersonation Works
Windows named pipes are a form of IPC. A server creates a named pipe (e.g. \\.\pipe\foo), and a client connects to it. Critically, Windows allows a server with `SeImpersonatePrivilege` to call ImpersonateNamedPipeClient — which causes the server's current thread to take on the security token of the client that connected. If the client is a high-privileged process (e.g. SYSTEM), the impersonation yields a SYSTEM token.
sequenceDiagram
participant A as Attacker process<br/>(SeImpersonatePrivilege)
participant P as Named pipe server<br/>(attacker-controlled)
participant S as SYSTEM service<br/>(coerced client)
A->>P: CreateNamedPipe("\\.\pipe\exploit")
Note over A,P: Attacker waits for a privileged connection
A->>S: Coerce SYSTEM service to connect to pipe<br/>(via authentication coercion or scheduled task trick)
S->>P: Connect to \\.\pipe\exploit as SYSTEM
P->>P: ImpersonateNamedPipeClient()
Note over P: Thread now holds SYSTEM token
P->>A: CreateProcessWithTokenW(SYSTEMtoken, "cmd.exe")
Note over A: SYSTEM shellThe pivotal precondition is SeImpersonatePrivilege. This privilege is assigned by default to:
- IIS application pool identities (
IIS AppPool\DefaultAppPooland similar) - SQL Server service accounts
- Network Service and Local Service accounts (with some restrictions)
- Any account that has been granted it explicitly
In a typical compromise scenario — an attacker who has exploited a web application and has code execution as the IIS app pool — they almost always have SeImpersonatePrivilege without needing any kernel vulnerability.
The PrintSpoofer Technique
PrintSpoofer (by itm4n, 2020) is the cleanest modern named-pipe impersonation that does not require the Print Spooler to be running. It works by creating a named pipe that masquerades as the Windows RPC endpoint for a specific printer port monitor, then calling CreateProcessWithTokenW with the impersonated token:
# Check if SeImpersonatePrivilege is present (from a web shell / low-priv shell)whoami /priv | findstr "SeImpersonatePrivilege" # If present, escalate to SYSTEM:PrintSpoofer64.exe -i -c "cmd /c whoami"# Output: nt authority\system # Drop an interactive SYSTEM shell:PrintSpoofer64.exe -i -c powershell.exeUnder the hood, PrintSpoofer:
- Creates a named pipe at a predictable path that the spooler's RPC endpoint will connect to.
- Calls
SpoolerPrinterExists()(via DCE/RPC to the local spooler) to trigger an authentication callback to the pipe — coercing a SYSTEM-context connection. - Calls
ImpersonateNamedPipeClient()to capture the SYSTEM token. - Uses
CreateProcessWithTokenWwith the captured token to spawn a new process running as SYSTEM.
The Juicy/Sweet Potato Variants
The Potato family exploits the same impersonation primitive but uses different coercion mechanisms to get a SYSTEM-context client to connect to the attacker's pipe:
| Variant | Coercion mechanism | Windows target | Notes |
|---|---|---|---|
| Hot Potato | NBNS spoofing + WPAD + NTLM relay to local machine | Win 7 / 2008 | Obsolete; patched |
| Rotten Potato | RPC/COM SYSTEM token via BITS | Win Server 2016 and earlier | Needed SeImpersonatePrivilege |
| Juicy Potato | COM object activation via DCOM (configurable CLSID) | Pre-2019 | DCOM restrictions patched in Server 2019 |
| Sweet Potato | ScheduleService COM + CreateProcessWithToken | Server 2019, Win 10 | Works even after JucyPotato DCOM fix |
| PrintSpoofer | Print Spooler RPC callback to named pipe | Server 2019 / Win 10 | Works without Spooler running via CreateFile trick |
| GodPotato | RPC EfsRpcOpenFileRaw (MS-EFSRPC) | Server 2012 R2 – 2022 | Does not require Spooler; very broadly applicable |
GodPotato (2023) is the most current and widely applicable variant. It exploits the EFSRPC call — the same coercion primitive used in PetitPotam for network NTLM relay — locally to coerce a SYSTEM connection to a named pipe:
# GodPotato: works on Server 2012 R2 through 2022 with SeImpersonatePrivilegeGodPotato-NET4.exe -cmd "cmd /c whoami"# → nt authority\system GodPotato-NET4.exe -cmd "cmd /c net user hacker Password1! /add && net localgroup administrators hacker /add"Detection: Named Pipe Impersonation Signals
Because named-pipe impersonation happens entirely in user mode, it is less visible to kernel-level sensors. The detectable signals are behavioural:
| Source | Indicator |
|---|---|
| Process telemetry | w3wp.exe, sqlservr.exe, or another service-account process spawning cmd.exe or powershell.exe as SYSTEM |
| Windows Security 4688 | CreateProcessWithTokenW or CreateProcessAsUser calls resulting in a SYSTEM-owned child process from a non-SYSTEM parent |
| Named pipe events (ETW, Sysmon Event ID 17/18) | Named pipe creation at unusual paths (e.g. \\.\pipe\spoolss or a GUID-looking path) immediately before a privilege elevation |
| Token integrity | A process that was Network Service or IIS AppPool suddenly acquiring a SYSTEM-integrity token |
Sysmon, when configured to log pipe creation and connection events (Event IDs 17 and 18), provides the clearest forensic trail:
<!-- Sysmon config: capture named pipe events for known Potato paths --><PipeEvent onmatch="include"> <PipeName condition="contains">spoolss</PipeName> <PipeName condition="contains">MSSE</PipeName> <PipeName condition="contains">ntsvcs</PipeName></PipeEvent>MITRE ATT&CK Mapping
| ATT&CK Tactic | Technique ID | Technique Name | Kernel LPE / Named Pipe fit |
|---|---|---|---|
| Privilege Escalation | T1068 | Exploitation for Privilege Escalation | Core technique: exploiting a kernel driver or win32k vulnerability for SYSTEM |
| Privilege Escalation | T1134.001 | Access Token Manipulation: Token Impersonation/Theft | Named pipe impersonation: ImpersonateNamedPipeClient → SYSTEM token |
| Privilege Escalation | T1134.002 | Access Token Manipulation: Create Process with Token | CreateProcessWithTokenW used to spawn a SYSTEM child process |
| Defense Evasion | T1055 | Process Injection | Some LPE techniques inject shellcode into a privileged process as a pivot step |
| Defense Evasion | T1014 | Rootkit | Post-SYSTEM, attackers may load a kernel driver to hide processes or network connections |
| Defense Evasion | T1562.001 | Impair Defenses: Disable or Modify Tools | SYSTEM privileges enable disabling or unloading EDR kernel components |
| Credential Access | T1003.001 | OS Credential Dumping: LSASS Memory | SYSTEM is required to open lsass.exe with PROCESSVMREAD; token theft enables this |
| Persistence | T1543.003 | Create or Modify System Process: Windows Service | SYSTEM allows installing a persistent kernel-level service or driver |
| Execution | T1059.001 | Command and Scripting Interpreter: PowerShell | SYSTEM-context PowerShell after LPE for unrestricted script execution |
| Discovery | T1082 | System Information Discovery | Post-SYSTEM enumeration of hardware, virtualisation, and security product state |
Conclusion and Takeaways
Windows kernel LPE is a moving battle between increasingly clever exploitation and increasingly aggressive mitigation. The strategic arc is clear: as Microsoft made code injection progressively impossible (DEP → SMEP → kCFG → HVCI → CET), exploitation migrated to data-only attacks that never run new code and simply rewrite the right kernel pointer — most often a process token. That single write, turning a low-privileged process into SYSTEM, remains the durable goal regardless of how many mitigations stand in the way.
For defenders, the practical priorities flow directly from how modern exploitation works: patch relentlessly (most LPEs are n-days against unpatched hosts), turn on VBS/HVCI and the vulnerable-driver blocklist (they force attackers off the easy paths), reduce reachable attack surface (win32k filtering, sandboxing), and invest in behavioural telemetry because the stealthiest kernel attacks leave no file to scan — only a process that suddenly, impossibly, became SYSTEM.