CVE-2024-21338 — Windows Kernel Elevation of Privilege Vulnerability
Executive Summary
None
Overview
Verified Attribution
Binary/function confirmed from a public vendor or researcher report; this pin overrides the keyword heuristic.
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H/E:F/RL:O/RC:C
EPSS Score
Affected Products
| Product | KB Article | Severity | Impact | Restart Required |
|---|---|---|---|---|
| Windows 10 Version 1809 for 32-bit Systems | 5034768 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 1809 for ARM64-based Systems | 5034768 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 1809 for x64-based Systems | 5034768 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 21H2 for 32-bit Systems | 5034763 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 21H2 for ARM64-based Systems | 5034763 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 21H2 for x64-based Systems | 5034763 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 22H2 for 32-bit Systems | 5034763 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 22H2 for ARM64-based Systems | 5034763 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 22H2 for x64-based Systems | 5034763 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 11 version 21H2 for ARM64-based Systems | 5034766 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 11 version 21H2 for x64-based Systems | 5034766 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 11 Version 22H2 for ARM64-based Systems | 5034765 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 11 Version 22H2 for x64-based Systems | 5034765 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 11 Version 23H2 for ARM64-based Systems | 5034765 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 11 Version 23H2 for x64-based Systems | 5034765 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows Server 2019 | 5034768 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows Server 2019 (Server Core installation) | 5034768 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows Server 2022 | 5034770 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows Server 2022 (Server Core installation) | 5034770 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows Server 2022, 23H2 Edition (Server Core installation) | 5034769 (Security Update) |
Important | Elevation of Privilege | Yes |
Patches
| Article | Type | Restart |
|---|---|---|
5034768 |
Security Update | Yes |
5034763 |
Security Update | Yes |
5034766 |
Security Update | Yes |
5034765 |
Security Update | Yes |
5034770 |
Security Update | Yes |
5034769 |
Security Update | Yes |
Patch Diff
Patch diff 10.0.22621.2506 -> 10.0.22621.3155 (ITW BYOVD/appid IOCTL fix; AipDeviceIoControlDispatch input validation)
| Function | Address | Change | Note |
|---|---|---|---|
__GSHandlerCheck |
1c0005c88 -> 1c0005f78 |
refcount, address | similarity 1.0 |
_guard_dispatch_icall |
1c0005f50 -> 1c0006240 |
refcount, address, calling | similarity 0.89 |
__security_check_cookie |
1c00010c0 |
refcount, calling | similarity 1.0 |
AipDeviceIoControlDispatch |
1c001df20 |
code, length, called | similarity 0.4 |
NTOSKRNL.EXE::RtlQueryFeatureConfiguration |
EXTERNAL:000000a7 -> EXTERNAL:000000a8 |
refcount, address, calling | similarity 1.0 |
wil_details_FeatureReporting_ReportUsageToService |
1c000217c -> 1c00015c0 |
refcount, address, calling | similarity 1.0 |
Root Cause Analysis
Root Cause Analysis — CVE-2024-21338
Summary
| Field | Value |
|---|---|
| CVE | CVE-2024-21338 |
| Binary | appid.sys (Windows AppLocker Driver) |
| Component | AipSmartHashImageFile IOCTL handler (IOCTL 0x22A018) |
| Bug Class | Untrusted Pointer Dereference (CWE-822) |
| Impact | Elevation of Privilege → SYSTEM (admin-to-kernel) |
| CVSS 3.1 | 7.8 (AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H) |
| Exploited ITW | Yes (Lazarus Group — FudModule rootkit, discovered by Avast) |
| Patch | February 2024 Patch Tuesday (KB5034765 Win11 23H2) |
Vulnerability Overview
The Windows AppLocker driver (appid.sys) exposes an IOCTL handler at code 0x22A018
that processes user-supplied input buffers without proper validation. When the IOCTL
is dispatched, the driver calls AipSmartHashImageFile with the user-mode
SystemBuffer. This chains through AppHashComputeFileHashesInternal to
AppHashComputeImageHashInternal, where a function pointer from the user-controlled
buffer is dereferenced and called in kernel context. Since the function pointer is
attacker-controlled (subject to kCFG validation), this allows calling arbitrary
kCFG-registered kernel functions with partially controlled arguments.
Root Cause — Untrusted Pointer Dereference in IOCTL Handler
The IOCTL Dispatch Path
User-mode application
→ NtDeviceIoControlFile(\Device\AppID, IOCTL=0x22A018, SystemBuffer)
→ AipSmartHashImageFile(SystemBuffer)
→ AppHashComputeFileHashesInternal(...)
→ AppHashComputeImageHashInternal(...) *** VULNERABLE ***
→ call [*(SystemBuffer+0x10)] with rcx = *(SystemBuffer+0x00)
The Vulnerable IOCTL Buffer Structure
The IOCTL 0x22A018 expects a buffer with the following layout:
// Windows 10 layout (0x18 bytes)
typedef struct {
PVOID FirstArg; // +0x00: pointer → dereferenced once → rcx
PVOID FileObjectPtr; // +0x08: FILE_OBJECT address (for refcount)
PVOID PtrToFunctionWrapper; // +0x10: pointer to CFG_FUNCTION_WRAPPER
} AIP_SMART_HASH_IMAGE_FILE_W10;
// Windows 11 layout (0x20 bytes)
typedef struct {
PVOID FirstArg; // +0x00
PVOID FileObjectPtr; // +0x08
PVOID PtrToFunctionWrapper; // +0x10
PVOID Unknown; // +0x18 (NULL)
} AIP_SMART_HASH_IMAGE_FILE_W11;
typedef struct {
PVOID FunctionPointer; // kCFG-valid function address
} CFG_FUNCTION_WRAPPER;
The Bug
In AppHashComputeImageHashInternal, the driver:
- Reads the
PtrToFunctionWrapperat offset +0x10 of SystemBuffer - Dereferences it to get a
FunctionPointer(must pass kCFG validation) - Calls the function with the first argument derived from
*(SystemBuffer+0x00)
The driver performs no validation that these pointers are safe or that the function pointer points to an appropriate callback. Any kCFG-valid kernel function can be called with a partially controlled first argument.
Attacker Control
| What | How |
|---|---|
| Function to call | Set PtrToFunctionWrapper → CFG_FUNCTION_WRAPPER.FunctionPointer to any kCFG-valid address |
| First argument (rcx) | FirstArg (+0x00) is a pointer that gets dereferenced once — the value at *FirstArg becomes rcx |
| FILE_OBJECT | FileObjectPtr (+0x08) must point to a valid FILE_OBJECT for ObfDereferenceObjectWithTag refcount decrement |
Exploitation Path (ITW — Lazarus Group)
Step 1: Leak Kernel Addresses
Use NtQuerySystemInformation(SystemHandleInformation) to leak:
- Current thread’s ETHREAD/KTHREAD kernel address (via pseudo-handle -2)
- Current process EPROCESS address
- SYSTEM process (PID 4) EPROCESS address
- FILE_OBJECT address (via a dummy file handle)
Use NtQuerySystemInformation(SystemModuleInformation) to get ntoskrnl.exe base address.
Step 2: Find kCFG Gadget
Load ntoskrnl.exe in user-mode (LoadLibraryExW) and scan the PAGE section for the
ExpProfileDelete function signature:
40 53 48 83 EC 20 48 83 79 30 00 48 8B D9 74
Calculate the kernel-space address: ntoskrnl_kernel_base + relative_offset.
Step 3: PreviousMode Modification
ExpProfileDelete is a kCFG-valid function that does:
void ExpProfileDelete(__int64 a1) {
if (*(QWORD*)(a1 + 0x30)) // check at offset +0x30
...
if (*(QWORD*)a1) // check at offset +0x00
ObfDereferenceObjectWithTag(*(PVOID*)a1, 0x66507845);
}
ObfDereferenceObjectWithTag performs:
lock xadd qword ptr [rsi-0x30], rbx ; atomically decrement refcount
By setting FirstArg to (KTHREAD + 0x232 + 0x30), the chain:
AppHashComputeImageHashInternalcallsExpProfileDelete(*(FirstArg))ExpProfileDeleteskips the firstif(offset +0x30 is zero in carefully crafted input)ExpProfileDeletecallsObfDereferenceObjectWithTag(*(*(FirstArg)), tag)- The
lock xadd [rsi-0x30]decrements the value atKTHREAD+0x232(PreviousMode) - PreviousMode changes from 1 (UserMode) to 0 (KernelMode)
Step 4: Arbitrary Kernel R/W
With PreviousMode=0, NtWriteVirtualMemory and NtReadVirtualMemory skip user/kernel
address validation. The attacker can now read and write arbitrary kernel memory.
Step 5: Token Swap
// Copy SYSTEM token to current process
NtWriteVirtualMemory(GetCurrentProcess(),
(EPROCESS + 0x4b8), // current process Token field
(SYSTEM_EPROCESS + 0x4b8), // SYSTEM process Token field
sizeof(ULONGLONG), &bytes);
Step 6: Restore and Spawn
// Restore PreviousMode to 1 (CRITICAL — else BSOD on process creation)
char restore = 1;
NtWriteVirtualMemory(GetCurrentProcess(),
(KTHREAD + 0x232), &restore, sizeof(CHAR), &bytes);
// Now spawn cmd.exe with SYSTEM privileges
system("cmd.exe");
Key Offsets (Windows 23H2, build 22631)
| Structure | Offset | Field |
|---|---|---|
| KTHREAD | +0x232 | PreviousMode |
| EPROCESS | +0x4b8 | Token |
| ExpProfileDelete | ntoskrnl+0xA01FD0 | kCFG gadget (build-specific) |
Patch Analysis
The patch in appid.sys (February 2024, KB5034765) adds validation in the IOCTL 0x22A018 handler path:
- Buffer content validation:
AipSmartHashImageFilenow validates that pointers within the SystemBuffer reference legitimate kernel objects before proceeding - Pointer validation: The driver verifies the function pointer wrapper points to an expected callback, not an arbitrary kCFG-valid function
- Access control: Tighter checks on who can send this IOCTL to the AppLocker device
In BinDiff, AipSmartHashImageFile and AppHashComputeImageHashInternal show significant
new validation basic blocks (the functions grew substantially in the patched version).
Reachability
- Attack vector: Local — requires code execution on the target
- Privileges required: Low (standard user can open
\Device\AppID) - User interaction: None
- Prerequisites:
- AppLocker / Smart App Control service running (AppIDSvc)
- appid.sys driver loaded
- On many enterprise systems, AppLocker is enabled by default via Group Policy
- Attack surface:
- Any local process can open a handle to
\\?\AppIDor\Device\AppID - The IOCTL 0x22A018 is accessible without special privileges
- Any local process can open a handle to
Detection
YARA — Exploit Artifacts
rule CVE_2024_21338_Exploit_Indicators
{
meta:
description = "Detects compiled exploit artifacts for CVE-2024-21338 appid.sys"
cve = "CVE-2024-21338"
author = "OnlyFm252"
strings:
$device1 = "\\Device\\AppID" wide
$device2 = "\\\\?\\AppID" ascii
$ioctl = { 18 A0 22 00 }
$pattern = { 40 53 48 83 EC 20 48 83 79 30 00 48 8B D9 74 }
$ntqsi = "NtQuerySystemInformation" ascii
$ntdio = "NtDeviceIoControlFile" ascii
condition:
uint16(0) == 0x5A4D and
($device1 or $device2) and
$ioctl and
($pattern or ($ntqsi and $ntdio))
}
Sigma — Suspicious AppLocker Driver IOCTL Access
title: CVE-2024-21338 AppLocker Driver Exploitation Indicators
id: a7b8c9d0-e1f2-3456-7890-abcdef012345
status: experimental
description: >
Detects potential exploitation of CVE-2024-21338 via suspicious handle
creation to the AppID device and subsequent privilege escalation indicators.
author: OnlyFm252
date: 2026/07/26
references:
- https://hakaisecurity.io/cve-2024-21338-from-admin-to-kernel-through-token-manipulation-and-windows-kernel-exploitation/research-blog/
- https://hackyboiz.github.io/2025/01/12/l0ch/bypassing-kernel-mitigation-part2/en/
- https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-21338
logsource:
product: windows
category: process_creation
detection:
selection_parent:
ParentImage|endswith:
- '\cmd.exe'
- '\powershell.exe'
selection_integrity:
IntegrityLevel: 'System'
filter_known_parents:
ParentImage|startswith:
- 'C:\Windows\System32\'
- 'C:\Windows\SysWOW64\'
ParentUser|contains: 'SYSTEM'
condition: selection_parent and selection_integrity and not filter_known_parents
level: high
tags:
- attack.privilege_escalation
- attack.t1068
- cve.2024.21338
Sysmon Configuration
<Sysmon schemaversion="4.90">
<EventFiltering>
<!-- Event 1: Detect new processes with SYSTEM integrity from non-system parents -->
<ProcessCreate onmatch="include">
<IntegrityLevel condition="is">System</IntegrityLevel>
</ProcessCreate>
<!-- Event 7: Detect appid.sys driver load (ensure it's loaded = attack surface exists) -->
<DriverLoad onmatch="include">
<ImageLoaded condition="end with">\appid.sys</ImageLoaded>
</DriverLoad>
<!-- Event 10: Detect suspicious handle access to lsass/csrss after token swap -->
<ProcessAccess onmatch="include">
<TargetImage condition="end with">\lsass.exe</TargetImage>
<GrantedAccess condition="is">0x1F0FFF</GrantedAccess>
</ProcessAccess>
</EventFiltering>
</Sysmon>
References
Attack Path
BYOVD-style kernel code execution - appid.sys dereferences a function pointer supplied in the IOCTL input buffer
Derived from the patch delta: the checks added by the vendor identify which fields crossed a trust boundary unvalidated. Reachability and privilege are taken from the call chain in the RCA report.
Exploits & PoC
8 public PoCsUnverified third-party code
Public proof-of-concept repositories aggregated from PoC-in-GitHub. They are not reviewed and may be incomplete, non-functional, or malicious — inspect the code before running anything.
| Repository | Stars | Published | Description |
|---|---|---|---|
| hakaioffsec/CVE-2024-21338 | 335 | 2024-04-13 | Local Privilege Escalation from Admin to Kernel vulnerability on Windows 10 and Windows 11 operating systems with HVCI enabled. |
| Crowdfense/CVE-2024-21338 | 80 | 2024-07-29 | Windows AppLocker Driver (appid.sys) LPE |
| tykawaii98/CVE-2024-21338_PoC | 40 | 2024-06-23 | |
| Zombie-Kaiser/CVE-2024-21338-x64-build- | 7 | 2024-05-18 | Local Privilege Escalation from Admin to Kernel vulnerability on Windows 10 and Windows 11 operating systems with HVCI enabled. |
| MistyFir/CVE-2024-21338-Exploit | 7 | 2026-03-11 | |
| UMU618/CVE-2024-21338 | 2 | 2024-04-17 | Fork of https://github.com/hakaioffsec/CVE-2024-21338 |
| wusijie/CVE-2024-21338-1 | 2 | 2024-05-05 | PoC for the Untrusted Pointer Dereference in the appid.sys driver |
| hackyboiz/kcfg-bypass | 2 | 2025-01-12 | kcfg bypass example - CVE-2024-21338 |
Detection Rules
Acknowledgments
Jan Vojtěšek with Avast