CVE-2026-21241 — Windows Ancillary Function Driver for WinSock Elevation of Privilege Vulnerability
Executive Summary
Use after free in Windows Ancillary Function Driver for WinSock allows an authorized attacker to elevate privileges locally.
Overview
CVSS Vector
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H/E:U/RL:O/RC:C
EPSS Score
Affected Products
| Product | KB Article | Severity | Impact | Restart Required |
|---|---|---|---|---|
| Windows 11 Version 23H2 for ARM64-based Systems | 5075941 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 11 Version 23H2 for x64-based Systems | 5075941 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 11 Version 24H2 for ARM64-based Systems 5077181 (Security Update) 5077212 (Security Hotpatch Update) Important Elevation of Privilege 5073379 Base: 7.0 Temporal: 6.1 Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H/E:U/RL:O/RC:C 10.0.26100.7840 10.0.26100.7781 Yes None Windows 11 Version 24H2 for x64-based Systems 5077212 (Security Hotpatch Update) 5077181 (Security Update) Important Elevation of Privilege 5074109 Base: 7.0 Temporal: 6.1 Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H/E:U/RL:O/RC:C 10.0.26100.7781 10.0.26100.7840 Yes None Windows 11 Version 25H2 for ARM64-based Systems 5077181 (Security Update) 5077212 (Security Hotpatch Update) Important Elevation of Privilege 5074109 Base: 7.0 Temporal: 6.1 Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H/E:U/RL:O/RC:C 10.0.26200.7840 10.0.26200.7781 Yes None Windows 11 Version 25H2 for x64-based Systems 5077181 (Security Update) 5077212 (Security Hotpatch Update) Important Elevation of Privilege 5074109 Base: 7.0 Temporal: 6.1 Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H/E:U/RL:O/RC:C 10.0.26200.7840 10.0.26200.7781 Yes None Windows 11 Version 26H1 for ARM64-based Systems | 5077179 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 11 version 26H1 for x64-based Systems | 5077179 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows Server 2022 5075906 (Security Update) 5075943 (Security Hotpatch Update) Important Elevation of Privilege 5073457 Base: 7.0 Temporal: 6.1 Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H/E:U/RL:O/RC:C 10.0.20348.4773 10.0.20348.4711 Yes None Windows Server 2022 (Server Core installation) 5075906 (Security Update) 5075943 (Security Hotpatch Update) Important Elevation of Privilege 5073457 Base: 7.0 Temporal: 6.1 Vector: CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H/E:U/RL:O/RC:C 10.0.20348.4773 10.0.20348.4711 Yes None Windows Server 2022, 23H2 Edition (Server Core installation) | 5075897 (Security Update) |
Important | Elevation of Privilege | Yes |
Patches
| Article | Type | Restart |
|---|---|---|
5075941 |
Security Update | Yes |
5077179 |
Security Update | Yes |
5075897 |
Security Update | Yes |
Patch Diff
Patch diff 10.0.26100.7623 -> 10.0.26100.7824
| Function | Address | Change | Note |
|---|---|---|---|
AfdBReceive |
14003f640 -> 14003e810 |
code, length, address, called | similarity 0.63 |
NTOSKRNL.EXE::MmMapLockedPages |
EXTERNAL:000000d5 -> EXTERNAL:000000d6 |
refcount, address | similarity 1.0 |
AfdNotifyPostEvents |
14005364c -> 140053cac |
code, length, address, called | similarity 0.39 |
memcpy |
140074980 -> 140075200 |
refcount, address | similarity 1.0 |
AfdFastDatagramReceive |
140033850 -> 140032940 |
code, length, address, called | similarity 0.6 |
AfdTdiCreateAO |
14002c650 -> 14002b6a0 |
code, length, sig, address, called | similarity 0.92 |
AfdNotifyDestroyContext |
14005349c -> 140053adc |
code, length, address, called | similarity 0.67 |
AfdCleanupCore |
140013870 -> 1400135a0 |
code, length, address, called | similarity 0.67 |
AfdTransmitPackets |
140043d30 -> 140044100 |
code, length, address, called | similarity 0.41 |
AfdBCommonChainedReceiveEventHandler |
14001a380 -> 140019340 |
code, length, address, called | similarity 0.98 |
AfdSuperAccept |
14002a310 -> 140029300 |
code, length, address, called | similarity 0.26 |
AfdSanConnectHandler |
14005c570 -> 14005cc50 |
code, length, address, called | similarity 0.29 |
AfdRestartSuperAcceptGetAddress |
14004a7e0 -> 14004ae30 |
code, length, address, called | similarity 0.98 |
AfdCloseCore |
140006ac8 -> 1400150c0 |
code, length, address, called | similarity 0.17 |
wil_details_IsEnabledFallback |
14004b4c8 -> 14004bab4 |
refcount, address, calling | similarity 1.0 |
AfdReceiveDatagram |
14003dec0 -> 14003d010 |
code, length, address, called | similarity 0.67 |
AfdSanAcceptCore |
140044f40 -> 1400453bc |
code, length, address, called | similarity 0.19 |
__security_check_cookie |
140074850 -> 1400750c0 |
refcount, address, calling | similarity 1.0 |
AfdNotifyProcessRegistration |
14005390c -> 140053fb8 |
code, length, address, called | similarity 0.48 |
AfdExtractAfdSendMsgInfo |
1400422a0 -> 1400415b0 |
code, length, address, called | similarity 0.41 |
__C_specific_handler |
140049fdd -> 14004a62d |
refcount, address | similarity 0.89 |
AfdCompleteBufferedSendsUnlock |
140005230 |
code, length, called | similarity 0.48 |
AfdFastConnectionSend |
140032e60 -> 140031ef0 |
code, length, address, called | similarity 0.7 |
AfdFastConnectionReceive |
140031ef0 -> 140030f00 |
code, length, address, called | similarity 0.5 |
__GSHandlerCheck_SEH |
1400747b4 -> 140075024 |
refcount, address | similarity 1.0 |
NTOSKRNL.EXE::ExFreePoolWithTag |
EXTERNAL:000000f5 -> EXTERNAL:000000f6 |
refcount, address, calling | similarity 1.0 |
AfdQueryHandles |
14003a350 -> 140039510 |
code, length, sig, address, called | similarity 0.63 |
AfdBind |
14002acb0 -> 140029c70 |
code, length, address, called | similarity 0.1 |
AfdFastDatagramSend |
140034280 -> 1400333d0 |
code, length, address, called | similarity 0.41 |
Feature_2829529401__private_IsEnabledDeviceUsageNoInline |
14004acf0 -> 14004c900 |
name, fullname, refcount, sig, address, calling, called | similarity 0.71 |
Feature_447951161__private_IsEnabledDeviceUsageNoInline |
14004acf0 -> 14004d200 |
name, fullname, refcount, sig, address, calling, called | similarity 0.71 |
Feature_TCPIP_2025_Wave4_AfdTransmit_MSRC__private_IsEnabledDeviceUsageNoInline |
14004acf0 -> 14005bd78 |
name, fullname, refcount, sig, address, calling, called | similarity 0.71 |
Feature_3923194169__private_IsEnabledDeviceUsageNoInline |
14004acf0 -> 140060620 |
name, fullname, refcount, sig, address, calling, called | similarity 0.71 |
Feature_2829529401__private_IsEnabledDeviceUsageNoInline |
14004c310 -> 14004c900 |
name, fullname, refcount, sig, address, calling, called | similarity 0.71 |
Feature_447951161__private_IsEnabledDeviceUsageNoInline |
14004c310 -> 14004d200 |
name, fullname, refcount, sig, address, calling, called | similarity 0.71 |
Feature_TCPIP_2025_Wave4_AfdTransmit_MSRC__private_IsEnabledDeviceUsageNoInline |
14004c310 -> 14005bd78 |
name, fullname, refcount, sig, address, calling, called | similarity 0.71 |
Feature_3923194169__private_IsEnabledDeviceUsageNoInline |
14004c310 -> 140060620 |
name, fullname, refcount, sig, address, calling, called | similarity 0.71 |
Feature_447951161__private_IsEnabledDeviceUsageNoInline |
140056c40 -> 14004d200 |
name, fullname, refcount, sig, address, calling, called | similarity 0.71 |
Feature_3923194169__private_IsEnabledDeviceUsageNoInline |
140056c40 -> 140060620 |
name, fullname, refcount, sig, address, calling, called | similarity 0.71 |
Root Cause Analysis
CVE-2026-21241 — afd.sys AfdNotifyPostEvents / AfdNotifyDestroyContext Use-After-Free
Summary
| Product | Microsoft Windows — afd.sys (Ancillary Function Driver for WinSock) |
|---|---|
| Vendor | Microsoft Corporation |
| Severity | CVSS v3.1 7.0 (High) |
| CVSS Vector | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H (MSRC) |
| CVE Title | Windows Ancillary Function Driver for WinSock Elevation of Privilege Vulnerability |
| CWE | CWE-416 (Use After Free); race-required (CWE-362) |
| Affected Versions | Windows 10/11 and Server with socket state notifications (build 20348+) |
| Tested Version | Windows 11 24H2 — afd.sys 10.0.26100.7623 (pre, KB5074109) vs 10.0.26100.7824 (post, KB5077181) |
| Impact | Local EoP — low-privilege user triggers UAF on a kernel pool allocation → SYSTEM |
| Exploitability (MSRC) | “Exploitation More Likely” |
| PoC Available | Yes — public PoC (see below); blue-team variant poc_cve_2026_21241.c here |
| Patch Date | February 2026 Patch Tuesday — KB5077181 |
| Discovered / reported by | Souhail Hammou (@Dark_Puzzle) |
Root Cause
Windows’ socket state notifications API (ProcessSocketNotifications,
build 20348+) lets a user-mode program register an I/O completion port (IOCP)
to receive socket state-change events. Internally, afd.sys posts these
events using I/O mini-completion packets — small pool allocations that
can carry a driver callback and context, dequeued by
IoRemoveIoCompletion/GetQueuedCompletionStatus.
The lifecycle rule: a driver that supplies its own packet must not free it
before it has been dequeued (or cancelled via
IoCancelMiniCompletionPacket). afd.sys extends the packet with a
NotifyStatus field used in two places:
AfdNotifyPostEventsqueues the packet to the IOCP (IoSetIoCompletionEx3). When the socket operation’sIoStatusInformation == 0, the enqueued packet legitimately carriesNotifyStatus == 0.AfdNotifyDestroyContext, reached fromIRP_MJ_CLEANUP(i.e. when the last socket handle is closed), only attemptsIoCancelMiniCompletionPacketwhenNotifyStatus != 0. WhenNotifyStatus == 0it skips cancellation andExFreePoolWithTags the packet while it may still be enqueued.
Any later dequeue — by AfdNotifyRemoveIoCompletion inside the still-running
ProcessSocketNotifications IOCTL on another thread, or by a user thread in
GetQueuedCompletionStatus — dereferences the freed packet: UAF on a
paged/non-paged pool allocation, with the freed object re-usable via
standard pool-grooming.
The patch (verified in our ghidriff diff, 7623 → 7824)
Behind WIL feature flag Feature_447951161, AfdNotifyDestroyContext no
longer performs the unconditional free:
// post-patch 10.0.26100.7824
if (uVar2 == 0) { // Feature_447951161 gated
ExFreePoolWithTag(param_2, 0x4e646641);
}
AfdNotifyPostEvents was modified in the same flag area. Microsoft also
added a new AFDETW_TRACECLOSE ETW helper on the AfdCloseCore path —
close-path telemetry that did not exist pre-patch.
Reaching the bug — userspace call flow
Fully client-reachable from any low-privilege process; no special privileges, no Server SKU, no RDMA:
ws2_32!socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
kernel32!CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0)
│
▼ [Thread 1]
ws2_32!ProcessSocketNotifications(iocp, 1, ®istration, 1, 1, &entry, &count)
│ registration.eventFilter = SOCK_NOTIFY_REGISTER_EVENT_OUT
│ registration.operation = SOCK_NOTIFY_OP_REMOVE
│ registration.triggerFlags = SOCK_NOTIFY_TRIGGER_LEVEL | SOCK_NOTIFY_TRIGGER_PERSISTENT
│ (these flags produce notifications on a NON-bound, NON-connected socket)
▼
mswsock → ntdll!NtDeviceIoControlFile(afd_endpoint, IOCTL 0x12127)
▼
afd!AfdNotifySock
└─► afd!AfdNotifyPostEvents ── IoSetIoCompletionEx3 ── packet enqueued, NotifyStatus == 0
│ (fresh socket ⇒ status 0)
▼ [Thread 2, racing]
ws2_32!closesocket(sock) ──► IRP_MJ_CLEANUP
▼
afd!AfdCleanupCore ──► afd!AfdNotifyDestroyContext
│ NotifyStatus == 0 ⇒ NO IoCancelMiniCompletionPacket
│ ExFreePoolWithTag(packet) ← freed while enqueued — BUG
▼ [Thread 1 resumes / optional Thread 3 GetQueuedCompletionStatus]
afd!AfdNotifyRemoveIoCompletion / IoRemoveIoCompletion
▼
dequeue + dereference of freed packet → bugcheck (varies: freed/re-purposed pool)
| Element | Value |
|---|---|
| Userspace API | ProcessSocketNotifications (ws2_32), CreateIoCompletionPort, closesocket, optional GetQueuedCompletionStatus |
| IOCTL | 0x12127 (AfdNotifySock) |
| Vulnerable functions | afd!AfdNotifyPostEvents, afd!AfdNotifyDestroyContext (called from AfdCleanupCore on IRP_MJ_CLEANUP) |
| Race | notify IOCTL thread vs closesocket thread; reliability improved with a third dequeue thread |
| Privileges | none (standard local user) |
PoC
poc_cve_2026_21241.c — blue-team crash PoC adapted from the public PoC (Souhail Hammou), with added heartbeat/progress output so a SOC can distinguish “exploit running” from “system crashed”. Expected result on a pre-KB5077181 build: bugcheck within seconds–minutes (various stop codes; the kernel dereferences freed or re-purposed pool). On patched builds it spins harmlessly.
Build (MSVC):
cl.exe /W4 /O2 /D_CRT_SECURE_NO_WARNINGS poc_cve_2026_21241.c /link ws2_32.lib
Run in a VM with verifier /standard /driver afd.sys for a faster, cleaner
bugcheck, and with crash dumps enabled (MEMORY.DMP) for IR material.
Detection engineering
- API telemetry:
ProcessSocketNotificationshas extremely low legitimate prevalence (introduced build 20348, used mostly by RIO-style high-scale servers). Alert on any process calling it, especially combined with rapidclosesocketloops. The PoC’s tight create/close/IOCP loop is also a process-behavior signal (highNtCreateFile/IOCP churn on afd endpoints). - ETW: post-patch afd.sys emits
AFDETW_TRACECLOSEevents on the close path — these exist only on patched builds and can be used both for fleet patch-level verification and as a trigger point for hunting. - Crash forensics: bugchecks with stacks through
afd!AfdNotifyRemoveIoCompletion,afd!AfdNotifyDestroyContext,nt!IoRemoveIoCompletionon pre-KB5077181 builds; pool tag0x4e646641(“AfdN”) in!pool/verifier output. - Sigma (process creation/behavioral proxy): hunt for non-browser,
non-server processes making ≥1 call into
ProcessSocketNotifications(ETW Threat Intelligence / API logging), or EDR rules onws2_32!ProcessSocketNotificationsimport usage in unsigned binaries.
References
Attack Path
A socket-notification completion packet is freed while still enqueued, then dereferenced on dequeue
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.