Important CVSS 7.8 EPSS 0.65417 🔬 Patch diffed 2023-01 archive

Executive Summary

None

Overview

7.8
CVSS HIGH
Important
MS Severity
Not Exploited
MS Exploit Status
More Likely
MS Exploit Likelihood
Category Elevation of Privilege
Released Jan 10 2023
Last Updated Jan 10 2023
Publicly Disclosed No
CISA KEV Not Listed
Known Exploits None Known
EPSS Score 0.65417 — 0.99192 percentile
NVD CVSS 7.8 HIGH — matches MSRC

CVSS Vector

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H/E:U/RL:O/RC:C
ATTACK VECTOR
Local
ATTACK COMPLEXITY
Low
PRIVILEGES REQUIRED
Low
USER INTERACTION
None
SCOPE
Unchanged
CONFIDENTIALITY
High
INTEGRITY
High
AVAILABILITY
High
EXPLOIT CODE MATURITY
Unproven
REMEDIATION LEVEL
Official Fix
REPORT CONFIDENCE
Confirmed
Temporal Score: 6.8

EPSS Score

0.65417
probability of exploitation in the next 30 days
0.99192 percentile - updated 2026-08-14
View on FIRST.org

Affected Products

6 affected products
Product KB Article Severity Impact Restart Required
Windows 11 version 21H2 for ARM64-based Systems 5022287 (Security Update) Important Elevation of Privilege Yes
Windows 11 version 21H2 for x64-based Systems 5022287 (Security Update) Important Elevation of Privilege Yes
Windows 11 Version 22H2 for ARM64-based Systems 5022303 (Security Update) Important Elevation of Privilege Yes
Windows 11 Version 22H2 for x64-based Systems 5022303 (Security Update) Important Elevation of Privilege Yes
Windows Server 2022 5022291 (Security Update) Important Elevation of Privilege Yes
Windows Server 2022 (Server Core installation) 5022291 (Security Update) Important Elevation of Privilege Yes

Patches

3 patches
Article Type Restart
5022287 Security Update Yes
5022303 Security Update Yes
5022291 Security Update Yes

Patch Diff

ghidriff · afd.sys (KB5022303)

Patch diff 10.0.22621.608 -> 10.0.22621.1105 (single-function fix: AfdNotifyRemoveIoCompletion PreviousMode check)

Pre-patch version 10.0.22621.608
Post-patch version 10.0.22621.1105
Function Address Change Note
NTOSKRNL.EXE::ProbeForWrite EXTERNAL:00000041 refcount similarity 1.0
AfdNotifyRemoveIoCompletion 1c006f92c code, length similarity 1.0
View full diff report View RCA report Download PoC

Root Cause Analysis

Root Cause Analysis — CVE-2023-21768

Summary

Field Value
CVE CVE-2023-21768
Binary afd.sys (Windows Ancillary Function Driver for WinSock)
Component AfdNotifyRemoveIoCompletion — called from AfdNotifySock (IOCTL 0x12127)
Bug Class Missing PreviousMode Validation / Arbitrary Write-Where (CWE-269)
Impact Elevation of Privilege — Local to SYSTEM
CVSS 3.1 7.8 (AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H)
Exploited ITW Yes — 360 IceSword Lab discovered ITW sample (January 2023)
Patch January 2023 Patch Tuesday (KB5022303 Win11 22H2)

BinDiff Summary

Versions Compared

  • Pre-patch: afd.sys 10.0.22621.608 (December 2022)
  • Post-patch: afd.sys 10.0.22621.1105 (January 2023)

Changed Functions

Only one function was modified between the two versions:

Function Change Type Description
AfdNotifyRemoveIoCompletion Code (PreviousMode check added) Added conditional branch: if PreviousMode != 0 (user-mode), call ProbeForWrite on the target pointer before writing

The fact that only a single function changed made root cause identification trivial from the BinDiff output.

Vulnerability Overview

The Windows AFD module is the kernel entry point for the Winsock API. IOCTL 0x12127 dispatches to AfdNotifySock, which is the last entry in the AfdImmediateCallDispatch table — indicating it was recently added code. AfdNotifySock calls AfdNotifyRemoveIoCompletion, which writes a value to a pointer from the user’s input structure without validating that the pointer resides in user-mode address space.

Root Cause — Missing PreviousMode Check

The Vulnerable Code (pre-patch)

In AfdNotifyRemoveIoCompletion, the function writes a value to a pointer at field_0x18 of the input structure unconditionally:

// Pre-patch: No PreviousMode check
// 'pStruct' is the user-supplied AFD_NOTIFYSOCK_STRUCT
// field_0x18 contains a pointer (attacker-controlled)
// 'writeValue' comes from KeRemoveQueueEx return value (0x1)

*pStruct->field_0x18 = writeValue;  // ARBITRARY WRITE — no address validation

The Patch (post-patch)

// Post-patch: PreviousMode check added
if (PreviousMode != KernelMode) {
    // User-mode caller — validate pointer is in user space
    ProbeForWrite(pStruct->field_0x18, sizeof(ULONG), sizeof(ULONG));
}
*pStruct->field_0x18 = writeValue;

The patch adds a check: if PreviousMode is non-zero (indicating the syscall originated from user mode), ProbeForWrite is called to ensure the target pointer falls within the user-mode address range. If the pointer is a kernel address, ProbeForWrite raises an exception, preventing the write.

The Write Value

The value written to the target address comes from IoRemoveCompletion → KeRemoveQueueEx. This return value equals the number of items removed from the I/O completion queue. By calling NtSetIoCompletion once before triggering the vulnerability, the write value is 0x1. Additional NtSetIoCompletion calls can increment this value arbitrarily.

Call Chain to Vulnerability

User mode: DeviceIoControl(hSocket, IOCTL_AFD_NOTIFY_SOCK, ...)
                │
                ▼
afd!AfdNotifySock                    [IOCTL 0x12127 dispatch]
    │
    ├── Check: InputBufferLength == 0x30
    ├── Check: ObReferenceObjectByHandle(pStruct->field_0x00) → IoCompletionObject
    ├── Loop:  Copy data from user-mode pointers in struct
    │
    └── Call: AfdNotifyRemoveIoCompletion(PreviousMode, ?, pStruct)
                │
                ├── Check: pStruct->dwLen != 0
                ├── ProbeForWrite(pStruct->pData2, dwLen * 0x20, ...)
                ├── IoRemoveCompletion(IoCompletionObject, ..., timeout)
                │       └── KeRemoveQueueEx → returns count (write value)
                │
                └── BUG: *pStruct->field_0x18 = writeValue
                         ↑ No PreviousMode check on this pointer

AFD_NOTIFYSOCK_STRUCT Layout

typedef struct _AFD_NOTIFYSOCK_STRUCT {
    HANDLE  hIoCompletion;   // +0x00: Valid IoCompletionObject handle
    PVOID   field_0x08;      // +0x08: User-mode pointer (validated)
    PVOID   field_0x10;      // +0x10: User-mode pointer (validated)
    PVOID   pWriteTarget;    // +0x18: WRITE TARGET — kernel address for exploit
    ULONG   dwCount;         // +0x20: Loop counter (set to 1)
    ULONG   dwLen;           // +0x24: Must be non-zero (set to 1)
    PVOID   pData2;          // +0x28: User-mode pointer for ProbeForWrite
} AFD_NOTIFYSOCK_STRUCT;     // Total size: 0x30 bytes

Key Constraints

  1. hIoCompletion must be a valid IoCompletionObject handle (created via NtCreateIoCompletion)
  2. At least one completion record must be queued (via NtSetIoCompletion) for IoRemoveCompletion to succeed
  3. field_0x08 and field_0x10 must point to valid user-mode memory
  4. dwLen must be non-zero (so ProbeForWrite size = dwLen * 0x20)
  5. pData2 must be a valid user-mode address
  6. Total struct size must be exactly 0x30 bytes

Exploitation — I/O Ring Primitive

Overview

IBM X-Force Red used the arbitrary write-where (value = 0x1 at any kernel address) to corrupt a kernel IORING_OBJECT structure, achieving full arbitrary kernel R/W.

IORING_OBJECT Corruption

IORING_OBJECT (kernel structure)
┌────────────────────────────────┐
│  ... (other fields) ...        │
│  +0x??: RegBuffersCount = 0    │ ← Trigger 1: write 0x1 here
│  +0x??: RegBuffers = NULL      │ ← Trigger 2: write 0x1 here
│  ... (other fields) ...        │    (address 0x0000000100000000)
└────────────────────────────────┘

After two triggers:
  RegBuffersCount = 1
  RegBuffers = 0x0000000100000000 (user-allocatable address)

Step-by-Step

  1. Create I/O Ring: Call CreateIoRing → get HIORING handle and kernel IORING_OBJECT address
  2. Leak kernel address: Use NtQuerySystemInformation or similar to find IORING_OBJECT in kernel
  3. First trigger: Write 0x1 to IORING_OBJECT.RegBuffersCount
  4. Second trigger: Write 0x1 to IORING_OBJECT.RegBuffers (sets it to 0x0000000100000000)
  5. Allocate user page: VirtualAlloc at address 0x100000000
  6. Place forged entries: Write IOP_MC_BUFFER_ENTRY structures at that address
  7. Arbitrary kernel read: BuildIoRingWriteFile with kernel address → reads kernel memory to file
  8. Arbitrary kernel write: BuildIoRingReadFile with kernel address → writes file data to kernel memory
  9. Token swap: Read SYSTEM (PID 4) token, overwrite current process token → SYSTEM shell

Why SMAP Doesn’t Protect

Windows 11 does not support Supervisor Mode Access Prevention (SMAP). This allows the kernel to freely read from and write to user-mode pages, making the I/O Ring primitive possible. On Linux (which supports SMAP), the equivalent io_uring attack would crash the system.

ITW Exploitation

360 IceSword Lab discovered an ITW sample in January 2023 that used ProcessSocketNotifications (the corresponding Winsock API) instead of direct DeviceIoControl to reach the vulnerable code. The ITW technique used the write value (incremented via multiple NtSetIoCompletion calls) to directly modify privilege counts, rather than the I/O Ring approach.

Detection

YARA — Exploit Artifacts

rule CVE_2023_21768_Exploit_Indicators
{
    meta:
        description = "Detects compiled exploit artifacts for CVE-2023-21768 afd.sys LPE"
        cve         = "CVE-2023-21768"
        author      = "OnlyFm252"

    strings:
        $ioctl_code  = { 27 21 01 00 }
        $s_ntcreateio = "NtCreateIoCompletion" ascii wide
        $s_ntsetio    = "NtSetIoCompletion" ascii wide
        $s_ioring     = "CreateIoRing" ascii wide
        $s_afd        = "\\Device\\Afd" ascii wide
        $s_proc_sock  = "ProcessSocketNotifications" ascii wide

        $hex_regbuf_count = { 52 65 67 42 75 66 66 65 72 73 43 6F 75 6E 74 }
        $ntdll_import = "ntdll" ascii wide nocase

    condition:
        uint16(0) == 0x5A4D and
        (
            ($ioctl_code and ($s_ntcreateio or $s_ntsetio)) or
            ($s_afd and ($s_ntcreateio or $s_ntsetio) and $s_ioring) or
            ($s_proc_sock and ($s_ntcreateio or $s_ntsetio))
        )
}

Sigma — Suspicious AFD Socket Notification Activity

title: CVE-2023-21768 AFD WinSock LPE Exploitation Attempt
id: a1b2c3d4-e5f6-7890-abcd-ef0123456789
status: experimental
description: >
    Detects potential exploitation of CVE-2023-21768 via suspicious process
    behavior patterns — non-system process loading ntdll for NtCreateIoCompletion
    followed by privilege escalation indicators.    
author: OnlyFm252
date: 2026/07/26
references:
    - https://www.ibm.com/think/x-force/patch-tuesday-exploit-wednesday-pwning-windows-ancillary-function-driver-winsock
    - https://github.com/xforcered/Windows_LPE_AFD_CVE-2023-21768
    - https://msrc.microsoft.com/update-guide/vulnerability/CVE-2023-21768
logsource:
    product: windows
    category: process_creation
detection:
    selection_parent:
        ParentIntegrityLevel|contains:
            - 'Medium'
            - 'Low'
    selection_child:
        IntegrityLevel: 'System'
        User|contains: 'SYSTEM'
    timeframe: 5s
    condition: selection_parent | near selection_child
level: high
tags:
    - attack.privilege_escalation
    - attack.t1068
    - cve.2023.21768

Sysmon Configuration

<Sysmon schemaversion="4.90">
  <EventFiltering>
    <!-- Event 1: Detect processes that may exploit CVE-2023-21768 -->
    <ProcessCreate onmatch="include">
      <!-- Detect known PoC filenames -->
      <Image condition="contains any">CVE-2023-21768;afd_exploit;WinSock_LPE</Image>
    </ProcessCreate>

    <!-- Event 7: Detect ntdll loading patterns (NtCreateIoCompletion is in ntdll) -->
    <ImageLoad onmatch="include">
      <ImageLoaded condition="end with">\afd.sys</ImageLoaded>
    </ImageLoad>

    <!-- Event 13: Detect I/O Ring creation artifacts -->
    <RegistryEvent onmatch="include">
      <TargetObject condition="contains">IoRing</TargetObject>
    </RegistryEvent>

    <!-- Event 1: Detect privilege escalation from medium to SYSTEM -->
    <ProcessCreate onmatch="include">
      <IntegrityLevel condition="is">System</IntegrityLevel>
      <ParentCommandLine condition="contains any">cmd;powershell;exploit</ParentCommandLine>
    </ProcessCreate>
  </EventFiltering>
</Sysmon>

References

Attack Path

Local EoP to SYSTEM via an arbitrary kernel write in AfdNotifySock - PreviousMode never checked on the output pointer

Attack path for CVE-2023-21768 Local EoP to SYSTEM via an arbitrary kernel write in AfdNotifySock - PreviousMode never checked on the output pointer 01 — ENTRY Attacker opens a socket and issues the AFD notify IOCTL DeviceIoControl(hSocket, IOCTL_AFD_NOTIFY_SOCK 0x12127). Winsock is reachable by any unprivileged user; afd.sys is always loaded. 02 — CONTROLLED INPUT Supplies a 0x30-byte AFD_NOTIFYSOCK_STRUCT with a kernel address at +0x18 AfdNotifySock validates InputBufferLength == 0x30 and resolves the completion handle, but field_0x18 is copied through as an output pointer under attacker control. 03 — PATH AfdNotifyRemoveIoCompletion runs and produces a value to write back ProbeForWrite is applied to pStruct->pData2 for dwLen * 0x20 bytes, then IoRemoveCompletion -> KeRemoveQueueEx returns a completion count. 04 — MISSING CHECK The completion count is written through field_0x18 with no PreviousMode check ProbeForWrite guards pData2 but never field_0x18, and the write happens regardless of whether the request came from user or kernel mode. The patch adds the missing PreviousMode validation. 05 — PRIMITIVE Arbitrary kernel-address write of a controlled small integer *pStruct->field_0x18 = writeValue lands anywhere in kernel space. Aiming it at a token privilege field or a page-table entry escalates to SYSTEM.

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

15 public PoCs
RepositoryStarsPublishedDescription
chompie1337/Windows_LPE_AFD_CVE-2023-21768 506 2023-03-07 LPE exploit for CVE-2023-21768
SamuelTulach/nullmap 200 2023-03-10 Using CVE-2023-21768 to manual map kernel mode driver
Malwareman007/CVE-2023-21768 65 2023-03-13 Windows_AFD_LPE_CVE-2023-21768
cl4ym0re/cve-2023-21768-compiled 27 2023-03-10 cve-2023-21768
P4x1s/CVE-2023-21768-POC 23 2023-03-22 CVE-2023-21768 Windows 11 22H2 系统本地提权 POC
zoemurmure/CVE-2023-21768-AFD-for-WinSock-EoP-exploit 15 2023-04-20
xboxoneresearch/CVE-2023-21768-dotnet 15 2024-05-15 C# / .NET version of CVE-2023-21768
h1bAna/CVE-2023-21768 3 2023-04-05
Rosayxy/Recreate-cve-2023-21768 1 2023-10-02 recreating exp for cve-2023-21768.
IlanDudnik/CVE-2023-21768 1 2024-12-30 Exploit implementation with IO Rings for CVE-2023-21768
ivanovick1/Windows_AFD_LPE_CVE-2023-21768 0 2023-08-21 Windows 11 System Permission Elevation
ldrx30/CVE-2023-21768 0 2024-04-07 CVE-2023-21768 Proof of Concept
radoi-teodor/CVE-2023-21768-DSE-Bypass 0 2025-08-25
Feede33/Windows-11-Exploit 0 2026-01-20 https://github.com/chompie1337/Windows_LPE_AFD_CVE-2023-21768
leandrofleury/CVE-2023-21768 0 2026-06-15

Detection Rules

Acknowledgments

None