CVE-2022-22715 — Named Pipe File System Elevation of Privilege Vulnerability
Executive Summary
"Windows Dirty Pipe." An integer-overflow-to-out-of-bounds-write in the Named Pipe File System driver (npfs.sys), reachable only from an AppContainer or restricted (sandboxed) token - making it a renderer/UWP sandbox-escape rather than an ordinary local EoP (it was used at TianfuCup 2021 to escape the Adobe Reader sandbox). Opening \Device\NamedPipe\LOCAL\<name> reaches NpTranslateContainerLocalAlias, which rewrites the name into the AppContainer object namespace and sizes a pool buffer using 16-bit (ushort) arithmetic. A sufficiently long pipe name wraps the size to 0 (yielding a tiny 0x20 allocation) while the UNICODE_STRING MaximumLength, decremented past 0, underflows to 0xFFFE; RtlUnicodeStringPrintf then writes ~64 KB of attacker-controlled name into the tiny buffer - a controlled paged-pool overflow that can be groomed (WNF + _TOKEN objects) into arbitrary kernel read/write and SYSTEM. Microsoft's February 2022 fix widens the size arithmetic to 32-bit and adds a bound check (allocate only when the length is < 0xFFFF); the fix is unconditional (no feature flag). Reported by k0shl of Kunlun Lab. Confirmed by an in-house binary diff of npfs.sys 10.0.18362.267 -> .2094.
Overview
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
EPSS Score
Affected Products
| Product | KB Article | Severity | Impact | Restart Required |
|---|---|---|---|---|
| Windows 10 Version 1809 for 32-bit Systems | 5010351 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 1809 for ARM64-based Systems | 5010351 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 1809 for x64-based Systems | 5010351 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 1909 for 32-bit Systems | 5010345 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 1909 for ARM64-based Systems | 5010345 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 1909 for x64-based Systems | 5010345 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 20H2 for 32-bit Systems | 5010342 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 20H2 for ARM64-based Systems | 5010342 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 20H2 for x64-based Systems | 5010342 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 21H1 for 32-bit Systems | 5010342 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 21H1 for ARM64-based Systems | 5010342 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 21H1 for x64-based Systems | 5010342 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 21H2 for 32-bit Systems | 5010342 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 21H2 for ARM64-based Systems | 5010342 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 10 Version 21H2 for x64-based Systems | 5010342 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 11 version 21H2 for ARM64-based Systems | 5010386 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows 11 version 21H2 for x64-based Systems | 5010386 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows Server 2019 | 5010351 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows Server 2019 (Server Core installation) | 5010351 (Security Update) |
Important | Elevation of Privilege | Yes |
| Windows Server 2022 5010354 (Security Update) 5010456 (Security Hotpatch Update) Important Elevation of Privilege 5009555 Base: 7.8 Temporal: 6.8 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 10.0.20348.524 10.0.20348.525 Yes 5010354 Windows Server 2022 (Server Core installation) 5010354 (Security Update) 5010456 (Security Hotpatch Update) Important Elevation of Privilege 5009555 Base: 7.8 Temporal: 6.8 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 10.0.20348.524 10.0.20348.525 Yes 5010354 Windows Server, version 20H2 (Server Core Installation) | 5010342 (Security Update) |
Important | Elevation of Privilege | Yes |
Patches
| Article | Type | Restart |
|---|---|---|
5010351 |
Security Update | Yes |
5010345 |
Security Update | Yes |
5010342 |
Security Update | Yes |
5010386 |
Security Update | Yes |
Patch Diff
"Windows Dirty Pipe": a 16-bit integer overflow -> pool out-of-bounds write in npfs.sys NpTranslateContainerLocalAlias, reachable ONLY from an AppContainer/restricted (sandboxed) token - a renderer/UWP sandbox escape (used at TianfuCup 2021 to escape the Adobe Reader sandbox). Opening \Device\NamedPipe\LOCAL\<name> routes NpFsdCreate -> NpTranslateAlias (matches the LOCAL\ prefix) -> NpTranslateContainerLocalAlias, which rewrites the name into Sessions\<n>\AppContainerNamedObjects\<sid>\...\<name>. All size vars were 16-bit: total = prefix + namelen + 0x14 (+2 if the remaining name starts with '\'); a long pipe name wraps this ushort to 0, so ExAllocatePoolWithTag returns a tiny 0x20 'NpFn' buffer, and the UNICODE_STRING MaximumLength decremented past 0 underflows to 0xFFFE. RtlUnicodeStringPrintf then writes ~64KB of attacker-controlled name bytes into the 0x20 pool -> controlled paged-pool OOB write (CWE-190 -> CWE-787). The trigger needs the total size to wrap to exactly 0. IN-HOUSE ghidriff diff of 10.0.18362.267 -> .2094 confirms NpTranslateContainerLocalAlias is the ONLY changed function (99.8% match): the fix widens the size arithmetic from short to 32-bit int/uint (iVar5/iVar10/uVar6) and adds a bound check `if (uVar6 < 0xffff)` before ExAllocatePoolWithTag, eliminating both the overflow and the 0xFFFE underflow. UNCONDITIONAL fix - no CFR/KIR flag. k0shl's PoC chains WNF _WNF_STATE_DATA + _TOKEN grooming into arbitrary R/W and sets ETHREAD.PreviousMode=0. Credit: k0shl of Kunlun Lab via TianfuCup 2021.
| Function | Address | Change | Note |
|---|---|---|---|
NpTranslateContainerLocalAlias |
99.8% match (only changed function) |
code (size arithmetic widened short->int + `< 0xffff` bound check, unconditional) | Pre: 16-bit size vars (short sVar5/sVar10); total = (short)prefix + 100 + (ushort)namelen (+2 if ifslash) wraps to 0 -> ExAllocatePoolWithTag(PagedPool, sVar5, 'NpFn') tiny alloc; MaximumLength -= 2 underflows 0 -> 0xFFFE; RtlUnicodeStringPrintf OOB-writes ~64KB. Post: iVar5/iVar10/uVar6 computed as 32-bit uint (no 16-bit wrap) and `if (uVar6 < 0xffff)` gates the allocation. Reached only when the token is AppContainer or restricted (SeQueryInformationToken TokenIsAppContainer/TokenIsRestricted). |
Root Cause Analysis
CVE-2022-22715 — “Windows Dirty Pipe”: npfs.sys NpTranslateContainerLocalAlias 16-bit Integer Overflow → Pool Out-of-Bounds Write (Sandbox Escape)
Summary
| Product | Microsoft Windows — npfs.sys (Named Pipe File System driver) |
| CVE ID | CVE-2022-22715 |
| Impact | Elevation of Privilege — sandbox escape (AppContainer/restricted → kernel) |
| MSRC severity | Important |
| CWE | CWE-190: Integer Overflow or Wraparound → CWE-787: Out-of-bounds Write |
| Patch Date | February 8, 2022 |
| Pre-patch binary | npfs.sys 10.0.18362.267 (served through 2022-01) — SHA256 d0179a8b31eb86b2c677c0aa3390f61510ae2f6ce48e42801f3b1352b4a291ed |
| Post-patch binary | npfs.sys 10.0.18362.2094 (Feb 2022 fix) — SHA256 28a29817b30798072d2e72df5fc403fdc63c480b3ef0bdae71a73bd16bcf309a |
| Fix gating | None — unconditional widen-and-check (no CFR/KIR flag) |
Product Description
npfs.sys implements the Named Pipe File System — the kernel driver behind
\Device\NamedPipe, the IPC primitive browsers and sandboxed applications
(old Edge, Adobe Reader) use between their broker and renderer processes. When
AppContainer arrived in Windows 8.1, npfs gained a name-translation path so a
sandboxed process’s pipe names are rewritten into its per-container object
namespace. That path — present for ~10 years — is the bug, reachable from
inside an AppContainer or restricted-token sandbox, which is exactly what makes
this a renderer-to-kernel sandbox escape rather than an ordinary local EoP.
Vulnerability Summary
Opening \Device\NamedPipe\LOCAL\… routes NpFsdCreate → NpTranslateAlias
(which matches the LOCAL\ prefix) → NpTranslateContainerLocalAlias. That
function rewrites the name into
Sessions\<n>\AppContainerNamedObjects\<sid>\…\<name> and allocates a pool
buffer sized for the result. Every size variable was 16-bit (ushort/short).
// NpTranslateContainerLocalAlias (npfs.sys 10.0.18362.267) — PRE-PATCH, from our diff
// (symbol names from the public PDB)
short sVar5; // total size — 16-bit
...
if (ifslash) { MaximumLength -= 2; ... } // remaining-name leading '\'
...
sVar5 = (short)prefix + 100 + (ushort)namelen; // 16-bit add
if (ifslash) sVar5 = sVar5 + 2; // +2, still 16-bit
buf = ExAllocatePoolWithTag(PagedPool, sVar5, 'NpFn'); // *** sVar5 can wrap to 0 ***
if (buf) {
if (ifslash) { buf++; MaximumLength -= 2; } // 0 - 2 -> 0xFFFE (ushort underflow)
RtlUnicodeStringPrintf(&dst, L"Sessions\\%ld\\AppContainerNamedObjects\\%wZ\\%wZ\\%wZ", ...);
// copies up to dst.MaximumLength (0xFFFE) bytes into the tiny buffer
}
Two chained integer bugs:
- Overflow to 0. With a long enough pipe name, the 16-bit
sVar5wraps to exactly0, soExAllocatePoolWithTagreturns a minimal (0x20)NpFnallocation. - Underflow to 0xFFFE. With the leading-
\(ifslash) case, theUNICODE_STRING.MaximumLengthis decremented by 2 from0→0xFFFE.
RtlUnicodeStringPrintf then formats the translated name up to MaximumLength
(0xFFFE ≈ 64 KB) into the 0x20 buffer — a paged-pool out-of-bounds write of
~64 KB of attacker-controlled name bytes, corrupting adjacent 0x20 LFH
allocations and neighbouring pool. The crash lands in
ExAcquirePushLockExclusiveEx on a 0x41414141… pointer from a smashed object.
Prerequisites and Constraints
- Local, but from inside a sandbox. The function only proceeds when the
caller’s token is AppContainer or restricted
(
SeQueryInformationToken(TokenIsAppContainer)/TokenIsRestricted). A normal token returns early — so this is specifically a primitive for escaping a renderer/UWP sandbox, not a generic local trigger. - The attacker controls the pipe name (length and bytes), hence both the allocation size (via the overflow) and the overflowing content.
- To reach the underflow, the total size must wrap to exactly 0 (any other
small value leaves
MaximumLengthsmall and no OOB) — note this precise-length requirement as the main triggering constraint. - Primitive is a controlled paged-pool OOB write; k0shl chains it (WNF
_WNF_STATE_DATAmanager object +_TOKENworker object, LFH/VS cross-subsegment grooming) into arbitrary kernel R/W and setsETHREAD.PreviousMode = 0for EoP.
Vulnerability Details
Call Chain
Sandboxed (AppContainer/restricted) process:
NtCreateFile("\Device\NamedPipe\LOCAL\<long name>")
↓ IRP_MJ_CREATE
npfs!NpFsdCreate
→ npfs!NpTranslateAlias // matches "LOCAL\" prefix
→ npfs!NpTranslateContainerLocalAlias [*** 16-bit overflow → OOB pool write ***]
ExAllocatePoolWithTag(PagedPool, size16, 'NpFn') // size wraps to 0 → 0x20 buf
RtlUnicodeStringPrintf(dst[MaximumLength=0xFFFE], …) // ~64KB copy
Root Cause
The translated-name length is computed and stored in 16-bit fields. A long pipe
name overflows the size to 0 (tiny allocation) while the UNICODE_STRING
MaximumLength, decremented past 0, underflows to 0xFFFE, so the subsequent
RtlUnicodeStringPrintf writes far beyond the allocation. Root cause is the
16-bit width of the size arithmetic (CWE-190) driving an OOB write (CWE-787).
The patch
The February 2022 build widens the size math to 32-bit and refuses any length
that would not fit a 16-bit UNICODE_STRING:
// NpTranslateContainerLocalAlias (10.0.18362.2094) — PATCHED, from our diff
int iVar5 = (uint)(ushort)prefix + (uint)(ushort)namelen + 0x78; // 32-bit
int iVar10 = (uint)(ushort)prefix + (uint)(ushort)namelen + 0x7a; // 32-bit (+2 variant)
uint uVar6 = (uint)extra + iVar5;
if (ifslash) uVar6 = iVar10 + (uint)extra;
if (uVar6 < 0xffff) { // *** NEW BOUND CHECK (<= 0xFFFE) ***
dst.MaximumLength = (ushort)uVar6;
buf = ExAllocatePoolWithTag(PagedPool, uVar6 & 0xffff, 'NpFn');
... // proceed only for in-range sizes
}
Because uVar6 is a full 32-bit uint, the sum can no longer wrap in 16 bits,
and the uVar6 < 0xffff guard rejects any length that would overflow a
UNICODE_STRING. Both the tiny-allocation and the 0xFFFE underflow are thereby
eliminated. (k0shl’s Server-2022 build shows the same fix expressed with
ExAllocatePool2 and if (v23 <= 0xFFFE).)
Patch Completeness Assessment
Unconditional fix — no Controlled Feature Rollout flag or Known Issue Rollback toggle. As with the 2023 DHCPv6 fix (CVE-2023-28231), the February 2022 npfs patch ships a straight widen-and-check with no gated fallback; patch state is determined by file version. The “both paths ship, gated at runtime” servicing pattern seen across the 2024–2026 CVEs in this corpus is not present here.
Detection Guidance
Crash signature. Paged-pool corruption bugchecks with the faulting access on
a 0x4141…-style pointer, stacks through npfs!NpTranslateContainerLocalAlias
/ RtlUnicodeStringPrintf, NpFn (Name block) pooltag near the overrun. Special
Pool on npfs.sys makes the OOB land on a guard page at the format call.
Behavioural. A sandboxed process (AppContainer / restricted token —
browser renderer, Adobe Reader) opening \Device\NamedPipe\LOCAL\… with an
unusually long pipe name. Legitimate LOCAL alias names are short; a name crafted
to wrap a 16-bit length (hundreds of chars, tuned so the total size hits exactly
0) is the direct indicator.
Config. File-version check is sufficient here — the fix is not feature-gated,
so a patched npfs.sys (≥ Feb 2022 build for the branch) is not vulnerable.
References
- k0shl (Kunlun Lab) — Break me out of sandbox in old pipe: CVE-2022-22715
Windows Dirty Pipe.
whereisk0shl.top - CVE-2022-22715 PoC
- MSRC advisory — CVE-2022-22715 (Named Pipe File System Elevation of Privilege)
- Full binary diff:
/data/patch_diffs/npfs_sys-cve-2022-22715-ghidriff.md
Attack Path
A long LOCAL\ pipe name wraps a 16-bit size to 0 (tiny pool) while MaximumLength underflows to 0xFFFE, so the name format-copy overruns paged pool - from inside a sandbox
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
Detection Rules
Acknowledgments
Kunlun lab (https://www.cyberkl.com) via TianfuCup (https://www.tianfucup.com)