CVE-2023-36906 — Windows Cryptographic Services Information Disclosure Vulnerability
Executive Summary
None
Overview
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N/E:U/RL:O/RC:C
EPSS Score
Affected Products
| Product | KB Article | Severity | Impact | Restart Required |
|---|---|---|---|---|
| Windows 10 for 32-bit Systems | 5029259 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 for x64-based Systems | 5029259 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 Version 1607 for 32-bit Systems | 5029242 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 Version 1607 for x64-based Systems | 5029242 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 Version 1809 for 32-bit Systems | 5029247 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 Version 1809 for ARM64-based Systems | 5029247 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 Version 1809 for x64-based Systems | 5029247 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 Version 21H2 for 32-bit Systems | 5029244 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 Version 21H2 for ARM64-based Systems | 5029244 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 Version 21H2 for x64-based Systems | 5029244 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 Version 22H2 for 32-bit Systems | 5029244 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 Version 22H2 for ARM64-based Systems | 5029244 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 10 Version 22H2 for x64-based Systems | 5029244 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 11 version 21H2 for ARM64-based Systems | 5029253 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 11 version 21H2 for x64-based Systems | 5029253 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 11 Version 22H2 for ARM64-based Systems | 5029263 (Security Update) |
Important | Information Disclosure | Yes |
| Windows 11 Version 22H2 for x64-based Systems | 5029263 (Security Update) |
Important | Information Disclosure | Yes |
| Windows Server 2008 for 32-bit Systems Service Pack 2 5029318 (Monthly Rollup) 5029301 (Security Only) Important Information Disclosure 5028222 Base: 5.5 Temporal: 4.8 Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N/E:U/RL:O/RC:C 6.0.6003.22216 Yes 5029318 5029301 Windows Server 2008 for 32-bit Systems Service Pack 2 (Server Core installation) 5029318 (Monthly Rollup) 5029301 (Security Only) Important Information Disclosure 5028222 Base: 5.5 Temporal: 4.8 Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N/E:U/RL:O/RC:C 6.0.6003.22216 Yes 5029318 5029301 Windows Server 2008 for x64-based Systems Service Pack 2 5029318 (Monthly Rollup) 5029301 (Security Only) Important Information Disclosure 5028222 Base: 5.5 Temporal: 4.8 Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N/E:U/RL:O/RC:C 6.0.6003.22216 Yes 5029318 5029301 Windows Server 2008 for x64-based Systems Service Pack 2 (Server Core installation) 5029318 (Monthly Rollup) 5029301 (Security Only) Important Information Disclosure 5028222 Base: 5.5 Temporal: 4.8 Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N/E:U/RL:O/RC:C 6.0.6003.22216 Yes 5029318 5029301 Windows Server 2008 R2 for x64-based Systems Service Pack 1 5029296 (Monthly Rollup) 5029307 (Security Only) Important Information Disclosure 5028240 Base: 5.5 Temporal: 4.8 Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N/E:U/RL:O/RC:C 6.1.7601.26664 Yes 5029296 5029307 Windows Server 2008 R2 for x64-based Systems Service Pack 1 (Server Core installation) 5029296 (Monthly Rollup) 5029307 (Security Only) Important Information Disclosure 5028240 Base: 5.5 Temporal: 4.8 Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N/E:U/RL:O/RC:C 6.1.7601.26664 Yes 5029296 5029307 Windows Server 2012 5029295 (Monthly Rollup) 5029308 (Security Only) Important Information Disclosure 5028232 Base: 5.5 Temporal: 4.8 Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N/E:U/RL:O/RC:C 6.2.9200.24414 Yes None Windows Server 2012 (Server Core installation) 5029295 (Monthly Rollup) 5029308 (Security Only) Important Information Disclosure 5028232 Base: 5.5 Temporal: 4.8 Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N/E:U/RL:O/RC:C 6.2.9200.24414 Yes None Windows Server 2012 R2 5029312 (Monthly Rollup) 5029304 (Security Only) Important Information Disclosure 5028228 Base: 5.5 Temporal: 4.8 Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N/E:U/RL:O/RC:C 6.3.9600.21503 Yes None Windows Server 2012 R2 (Server Core installation) 5029312 (Monthly Rollup) 5029304 (Security Only) Important Information Disclosure 5028228 Base: 5.5 Temporal: 4.8 Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N/E:U/RL:O/RC:C 6.3.9600.21503 Yes None Windows Server 2016 | 5029242 (Security Update) |
Important | Information Disclosure | Yes |
| Windows Server 2016 (Server Core installation) | 5029242 (Security Update) |
Important | Information Disclosure | Yes |
| Windows Server 2019 | 5029247 (Security Update) |
Important | Information Disclosure | Yes |
| Windows Server 2019 (Server Core installation) | 5029247 (Security Update) |
Important | Information Disclosure | Yes |
Patches
| Article | Type | Restart |
|---|---|---|
5029259 |
Security Update | Yes |
5029242 |
Security Update | Yes |
5029247 |
Security Update | Yes |
5029244 |
Security Update | Yes |
5029253 |
Security Update | Yes |
5029263 |
Security Update | Yes |
Patch Diff
Out-of-bounds read / information disclosure (CWE-170 Improper Null Termination) in the Microsoft Software Key Storage Provider ncryptprov.dll, reachable from an AppContainer sandbox via the CNG Key Isolation RPC (keyiso.dll in lsass). The client-defined 'Use Context' provider property is stored by SPCryptSetProviderProperty at exactly the client-supplied length with NO null terminator, but read back by SPCryptGetProviderProperty as a wide string: `do { ++i; } while (*(WORD*)(buf + 2*i));` scans for a NUL with no bound, then memcpy returns 2*i+2 bytes. If the stored content has no embedded null, the scan runs past the allocation and returns adjacent lsass heap to the caller. k0shl used this to leak a provider-object pointer (defeating ASLR/CFG) to bootstrap the CVE-2023-28229 CNG UAF into lsass code execution / sandbox escape. IN-HOUSE ghidriff of ncryptprov.dll 10.0.22621.1928 -> .2134 (Aug 8 2023) confirms the fix: SPCryptSetProviderProperty now bounds-checks size (<= 0x7ffffffd), allocates _Size+2, and writes a 0x0000 WCHAR terminator at buf[_Size & ~1] before memcpy - so the stored property is always NUL-terminated and the read-side scan stays in bounds. SPCryptSetKeyProperty gets the same hardening (5% match). Unconditional fix (no feature flag). keyiso.dll was RULED OUT: SrvCryptGetProviderProperty is byte-identical across .819/.1555/.1992. Credit: k0shl of Kunlun Lab. Chains with CVE-2023-28229.
| Function | Address | Change | Note |
|---|---|---|---|
SPCryptSetProviderProperty |
96% match |
code (null-termination + bound added, unconditional) | Pre: RtlAllocateHeap(_, 0, _Size) stores the client 'Use Context' buffer with no terminator. Post: adds `if (param_3 == 0 || 0x7ffffffd < uVar3) goto error`, allocates `_Size + 2`, writes `*(WORD*)(buf + (param_4 & 0xfffffffe)) = 0` (NUL terminator), then memcpy(buf, param_3, _Size). Guarantees the stored property is NUL-terminated so the SPCryptGetProviderProperty read-back scan cannot over-read. |
SPCryptSetKeyProperty |
5% match (heavily rewritten) |
code (same null-termination hardening for key properties) | Rewritten alongside the provider-property fix to apply the same terminate-on-store handling to the key-property path. |
SPCryptGetProviderProperty |
unchanged (read/leak site) |
vulnerable sink (not modified) | Reads the stored property as a wide string, scanning for a NUL with no bound (do{++i;}while(*(WORD*)(buf+2*i))) then memcpy 2*i+2 bytes. The fix is on the store side, so this read site is unchanged - which is why a read-side-only or keyiso-only search misses the fix. |
Root Cause Analysis
CVE-2023-36906 — Windows KSP ncryptprov.dll Out-of-Bounds Read via an Un-terminated “Use Context” Provider Property
Summary
| Product | Microsoft Windows — ncryptprov.dll (Microsoft Software Key Storage Provider / KSP) |
| CVE ID | CVE-2023-36906 |
| Impact | Information Disclosure (kernel/service heap leak; sandbox-escape enabler) |
| MSRC severity | Important |
| CWE | CWE-170: Improper Null Termination → out-of-bounds read |
| Patch Date | August 8, 2023 |
| Pre-patch binary | ncryptprov.dll 10.0.22621.1928 (Jun–Jul 2023) — SHA256 879a649afbbd2c83519a0308d06178ae1b9e2a2c7ed236e4a4368a7761270beb |
| Post-patch binary | ncryptprov.dll 10.0.22621.2134 (Aug 8 2023 fix) — SHA256 9072392ae7ff191ed806eda9f46822326fded010a204b80a8beb6d5b86bfec61 |
| Fix gating | None — unconditional (no CFR/KIR flag) |
Product Description
ncryptprov.dll is the Microsoft Software Key Storage Provider, the default
CNG KSP that stores and operates on private keys. It is driven through the CNG
Key Isolation service (keyiso.dll, hosted in lsass), whose RPC surface —
including SrvCryptGetProviderProperty / SrvCryptSetProviderProperty — is
reachable from AppContainer integrity-level processes (browser and Adobe
Reader renderer sandboxes). That reachability is why an info-leak here is a
sandbox-escape enabler: the analysis chained it with the CNG UAF
(CVE-2023-28229) to defeat lsass ASLR/CFG and load a DLL into lsass.
A provider carries a property bag. The “Use Context” property is
client-defined: the caller supplies its size and full content, ncryptprov
stores it, and a later query returns it.
Vulnerability Summary
SPCryptSetProviderProperty stored the “Use Context” buffer at exactly the
client-supplied length, with no null terminator. SPCryptGetProviderProperty
read it back as a wide string — scanning for a L'\0' terminator to compute
the length, then copying that many bytes to the caller:
// SPCryptGetProviderProperty (ncryptprov.dll) — the read side (from the analysis)
v17 = *(QWORD *)(provider + 0x20); // stored "Use Context" buffer
v13 = 0;
do { ++v13; } while (*(WORD *)(v17 + 2*v13)); // *** scans for a NUL — no bound ***
v16 = 2*v13 + 2;
memcpy(a3, v17, v16); // returns v16 bytes to the caller
If the stored property contains no embedded null, the while scan walks off
the end of the allocation and memcpy returns the buffer plus adjacent heap
to the (sandboxed) caller — an out-of-bounds read / information disclosure. The
caller controls the property’s size and content, so it can size the property to
land next to a target object and leak it. It was placed beside a
memory-buffer object to leak a provider-object pointer, the ASLR break that
made CVE-2023-28229 exploitable.
Prerequisites and Constraints
- Local, from inside a sandbox. Reachable from an AppContainer / restricted token via the CNG Key Isolation RPC interface → KSP. No elevated rights.
- The attacker controls the “Use Context” property size and bytes (hence both the over-read length and the heap grooming around it).
- Primitive is an out-of-bounds read: disclosure of adjacent process-heap memory in lsass (the KSP host), not a write. Its value is as an ASLR/CFG-defeating leak that chains into a separate EoP.
Vulnerability Details
Call Chain
Sandboxed (AppContainer) process:
NCryptSetProperty(provider, "Use Context", buf[N]) // store, no terminator
NCryptGetProperty(provider, "Use Context", ...) // read back
↓ RPC to CNG Key Isolation (lsass)
keyiso!SrvCryptSetProviderProperty / SrvCryptGetProviderProperty
↓ KSP
ncryptprov!SPCryptSetProviderProperty // stores buf, unterminated (BUG SOURCE)
ncryptprov!SPCryptGetProviderProperty // NUL-scan over-reads (LEAK SITE)
Root Cause
The store and the read disagree about termination. The property is stored as raw bytes of a client-chosen length, but read back as a NUL-terminated wide string. With no guaranteed terminator, the read’s length computation runs past the allocation (CWE-170 → out-of-bounds read).
The patch (confirmed — diff, .1928 → .2134)
The August build fixes it on the store side: SPCryptSetProviderProperty
now over-allocates by one WCHAR, bounds-checks the size, and writes an explicit
terminator so the buffer is always NUL-terminated:
// SPCryptSetProviderProperty (ncryptprov.dll 10.0.22621.2134) — PATCHED, from our diff
if ((param_3 == NULL) || (0x7ffffffd < uVar3)) goto error; // new upper bound (leave room for NUL)
...
buf = RtlAllocateHeap(heap, 0, _Size + 2); // *** +2 bytes for a WCHAR terminator ***
*(WORD *)(buf + (param_4 & 0xfffffffe)) = 0; // *** write L'\0' at the end ***
memcpy(buf, param_3, _Size); // then copy the client content
Because the stored “Use Context” property is now always NUL-terminated, the
SPCryptGetProviderProperty scan terminates inside the allocation and the
over-read is gone. SPCryptSetKeyProperty receives the same hardening (heavily
rewritten — 5% match), covering the key-property store path as well.
Patch Completeness Assessment
Unconditional fix — no Controlled Feature Rollout flag or Known Issue
Rollback toggle (no Feature_* gate in the diff). As with the other 2022–2023
fixes in this corpus (npfs CVE-2022-22715, DHCPv6 CVE-2023-28231), the
remediation is always-on and patch state is determined by file version. Note the
fix is on the store side (Set…Property); the read side
(SPCryptGetProviderProperty) is unchanged, which is why a keyiso.dll-only or
read-side-only search misses it.
Detection Guidance
Behavioural. A sandboxed (AppContainer) process driving the CNG Key Isolation RPC to set a “Use Context” provider property whose content has no embedded null and then immediately querying it back — especially repeatedly with sizes tuned to sit beside other allocations. Legitimate callers store terminated, modest context blobs.
Host. Anomalous CNG KSP activity from renderer-class processes; correlate KSP property set/get bursts with the process’s integrity level. Because the leak lands in lsass, pair with lsass-integrity monitoring — this info-leak is typically the first stage of an lsass code-execution chain (see CVE-2023-28229).
Config. File-version check is sufficient (fix not feature-gated): a patched
ncryptprov.dll (≥ Aug 2023 build for the branch) is not vulnerable.
References
- k0shl (Kunlun Lab) — Isolate me from sandbox: Explore elevation of privilege
of CNG Key Isolation (covers CVE-2023-28229 UAF and CVE-2023-36906 info leak).
whereisk0shl.top - MSRC advisory — CVE-2023-36906 (Windows Cryptographic Services Information Disclosure)
- Full binary diff:
/data/patch_diffs/ncryptprov_dll-cve-2023-36906-ghidriff.md - Chained with: CVE-2023-28229 (CNG Key Isolation UAF, keyiso.dll)
Attack Path
A 'Use Context' KSP property is stored without a null terminator, so reading it back as a string over-reads adjacent lsass heap
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.